mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-06-03 23:16:47 +00:00
fix 历史删除
This commit is contained in:
@@ -3,6 +3,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
import pytz
|
||||
|
||||
from app import schemas
|
||||
from app.chain.douban import DoubanChain
|
||||
from app.chain.tmdb import TmdbChain
|
||||
from app.chain.download import DownloadChain
|
||||
@@ -262,11 +263,13 @@ class ActorSubscribe(_PluginBase):
|
||||
"overview": mediainfo.overview,
|
||||
"tmdbid": mediainfo.tmdb_id,
|
||||
"doubanid": mediainfo.douban_id,
|
||||
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"unique": f"actorsubscribe: {mediainfo.title} (DB:{mediainfo.tmdb_id})"
|
||||
})
|
||||
|
||||
if not is_subscribe:
|
||||
logger.info(f"{mediainfo.type.value} {mediainfo.title_year} {mediainfo.tmdb_id or mediainfo.douban_id} 未命中订阅演员,跳过")
|
||||
logger.info(
|
||||
f"{mediainfo.type.value} {mediainfo.title_year} {mediainfo.tmdb_id or mediainfo.douban_id} 未命中订阅演员,跳过")
|
||||
|
||||
# 保存历史记录
|
||||
self.save_data('history', history)
|
||||
@@ -451,6 +454,21 @@ class ActorSubscribe(_PluginBase):
|
||||
"source": self._source,
|
||||
})
|
||||
|
||||
def delete_history(self, key: str, apikey: str):
|
||||
"""
|
||||
删除同步历史记录
|
||||
"""
|
||||
if apikey != settings.API_TOKEN:
|
||||
return schemas.Response(success=False, message="API密钥错误")
|
||||
# 历史记录
|
||||
historys = self.get_data('history')
|
||||
if not historys:
|
||||
return schemas.Response(success=False, message="未找到历史记录")
|
||||
# 删除指定记录
|
||||
historys = [h for h in historys if h.get("unique") != key]
|
||||
self.save_data('history', historys)
|
||||
return schemas.Response(success=True, message="删除成功")
|
||||
|
||||
def get_state(self) -> bool:
|
||||
return self._enabled
|
||||
|
||||
@@ -716,11 +734,28 @@ class ActorSubscribe(_PluginBase):
|
||||
poster = history.get("poster")
|
||||
mtype = history.get("type")
|
||||
time_str = history.get("time")
|
||||
tmdbid = history.get("tmdbid")
|
||||
doubanid = history.get("doubanid")
|
||||
contents.append(
|
||||
{
|
||||
'component': 'VCard',
|
||||
'content': [
|
||||
{
|
||||
"component": "VDialogCloseBtn",
|
||||
"props": {
|
||||
'innerClass': 'absolute top-0 right-0',
|
||||
},
|
||||
'events': {
|
||||
'click': {
|
||||
'api': 'plugin/ActorSubscribe/delete_history',
|
||||
'method': 'get',
|
||||
'params': {
|
||||
'key': f"actorsubscribe: {title} (DB:{tmdbid})",
|
||||
'apikey': settings.API_TOKEN
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
'component': 'div',
|
||||
'props': {
|
||||
|
||||
@@ -112,6 +112,12 @@ class PopularSubscribe(_PluginBase):
|
||||
logger.info(f"热门订阅检查:{sub.get('name')} 流行度:{sub.get('count')}")
|
||||
if popular_cnt and sub.get("count") and int(popular_cnt) > int(sub.get("count")):
|
||||
continue
|
||||
|
||||
unique_flag = f"popularsubscribe: {sub.get('name')} (DB:{sub.get('tmdbid')})"
|
||||
# 检查是否已处理过
|
||||
if unique_flag in [h.get("unique") for h in history]:
|
||||
continue
|
||||
|
||||
media = MediaInfo()
|
||||
media.type = MediaType(sub.get("type"))
|
||||
media.title = sub.get("name")
|
||||
@@ -157,7 +163,8 @@ class PopularSubscribe(_PluginBase):
|
||||
"overview": media.overview,
|
||||
"tmdbid": media.tmdb_id,
|
||||
"doubanid": media.douban_id,
|
||||
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
"time": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"unique": unique_flag
|
||||
})
|
||||
|
||||
# 保存历史记录
|
||||
@@ -399,6 +406,7 @@ class PopularSubscribe(_PluginBase):
|
||||
poster = history.get("poster")
|
||||
mtype = history.get("type")
|
||||
time_str = history.get("time")
|
||||
tmdbid = history.get("tmdbid")
|
||||
doubanid = history.get("doubanid")
|
||||
contents.append(
|
||||
{
|
||||
@@ -411,10 +419,10 @@ class PopularSubscribe(_PluginBase):
|
||||
},
|
||||
'events': {
|
||||
'click': {
|
||||
'api': 'plugin/subscribechain/delete_history',
|
||||
'api': 'plugin/PopularSubscribe/delete_history',
|
||||
'method': 'get',
|
||||
'params': {
|
||||
'key': f"doubanrank: {title} (DB:{doubanid})",
|
||||
'key': f"popularsubscribe: {title} (DB:{tmdbid})",
|
||||
'apikey': settings.API_TOKEN
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user