fix douban plugin
This commit is contained in:
parent
0f6674ec16
commit
9793c6e0a2
@ -21,6 +21,13 @@ class PluginDataOper(DbOper):
|
|||||||
"""
|
"""
|
||||||
if ObjectUtils.is_obj(value):
|
if ObjectUtils.is_obj(value):
|
||||||
value = json.dumps(value)
|
value = json.dumps(value)
|
||||||
|
plugin = PluginData.get_plugin_data_by_key(self._db, plugin_id, key)
|
||||||
|
if plugin:
|
||||||
|
plugin.update(self._db, {
|
||||||
|
"value": value
|
||||||
|
})
|
||||||
|
return plugin
|
||||||
|
else:
|
||||||
plugin = PluginData(plugin_id=plugin_id, key=key, value=value)
|
plugin = PluginData(plugin_id=plugin_id, key=key, value=value)
|
||||||
return plugin.create(self._db)
|
return plugin.create(self._db)
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ class TNodeSpider:
|
|||||||
results = res.json().get('data', {}).get("torrents") or []
|
results = res.json().get('data', {}).get("torrents") or []
|
||||||
for result in results:
|
for result in results:
|
||||||
torrent = {
|
torrent = {
|
||||||
'indexer': self._indexerid,
|
'id': self._indexerid,
|
||||||
'title': result.get('title'),
|
'title': result.get('title'),
|
||||||
'description': result.get('subtitle'),
|
'description': result.get('subtitle'),
|
||||||
'enclosure': self._downloadurl % (self._domain, result.get('id')),
|
'enclosure': self._downloadurl % (self._domain, result.get('id')),
|
||||||
|
@ -239,8 +239,8 @@ class DoubanSync(_PluginBase):
|
|||||||
拼装插件详情页面,需要返回页面配置,同时附带数据
|
拼装插件详情页面,需要返回页面配置,同时附带数据
|
||||||
"""
|
"""
|
||||||
# 查询同步详情
|
# 查询同步详情
|
||||||
history = self.get_data('history')
|
historys = self.get_data('history')
|
||||||
if not history:
|
if not historys:
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'component': 'div',
|
'component': 'div',
|
||||||
@ -250,8 +250,80 @@ class DoubanSync(_PluginBase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
return [
|
# 拼装页面
|
||||||
|
contents = []
|
||||||
|
for history in historys:
|
||||||
|
title = history.get("title")
|
||||||
|
poster = history.get("poster")
|
||||||
|
mtype = history.get("type")
|
||||||
|
time_str = history.get("time")
|
||||||
|
overview = history.get("overview")
|
||||||
|
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': poster,
|
||||||
|
'height': 120,
|
||||||
|
'width': 80,
|
||||||
|
'aspect-ratio': '2/3',
|
||||||
|
'class': 'object-cover rounded shadow ring-gray-500',
|
||||||
|
'cover': True
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'component': 'div',
|
||||||
|
'content': [
|
||||||
|
{
|
||||||
|
'component': 'VCardSubtitle',
|
||||||
|
'props': {
|
||||||
|
'class': 'pa-2 font-bold break-words whitespace-break-spaces'
|
||||||
|
},
|
||||||
|
'text': title
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'component': 'VCardText',
|
||||||
|
'props': {
|
||||||
|
'class': 'pa-0 px-2'
|
||||||
|
},
|
||||||
|
'text': f'类型:{mtype}'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'component': 'VCardText',
|
||||||
|
'props': {
|
||||||
|
'class': 'pa-0 px-2'
|
||||||
|
},
|
||||||
|
'text': f'时间:{time_str}'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'component': 'div',
|
||||||
|
'props': {
|
||||||
|
'class': 'grid gap-3 grid-info-card',
|
||||||
|
},
|
||||||
|
'content': contents
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
def stop_service(self):
|
def stop_service(self):
|
||||||
@ -289,6 +361,7 @@ class DoubanSync(_PluginBase):
|
|||||||
return
|
return
|
||||||
# 解析数据
|
# 解析数据
|
||||||
for result in results:
|
for result in results:
|
||||||
|
try:
|
||||||
dtype = result.get("title", "")[:2]
|
dtype = result.get("title", "")[:2]
|
||||||
title = result.get("title", "")[2:]
|
title = result.get("title", "")[2:]
|
||||||
if dtype not in ["想看"]:
|
if dtype not in ["想看"]:
|
||||||
@ -298,7 +371,7 @@ class DoubanSync(_PluginBase):
|
|||||||
# 判断是否在天数范围
|
# 判断是否在天数范围
|
||||||
pubdate: Optional[datetime.datetime] = result.get("pubdate")
|
pubdate: Optional[datetime.datetime] = result.get("pubdate")
|
||||||
if pubdate:
|
if pubdate:
|
||||||
if (datetime.datetime.now() - pubdate).days > self._days:
|
if (datetime.datetime.now(datetime.timezone.utc) - pubdate).days > float(self._days):
|
||||||
logger.info(f'已超过同步天数,标题:{title},发布时间:{pubdate}')
|
logger.info(f'已超过同步天数,标题:{title},发布时间:{pubdate}')
|
||||||
continue
|
continue
|
||||||
douban_id = result.get("link", "").split("/")[-2]
|
douban_id = result.get("link", "").split("/")[-2]
|
||||||
@ -340,22 +413,14 @@ class DoubanSync(_PluginBase):
|
|||||||
season=meta.begin_season,
|
season=meta.begin_season,
|
||||||
exist_ok=True,
|
exist_ok=True,
|
||||||
username="豆瓣想看")
|
username="豆瓣想看")
|
||||||
history.append({
|
action = "subscribe"
|
||||||
"action": 'subscribe',
|
else:
|
||||||
"media": mediainfo.to_dict(),
|
|
||||||
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
# 自动下载
|
# 自动下载
|
||||||
downloads, lefts = self.downloadchain.batch_download(contexts=contexts, no_exists=no_exists)
|
downloads, lefts = self.downloadchain.batch_download(contexts=contexts, no_exists=no_exists)
|
||||||
if downloads and not lefts:
|
if downloads and not lefts:
|
||||||
# 全部下载完成
|
# 全部下载完成
|
||||||
logger.info(f'{mediainfo.title_year} 下载完成')
|
logger.info(f'{mediainfo.title_year} 下载完成')
|
||||||
history.append({
|
action = "download"
|
||||||
"action": 'download',
|
|
||||||
"media": mediainfo.to_dict(),
|
|
||||||
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
||||||
})
|
|
||||||
else:
|
else:
|
||||||
# 未完成下载
|
# 未完成下载
|
||||||
logger.info(f'{mediainfo.title_year} 未下载未完整,添加订阅 ...')
|
logger.info(f'{mediainfo.title_year} 未下载未完整,添加订阅 ...')
|
||||||
@ -367,11 +432,21 @@ class DoubanSync(_PluginBase):
|
|||||||
season=meta.begin_season,
|
season=meta.begin_season,
|
||||||
exist_ok=True,
|
exist_ok=True,
|
||||||
username="豆瓣想看")
|
username="豆瓣想看")
|
||||||
|
action = "subscribe"
|
||||||
|
# 存储历史记录
|
||||||
history.append({
|
history.append({
|
||||||
"action": 'subscribe',
|
"action": action,
|
||||||
"media": mediainfo.to_dict(),
|
"title": doubaninfo.get("title") or mediainfo.title,
|
||||||
|
"type": mediainfo.type.value,
|
||||||
|
"year": mediainfo.year,
|
||||||
|
"poster": mediainfo.poster_path,
|
||||||
|
"overview": mediainfo.overview,
|
||||||
|
"tmdbid": mediainfo.tmdb_id,
|
||||||
|
"doubanid": douban_id,
|
||||||
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
"time": datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
})
|
})
|
||||||
|
except Exception as err:
|
||||||
|
logger.error(f'同步用户 {user_id} 豆瓣想看数据出错:{err}')
|
||||||
logger.info(f"用户 {user_id} 豆瓣想看同步完成")
|
logger.info(f"用户 {user_id} 豆瓣想看同步完成")
|
||||||
# 保存历史记录
|
# 保存历史记录
|
||||||
self.save_data('history', history)
|
self.save_data('history', history)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user