Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 新增下載封面照 #257

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,15 @@ def download(self, resolution='', save_dir='', bangumi_tag='', realtime_show_fil
except:
err_print(self._sn, 'Plex auto Refresh UNKNOWN ERROR', 'Exception: ' + str(e), status=1)

# 下載封面照
if self._settings['download_poster']:
url = self.get_thumbnail()
full_filename = os.path.join(self._bangumi_dir, 'poster.jpg')
if url:
with requests.get(url, stream=True) as r:
with open(full_filename, 'wb') as f:
shutil.copyfileobj(r.raw, f)

def upload(self, bangumi_tag='', debug_file=''):
first_connect = True # 标记是否是第一次连接, 第一次连接会删除临时缓存目录
tmp_dir = str(self._sn) + '-uploading-by-aniGamerPlus'
Expand Down Expand Up @@ -1362,6 +1371,19 @@ def get_info(self):
err_print(0, indent+'参考檔名:', '\"' + self.get_filename() + '\"', no_sn=True, display_time=False)
err_print(0, indent+'可用解析度', 'P '.join(self.get_m3u8_dict().keys()) + 'P\n', no_sn=True, display_time=False)

def get_thumbnail(self):
if self._settings['use_mobile_api']:
return self._src['data']['anime']['cover']
else:
soup = self._src
# return soup.find('meta', property='og:image')['content']
try:
return soup.find('div', 'data-file').img['data-src']
except (TypeError, AttributeError, KeyError):
# 该sn下没有动画
err_print(self._sn, 'ERROR: 該 sn 下真的有動畫?', status=1)
sys.exit(1)

def enable_danmu(self):
self._danmu = True

Expand Down
8 changes: 5 additions & 3 deletions Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
sn_list_path = os.path.join(working_dir, 'sn_list.txt')
cookie_path = os.path.join(working_dir, 'cookie.txt')
logs_dir = os.path.join(working_dir, 'logs')
aniGamerPlus_version = 'v24.5'
latest_config_version = 17.2
aniGamerPlus_version = 'v24.6'
latest_config_version = 17.3
latest_database_version = 2.0
cookie = None
max_multi_thread = 5
Expand Down Expand Up @@ -161,7 +161,9 @@ def __init_settings():
'save_logs': True,
'quantity_of_logs': 7,
'config_version': latest_config_version,
'database_version': latest_database_version
'database_version': latest_database_version,
'download_poster': True,
'generate_nfo': True,
}
with open(config_path, 'w', encoding='utf-8') as f:
json.dump(settings, f, ensure_ascii=False, indent=4)
Expand Down
2 changes: 1 addition & 1 deletion config-sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@
},
"save_logs": true,
"quantity_of_logs": 7,
"config_version": 13.0,
"config_version": 13.1,
tasi788 marked this conversation as resolved.
Show resolved Hide resolved
"database_version": 2.0
}
Loading