From e6cdd337c3e7ac4f8a9ad9aca6ffd5ba7685e801 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 10 May 2025 20:10:13 +0800 Subject: [PATCH] fix subscribe files --- app/db/models/downloadhistory.py | 20 ++++++++++---------- app/modules/filemanager/__init__.py | 3 ++- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/app/db/models/downloadhistory.py b/app/db/models/downloadhistory.py index 400a2eed..7e96b01f 100644 --- a/app/db/models/downloadhistory.py +++ b/app/db/models/downloadhistory.py @@ -1,7 +1,7 @@ import time from typing import Optional -from sqlalchemy import Column, Integer, String, Sequence, JSON +from sqlalchemy import Column, Integer, String, Sequence, JSON, or_ from sqlalchemy.orm import Session from app.db import db_query, db_update, Base @@ -65,8 +65,8 @@ class DownloadHistory(Base): @staticmethod @db_query def get_by_mediaid(db: Session, tmdbid: int, doubanid: str): - return db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, - DownloadHistory.doubanid == doubanid).all() + return db.query(DownloadHistory).filter(or_(DownloadHistory.tmdbid == tmdbid, + DownloadHistory.doubanid == doubanid)).all() @staticmethod @db_query @@ -81,7 +81,7 @@ class DownloadHistory(Base): @staticmethod @db_query - def get_last_by(db: Session, mtype: Optional[str] = None, title: Optional[str] = None, + def get_last_by(db: Session, mtype: Optional[str] = None, title: Optional[str] = None, year: Optional[str] = None, season: Optional[str] = None, episode: Optional[str] = None, tmdbid: Optional[int] = None): """ @@ -97,18 +97,18 @@ class DownloadHistory(Base): DownloadHistory.type == mtype, DownloadHistory.seasons == season, DownloadHistory.episodes == episode).order_by( - DownloadHistory.id.desc()).all() + DownloadHistory.id.desc()).all() # 电视剧某季 elif season: result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, DownloadHistory.type == mtype, DownloadHistory.seasons == season).order_by( - DownloadHistory.id.desc()).all() + DownloadHistory.id.desc()).all() else: # 电视剧所有季集/电影 result = db.query(DownloadHistory).filter(DownloadHistory.tmdbid == tmdbid, DownloadHistory.type == mtype).order_by( - DownloadHistory.id.desc()).all() + DownloadHistory.id.desc()).all() # 标题 + 年份 elif title and year: # 电视剧某季某集 @@ -117,18 +117,18 @@ class DownloadHistory(Base): DownloadHistory.year == year, DownloadHistory.seasons == season, DownloadHistory.episodes == episode).order_by( - DownloadHistory.id.desc()).all() + DownloadHistory.id.desc()).all() # 电视剧某季 elif season: result = db.query(DownloadHistory).filter(DownloadHistory.title == title, DownloadHistory.year == year, DownloadHistory.seasons == season).order_by( - DownloadHistory.id.desc()).all() + DownloadHistory.id.desc()).all() else: # 电视剧所有季集/电影 result = db.query(DownloadHistory).filter(DownloadHistory.title == title, DownloadHistory.year == year).order_by( - DownloadHistory.id.desc()).all() + DownloadHistory.id.desc()).all() if result: return list(result) diff --git a/app/modules/filemanager/__init__.py b/app/modules/filemanager/__init__.py index 35babfb7..9082cda1 100644 --- a/app/modules/filemanager/__init__.py +++ b/app/modules/filemanager/__init__.py @@ -1311,7 +1311,8 @@ class FileManagerModule(_ModuleBase): if media_files: for media_file in media_files: if f".{media_file.extension.lower()}" in settings.RMT_MEDIAEXT: - ret_fileitems.append(media_file) + if media_file not in ret_fileitems: + ret_fileitems.append(media_file) return ret_fileitems def media_exists(self, mediainfo: MediaInfo, **kwargs) -> Optional[ExistMediaInfo]: