From a32c0d3fd47adfd97dd11b8d3eef5bcc371c71e3 Mon Sep 17 00:00:00 2001 From: tdc Date: Wed, 6 Sep 2023 17:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=96=B0=E5=A2=9E=E4=B8=8B?= =?UTF-8?q?=E8=BC=89=E5=B0=81=E9=9D=A2=E7=85=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Anime.py | 22 ++++++++++++++++++++++ Config.py | 4 +++- config-sample.json | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Anime.py b/Anime.py index 5d3001a..b415bcd 100644 --- a/Anime.py +++ b/Anime.py @@ -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' @@ -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 diff --git a/Config.py b/Config.py index 99c6acd..f862be1 100644 --- a/Config.py +++ b/Config.py @@ -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) diff --git a/config-sample.json b/config-sample.json index d3ef529..65c212e 100644 --- a/config-sample.json +++ b/config-sample.json @@ -67,6 +67,6 @@ }, "save_logs": true, "quantity_of_logs": 7, - "config_version": 13.0, + "config_version": 13.1, "database_version": 2.0 }