add db订阅、下载历史根据类型和时间查询列表(插件方法)
This commit is contained in:
parent
d3983c51c2
commit
14a3bb8fc2
@ -131,3 +131,11 @@ class DownloadHistoryOper(DbOper):
|
|||||||
type=type,
|
type=type,
|
||||||
tmdbid=tmdbid,
|
tmdbid=tmdbid,
|
||||||
seasons=seasons)
|
seasons=seasons)
|
||||||
|
|
||||||
|
def list_by_type(self, mtype: str, days: int = 7) -> List[DownloadHistory]:
|
||||||
|
"""
|
||||||
|
获取指定类型的下载历史
|
||||||
|
"""
|
||||||
|
return DownloadHistory.list_by_type(db=self._db,
|
||||||
|
mtype=mtype,
|
||||||
|
days=days)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, String, Sequence
|
from sqlalchemy import Column, Integer, String, Sequence
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@ -140,6 +142,16 @@ class DownloadHistory(Base):
|
|||||||
DownloadHistory.tmdbid == tmdbid).order_by(
|
DownloadHistory.tmdbid == tmdbid).order_by(
|
||||||
DownloadHistory.id.desc()).all()
|
DownloadHistory.id.desc()).all()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@db_query
|
||||||
|
def list_by_type(db: Session, mtype: str, days: int):
|
||||||
|
result = db.query(DownloadHistory) \
|
||||||
|
.filter(DownloadHistory.type == mtype,
|
||||||
|
DownloadHistory.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
||||||
|
time.localtime(time.time() - 86400 * int(days)))
|
||||||
|
).all()
|
||||||
|
return list(result)
|
||||||
|
|
||||||
|
|
||||||
class DownloadFiles(Base):
|
class DownloadFiles(Base):
|
||||||
"""
|
"""
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
from sqlalchemy import Column, Integer, String, Sequence
|
from sqlalchemy import Column, Integer, String, Sequence
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@ -126,3 +128,13 @@ class Subscribe(Base):
|
|||||||
if subscribe:
|
if subscribe:
|
||||||
subscribe.delete(db, subscribe.id)
|
subscribe.delete(db, subscribe.id)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@db_query
|
||||||
|
def list_by_type(db: Session, mtype: str, days: int):
|
||||||
|
result = db.query(Subscribe) \
|
||||||
|
.filter(Subscribe.type == mtype,
|
||||||
|
Subscribe.date >= time.strftime("%Y-%m-%d %H:%M:%S",
|
||||||
|
time.localtime(time.time() - 86400 * int(days)))
|
||||||
|
).all()
|
||||||
|
return list(result)
|
||||||
|
@ -83,3 +83,9 @@ class SubscribeOper(DbOper):
|
|||||||
subscribe = self.get(sid)
|
subscribe = self.get(sid)
|
||||||
subscribe.update(self._db, payload)
|
subscribe.update(self._db, payload)
|
||||||
return subscribe
|
return subscribe
|
||||||
|
|
||||||
|
def list_by_type(self, mtype: str, days: int = 7) -> Subscribe:
|
||||||
|
"""
|
||||||
|
获取指定类型的订阅
|
||||||
|
"""
|
||||||
|
return Subscribe.list_by_type(self._db, mtype=mtype, days=days)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user