feat 转移历史记录文件清单
This commit is contained in:
parent
bd163f9c4b
commit
61d44a6e7d
30
alembic/versions/ec5fb51fc300_1_0_2.py
Normal file
30
alembic/versions/ec5fb51fc300_1_0_2.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
"""1.0.2
|
||||||
|
|
||||||
|
Revision ID: ec5fb51fc300
|
||||||
|
Revises: 14f1813ae8e3
|
||||||
|
Create Date: 2023-08-12 17:55:06.509548
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'ec5fb51fc300'
|
||||||
|
down_revision = '14f1813ae8e3'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
try:
|
||||||
|
with op.batch_alter_table("transferhistory") as batch_op:
|
||||||
|
batch_op.add_column(sa.Column('files', sa.String, nullable=True))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
pass
|
@ -1,3 +1,4 @@
|
|||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -167,7 +168,8 @@ class TransferChain(ChainBase):
|
|||||||
image=mediainfo.get_poster_image(),
|
image=mediainfo.get_poster_image(),
|
||||||
download_hash=torrent.hash,
|
download_hash=torrent.hash,
|
||||||
status=0,
|
status=0,
|
||||||
errmsg=transferinfo.message if transferinfo else '未知错误'
|
errmsg=transferinfo.message if transferinfo else '未知错误',
|
||||||
|
files=json.dumps(transferinfo.file_list) if transferinfo else None
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
# 新增转移成功历史记录
|
# 新增转移成功历史记录
|
||||||
@ -187,7 +189,8 @@ class TransferChain(ChainBase):
|
|||||||
episodes=meta.episode,
|
episodes=meta.episode,
|
||||||
image=mediainfo.get_poster_image(),
|
image=mediainfo.get_poster_image(),
|
||||||
download_hash=torrent.hash,
|
download_hash=torrent.hash,
|
||||||
status=1
|
status=1,
|
||||||
|
files=json.dumps(transferinfo.file_list)
|
||||||
)
|
)
|
||||||
# 转移完成
|
# 转移完成
|
||||||
self.transfer_completed(hashs=torrent.hash, transinfo=transferinfo)
|
self.transfer_completed(hashs=torrent.hash, transinfo=transferinfo)
|
||||||
|
@ -45,3 +45,7 @@ class DownloadHistory(Base):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def list_by_page(db: Session, page: int = 1, count: int = 30):
|
def list_by_page(db: Session, page: int = 1, count: int = 30):
|
||||||
return db.query(DownloadHistory).offset((page - 1) * count).limit(count).all()
|
return db.query(DownloadHistory).offset((page - 1) * count).limit(count).all()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_by_path(db: Session, path: str):
|
||||||
|
return db.query(DownloadHistory).filter(DownloadHistory.path == path).first()
|
||||||
|
@ -43,6 +43,8 @@ class TransferHistory(Base):
|
|||||||
errmsg = Column(String)
|
errmsg = Column(String)
|
||||||
# 时间
|
# 时间
|
||||||
date = Column(String, index=True)
|
date = Column(String, index=True)
|
||||||
|
# 文件清单,以JSON存储
|
||||||
|
files = Column(String)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_by_title(db: Session, title: str, page: int = 1, count: int = 30):
|
def list_by_title(db: Session, title: str, page: int = 1, count: int = 30):
|
||||||
|
@ -15,7 +15,7 @@ class TransferHistoryOper(DbOper):
|
|||||||
按标题查询转移记录
|
按标题查询转移记录
|
||||||
:param title: 数据key
|
:param title: 数据key
|
||||||
"""
|
"""
|
||||||
return TransferHistory.search_by_title(self._db, title)
|
return TransferHistory.list_by_title(self._db, title)
|
||||||
|
|
||||||
def get_by_src(self, src: str) -> Any:
|
def get_by_src(self, src: str) -> Any:
|
||||||
"""
|
"""
|
||||||
|
@ -469,9 +469,9 @@ class FileTransferModule(_ModuleBase):
|
|||||||
fail_list.append(transfer_file)
|
fail_list.append(transfer_file)
|
||||||
continue
|
continue
|
||||||
# 计算文件数
|
# 计算文件数
|
||||||
file_list.append(str(new_file))
|
file_list.append(str(transfer_file))
|
||||||
# 计算大小
|
# 计算大小
|
||||||
total_filesize += new_file.stat().st_size
|
total_filesize += transfer_file.stat().st_size
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
err_msgs.append(f"{transfer_file.name}:{err}")
|
err_msgs.append(f"{transfer_file.name}:{err}")
|
||||||
logger.error(f"{transfer_file}转移失败:{err}")
|
logger.error(f"{transfer_file}转移失败:{err}")
|
||||||
|
@ -45,6 +45,7 @@ class MediaSyncDel(_PluginBase):
|
|||||||
auth_level = 1
|
auth_level = 1
|
||||||
|
|
||||||
# 私有属性
|
# 私有属性
|
||||||
|
episode = None
|
||||||
_scheduler: Optional[BackgroundScheduler] = None
|
_scheduler: Optional[BackgroundScheduler] = None
|
||||||
_enabled = False
|
_enabled = False
|
||||||
_sync_type: str = ""
|
_sync_type: str = ""
|
||||||
|
@ -111,7 +111,7 @@ class TorrentRemover(_PluginBase):
|
|||||||
self._onlyonce = False
|
self._onlyonce = False
|
||||||
# 保存设置
|
# 保存设置
|
||||||
self.update_config({
|
self.update_config({
|
||||||
"enable": self._enabled,
|
"enabled": self._enabled,
|
||||||
"notify": self._notify,
|
"notify": self._notify,
|
||||||
"onlyonce": self._onlyonce,
|
"onlyonce": self._onlyonce,
|
||||||
"action": self._action,
|
"action": self._action,
|
||||||
@ -132,7 +132,7 @@ class TorrentRemover(_PluginBase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
def get_state(self) -> bool:
|
def get_state(self) -> bool:
|
||||||
return self._enabled and True if self._cron and self._downloaders else False
|
return self._enabled and self._cron and self._downloaders
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_command() -> List[Dict[str, Any]]:
|
def get_command() -> List[Dict[str, Any]]:
|
||||||
|
@ -4,7 +4,6 @@ from typing import Optional
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TransferTorrent(BaseModel):
|
class TransferTorrent(BaseModel):
|
||||||
"""
|
"""
|
||||||
待转移任务信息
|
待转移任务信息
|
||||||
@ -60,4 +59,4 @@ class TransferInfo(BaseModel):
|
|||||||
dicts = vars(self).copy() # 创建一个字典的副本以避免修改原始数据
|
dicts = vars(self).copy() # 创建一个字典的副本以避免修改原始数据
|
||||||
dicts["path"] = str(self.path) if self.path else None
|
dicts["path"] = str(self.path) if self.path else None
|
||||||
dicts["target_path"] = str(self.target_path) if self.target_path else None
|
dicts["target_path"] = str(self.target_path) if self.target_path else None
|
||||||
return dicts
|
return dicts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user