From d550de4e9feacf0882922c5d0142ffd416557a1c Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Thu, 25 Dec 2025 10:55:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=20TMDB=20?= =?UTF-8?q?=E4=B8=8A=E9=9B=86=E7=9A=84=20air=5Fdate=20=E8=A2=AB=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=B6=20air=5Fdate=5Flocal=20=E6=9C=AA=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=B8=85=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题描述: - 当 TMDB 上某一集的播出日期被删除后,本地数据库的 air_date 会在刷新时被清空 - 但对应的 air_date_local 没有被清空,导致已播出集数计算不准确 修复内容: - 修改 update_episodes_air_date_local 函数,在所有三个分支中添加对 air_date 为空的处理 - 当 air_date 为空时,自动清空对应的 air_date_local - 确保 air_date_local 始终与 air_date 保持一致 影响范围: - 修复后,当 TMDB 上集的播出日期被删除时,air_date_local 会被正确清空 - is_episode_aired 函数会正确返回 False,已播出集数计算会及时更新 --- app/run.py | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/app/run.py b/app/run.py index fa18d36..3f3326d 100644 --- a/app/run.py +++ b/app/run.py @@ -6360,7 +6360,9 @@ def update_episodes_air_date_local(cal_db: CalendarDB, tmdb_id: int, season_numb for ep in episodes: ep_air_date = ep.get('air_date') or '' ep_number = ep.get('episode_number') or 0 - if ep_air_date and ep_number: + if not ep_number: + continue + if ep_air_date: try: from datetime import datetime as _dt, timedelta as _td src_date = _dt.strptime(ep_air_date, '%Y-%m-%d').date() @@ -6373,13 +6375,26 @@ def update_episodes_air_date_local(cal_db: CalendarDB, tmdb_id: int, season_numb ) except Exception as _e_sync: logging.debug(f"使用手动偏移值更新 air_date_local 失败 tmdb_id={tmdb_id}, season={season_number}, ep={ep_number}: {_e_sync}") + else: + # 如果 air_date 为空,清空 air_date_local + try: + cal_db.update_episode_air_date_local( + int(tmdb_id), + int(season_number), + int(ep_number), + '' + ) + except Exception as _e_clear: + logging.debug(f"清空 air_date_local 失败 tmdb_id={tmdb_id}, season={season_number}, ep={ep_number}: {_e_clear}") return else: # 没有时区信息且没有手动偏移值,将 air_date_local 设置为与 air_date 相同的值 for ep in episodes: ep_air_date = ep.get('air_date') or '' ep_number = ep.get('episode_number') or 0 - if ep_air_date and ep_number: + if not ep_number: + continue + if ep_air_date: try: cal_db.update_episode_air_date_local( int(tmdb_id), @@ -6389,6 +6404,17 @@ def update_episodes_air_date_local(cal_db: CalendarDB, tmdb_id: int, season_numb ) except Exception as _e_sync: logging.debug(f"同步 air_date 到 air_date_local 失败 tmdb_id={tmdb_id}, season={season_number}, ep={ep_number}: {_e_sync}") + else: + # 如果 air_date 为空,清空 air_date_local + try: + cal_db.update_episode_air_date_local( + int(tmdb_id), + int(season_number), + int(ep_number), + '' + ) + except Exception as _e_clear: + logging.debug(f"清空 air_date_local 失败 tmdb_id={tmdb_id}, season={season_number}, ep={ep_number}: {_e_clear}") return # 获取本地时区配置 @@ -6401,7 +6427,9 @@ def update_episodes_air_date_local(cal_db: CalendarDB, tmdb_id: int, season_numb for ep in episodes: ep_air_date = ep.get('air_date') or '' ep_number = ep.get('episode_number') or 0 - if ep_air_date and ep_number: + if not ep_number: + continue + if ep_air_date: try: # 解析 TMDB air_date 作为源时区日期 src_date = _dt.strptime(ep_air_date, '%Y-%m-%d').date() @@ -6436,6 +6464,17 @@ def update_episodes_air_date_local(cal_db: CalendarDB, tmdb_id: int, season_numb ) except Exception as _e_local: logging.debug(f"计算本地播出日期失败 tmdb_id={tmdb_id}, season={season_number}, ep={ep_number}: {_e_local}") + else: + # 如果 air_date 为空,清空 air_date_local + try: + cal_db.update_episode_air_date_local( + int(tmdb_id), + int(season_number), + int(ep_number), + '' + ) + except Exception as _e_clear: + logging.debug(f"清空 air_date_local 失败 tmdb_id={tmdb_id}, season={season_number}, ep={ep_number}: {_e_clear}") # 如果计算出了日期偏移且用户没有手动设置,存储到数据库 # 这里的 date_offset 是通过时区转换计算出的偏移值(例如:美东周日 21:00 -> 北京时间周一 10:00,偏移 +1) From 7abb33f7ce2baa4e803f45ea8b6141d7093a63c4 Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Thu, 25 Dec 2025 16:14:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=84=E8=8C=83=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 2 +- .gitignore | 2 +- notify.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2cadd08..bbe3253 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -120,4 +120,4 @@ jobs: prerelease: false body: "## What's Changed\n\n${{ steps.get_commit_messages.outputs.commits }}" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index c1e5b58..fdea2b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ quark_config_debug.json __pycache__ /config -.vscode \ No newline at end of file +.vscode diff --git a/notify.py b/notify.py index be1f824..e07345a 100644 --- a/notify.py +++ b/notify.py @@ -1039,4 +1039,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main()