😮‍💨完善github信息获取机制,完善action文件,修复问题(@weekdaycare)

This commit is contained in:
柳神 2024-10-29 12:01:38 +08:00
parent d9019fe88e
commit ec87edc284
4 changed files with 23 additions and 9 deletions

View File

@ -26,7 +26,7 @@ jobs:
issue-number: ${{ github.event.issue.number }}
body: |
🤩你好呀! ${{ github.event.issue.user.login }}!你已经成功通过邮件订阅了本站啦!若有新文章将通过邮箱推送给你!谢谢你的订阅!
😥如果您实在想要关闭订阅在右下角直接删除这个issue就好咕咕咕咕咕咕咕
😥如果您实在想要关闭订阅在右下角直接删除这个issue就好咕咕咕咕咕咕咕感谢你的订阅!
- name: Close issue
uses: actions-cool/issues-helper@v3

View File

@ -46,7 +46,9 @@ jobs:
- name: Check RSS feeds
env:
SMTP_PWD: ${{ secrets.SMTP_PWD }}
FCL_REPO: ${{ github.repository }}
run: |
echo "Checking RSS feeds..."
python run.py
- name: Upload last_articles.json as artifact

View File

@ -193,7 +193,7 @@ def parse_feed(url, session, count=5):
return result
except Exception as e:
print(f"不可链接的FEED地址{url}: {e}")
print(f"不可链接的FEED地址{url} : {e}")
return {
'website_name': '',
'author': '',
@ -223,10 +223,10 @@ def process_friend(friend, session, count, specific_RSS=[]):
if rss_feed:
feed_url = rss_feed
feed_type = 'specific'
print(f"========“{name}”的博客“{blog_url}”为特定RSS源“{feed_url}”========")
print(f"========“{name}”的博客“{blog_url} ”为特定RSS源“{feed_url}”========")
else:
feed_type, feed_url = check_feed(blog_url, session)
print(f"========“{name}”的博客“{blog_url}”的feed类型为“{feed_type}”========")
print(f"========“{name}”的博客“{blog_url} ”的feed类型为“{feed_type}”========")
if feed_type != 'none':
feed_info = parse_feed(feed_url, session, count)
@ -275,7 +275,7 @@ def fetch_and_process_data(json_url, specific_RSS=[], count=5):
response = session.get(json_url, headers=headers, timeout=timeout)
friends_data = response.json()
except Exception as e:
print(f"无法获取该链接:{json_url}, 出现的问题为:{e}")
print(f"无法获取该链接:{json_url} , 出现的问题为:{e}")
return None
total_friends = len(friends_data['friends'])
@ -364,7 +364,7 @@ def marge_data_from_json_url(data, marge_json_url):
response = requests.get(marge_json_url, headers=headers, timeout=timeout)
marge_data = response.json()
except Exception as e:
print(f"无法获取该链接:{marge_json_url}, 出现的问题为:{e}")
print(f"无法获取该链接:{marge_json_url} , 出现的问题为:{e}")
return data
if 'article_data' in marge_data:
@ -389,7 +389,7 @@ def marge_errors_from_json_url(errors, marge_json_url):
response = requests.get(marge_json_url, headers=headers, timeout=timeout)
marge_errors = response.json()
except Exception as e:
print(f"无法获取该链接:{marge_json_url}, 出现的问题为:{e}")
print(f"无法获取该链接:{marge_json_url} , 出现的问题为:{e}")
return errors
print("开始合并错误信息,原错误信息共有 %d 位朋友,境外错误信息共有 %d 位朋友" % (len(errors), len(marge_errors)))

16
run.py
View File

@ -45,8 +45,20 @@ if config["email_push"]["enable"]:
if config["rss_subscribe"]["enable"]:
print("RSS通过issue订阅已启用")
# 获取并强制转换为字符串
github_username = str(config["rss_subscribe"]["github_username"]).strip()
github_repo = str(config["rss_subscribe"]["github_repo"]).strip()
# 尝试从环境变量获取 FCL_REPO
fcl_repo = os.getenv('FCL_REPO')
# 提取 github_username 和 github_repo
if fcl_repo:
github_username, github_repo = fcl_repo.split('/')
print(f"从环境变量获取到的 GitHub Username: {github_username}")
print(f"从环境变量获取到的 GitHub Repo: {github_repo}")
else:
github_username = str(config["rss_subscribe"]["github_username"]).strip()
github_repo = str(config["rss_subscribe"]["github_repo"]).strip()
print(f"从配置文件获取到的 GitHub Username: {github_username}")
print(f"从配置文件获取到的 GitHub Repo: {github_repo}")
your_blog_url = config["rss_subscribe"]["your_blog_url"]
email_template = config["rss_subscribe"]["email_template"]
# 获取网站信息