fix 同步删除

This commit is contained in:
thsrite 2023-08-19 13:37:19 +08:00
parent 4d8e2a5d03
commit 398397d7e4
2 changed files with 237 additions and 202 deletions

View File

@ -50,7 +50,7 @@ class TransferHistoryOper(DbOper):
"""
return TransferHistory.statistic(self._db, days)
def get_by(self, mtype: str = None, title: str = None, year: int = None,
def get_by(self, mtype: str = None, title: str = None, year: str = None,
season: str = None, episode: str = None, tmdbid: str = None) -> Any:
"""
按类型标题年份季集查询转移记录

View File

@ -286,35 +286,8 @@ class MediaSyncDel(_PluginBase):
image = history.get("image")
del_time = history.get("del_time")
contents.append(
{
'component': 'VCard',
'content': [
{
'component': 'div',
'props': {
'class': 'd-flex justify-space-start flex-nowrap flex-row',
},
'content': [
{
'component': 'div',
'content': [
{
'component': 'VImg',
'props': {
'src': image,
'height': 120,
'width': 80,
'aspect-ratio': '2/3',
'class': 'object-cover shadow ring-gray-500',
'cover': True
}
}
]
},
{
'component': 'div',
'content': [
if season:
sub_contents = [
{
'component': 'VCardText',
'props': {
@ -323,19 +296,11 @@ class MediaSyncDel(_PluginBase):
'text': f'类型:{htype}'
},
{
'component': 'VCardSubtitle',
'props': {
'class': 'pa-2 font-bold break-words whitespace-break-spaces'
},
'content': [
{
'component': 'a',
'component': 'VCardText',
'props': {
'class': 'pa-0 px-2'
},
'text': title
}
]
'text': f'标题:{title}'
},
{
'component': 'VCardText',
@ -366,6 +331,67 @@ class MediaSyncDel(_PluginBase):
'text': f'时间:{del_time}'
}
]
else:
sub_contents = [
{
'component': 'VCardText',
'props': {
'class': 'pa-0 px-2'
},
'text': f'类型:{htype}'
},
{
'component': 'VCardText',
'props': {
'class': 'pa-0 px-2'
},
'text': f'标题:{title}'
},
{
'component': 'VCardText',
'props': {
'class': 'pa-0 px-2'
},
'text': f'年份:{year}'
},
{
'component': 'VCardText',
'props': {
'class': 'pa-0 px-2'
},
'text': f'时间:{del_time}'
}
]
contents.append(
{
'component': 'VCard',
'content': [
{
'component': 'div',
'props': {
'class': 'd-flex justify-space-start flex-nowrap flex-row',
},
'content': [
{
'component': 'div',
'content': [
{
'component': 'VImg',
'props': {
'src': image,
'height': 120,
'width': 80,
'aspect-ratio': '2/3',
'class': 'object-cover shadow ring-gray-500',
'cover': True
}
}
]
},
{
'component': 'div',
'content': sub_contents
}
]
}
@ -510,9 +536,11 @@ class MediaSyncDel(_PluginBase):
if self._notify:
if media_type == "Episode":
# 根据tmdbid获取图片
image = self.episode.images(tv_id=tmdb_id,
images = self.episode.images(tv_id=tmdb_id,
season_num=season_num,
episode_num=episode_num)
if images:
image = self.get_tmdbimage_url(images[-1].get("file_path"), prefix="original")
# 发送通知
self.post_message(
mtype=NotificationType.MediaServer,
@ -530,7 +558,7 @@ class MediaSyncDel(_PluginBase):
"season": season_num,
"episode": episode_num,
"image": image,
"del_time": str(datetime.datetime.now())
"del_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
})
# 保存历史
@ -671,7 +699,7 @@ class MediaSyncDel(_PluginBase):
"season": media_season,
"episode": media_episode,
"image": image,
"del_time": del_time
"del_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
})
# 保存历史
@ -1034,3 +1062,10 @@ class MediaSyncDel(_PluginBase):
if event:
self.post_message(channel=event.event_data.get("channel"),
title="媒体库同步删除完成!", userid=event.event_data.get("user"))
@staticmethod
def get_tmdbimage_url(path, prefix="w500"):
if not path:
return ""
tmdb_image_url = f"https://{settings.TMDB_IMAGE_DOMAIN}"
return tmdb_image_url + f"/t/p/{prefix}{path}"