Skip to content

Commit

Permalink
Merge pull request #60 from nichuanfang/dev
Browse files Browse the repository at this point in the history
feat: 测试自动更新yt-dlp版本
  • Loading branch information
nichuanfang authored Jul 9, 2024
2 parents 45c643c + 8983f44 commit c7bcd9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update_dep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ jobs:
TWINE_PASSWORD: ${{secrets.PYPI_PASSWORD}}
YT_DLP_VERSION: ${{steps.release-drafter.outputs.tag_name}}
run: |
pip install wheel twine
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
wheel==0.43.0
twine==5.1.1
rich==13.7.1
setuptools==70.0.0
yt-dlp==2024.7.8
14 changes: 7 additions & 7 deletions update_ytdlp.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import requests
import re

# 获取当前 requirements.txt 中的 yt-dlp 版本


def get_current_ytdlp_version():
# 获取当前 requirements.txt 中的 yt-dlp 版本
with open('requirements.txt', 'r') as file:
for line in file:
if line.startswith('yt-dlp'):
Expand All @@ -22,10 +21,9 @@ def get_latest_ytdlp_version():
return latest_version
return None

# 更新 requirements.txt 文件中的 yt-dlp 版本


def update_requirements_file(new_version):
# 更新 requirements.txt 文件中的 yt-dlp 版本
with open('requirements.txt', 'r') as file:
lines = file.readlines()
with open('requirements.txt', 'w') as file:
Expand All @@ -35,24 +33,26 @@ def update_requirements_file(new_version):
else:
file.write(line)

# 主逻辑


def main():
# 主逻辑
current_version = get_current_ytdlp_version()
latest_version = get_latest_ytdlp_version()

if current_version and latest_version and current_version != latest_version:
update_requirements_file(latest_version)
print(
f'Updated yt-dlp from {current_version} to {latest_version} in requirements.txt')

author_email = 'git config --global user.email "[email protected]"'
author_username = 'git config --global user.name "AutoUpdater"'
# 使用 Git 提交更改
commit_message = f'Update yt-dlp to version {latest_version}'
commit_command = f'git commit -am "{commit_message}"'
push_command = 'git push origin main'

import subprocess
subprocess.run(author_email, shell=True)
subprocess.run(author_username, shell=True)
subprocess.run(commit_command, shell=True)
subprocess.run(push_command, shell=True)
else:
Expand Down

0 comments on commit c7bcd9a

Please sign in to comment.