fix json exception
This commit is contained in:
parent
fa47d9adeb
commit
07a6abde0e
@ -42,7 +42,10 @@ def read_subscribes(
|
||||
subscribes = Subscribe.list(db)
|
||||
for subscribe in subscribes:
|
||||
if subscribe.sites:
|
||||
try:
|
||||
subscribe.sites = json.loads(str(subscribe.sites))
|
||||
except json.JSONDecodeError:
|
||||
subscribe.sites = []
|
||||
else:
|
||||
subscribe.sites = []
|
||||
return subscribes
|
||||
@ -168,7 +171,10 @@ def subscribe_mediaid(
|
||||
meta.begin_season = season
|
||||
result = Subscribe.get_by_title(db, title=meta.name, season=meta.begin_season)
|
||||
if result and result.sites:
|
||||
try:
|
||||
result.sites = json.loads(result.sites)
|
||||
except json.JSONDecodeError:
|
||||
result.sites = []
|
||||
|
||||
return result if result else Subscribe()
|
||||
|
||||
@ -322,7 +328,10 @@ def read_subscribe(
|
||||
historys = SubscribeHistory.list_by_type(db, mtype=mtype, page=page, count=count)
|
||||
for history in historys:
|
||||
if history and history.sites:
|
||||
try:
|
||||
history.sites = json.loads(history.sites)
|
||||
except json.JSONDecodeError:
|
||||
history.sites = []
|
||||
return historys
|
||||
|
||||
|
||||
@ -396,7 +405,10 @@ def read_subscribe(
|
||||
return Subscribe()
|
||||
subscribe = Subscribe.get(db, subscribe_id)
|
||||
if subscribe and subscribe.sites:
|
||||
try:
|
||||
subscribe.sites = json.loads(subscribe.sites)
|
||||
except json.JSONDecodeError:
|
||||
subscribe.sites = []
|
||||
return subscribe
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ import json
|
||||
import random
|
||||
import time
|
||||
from datetime import datetime
|
||||
from json import JSONDecodeError
|
||||
from typing import Dict, List, Optional, Union, Tuple
|
||||
|
||||
from app.chain import ChainBase
|
||||
@ -459,7 +460,10 @@ class SubscribeChain(ChainBase):
|
||||
获取订阅中涉及的站点清单
|
||||
"""
|
||||
if subscribe.sites:
|
||||
try:
|
||||
return json.loads(subscribe.sites)
|
||||
except JSONDecodeError:
|
||||
return []
|
||||
# 默认站点
|
||||
return self.systemconfig.get(SystemConfigKey.RssSites) or []
|
||||
|
||||
@ -780,7 +784,10 @@ class SubscribeChain(ChainBase):
|
||||
return
|
||||
note = []
|
||||
if subscribe.note:
|
||||
try:
|
||||
note = json.loads(subscribe.note)
|
||||
except JSONDecodeError:
|
||||
note = []
|
||||
for context in downloads:
|
||||
meta = context.meta_info
|
||||
mediainfo = context.media_info
|
||||
@ -811,7 +818,10 @@ class SubscribeChain(ChainBase):
|
||||
return False
|
||||
if not episodes:
|
||||
return False
|
||||
try:
|
||||
note = json.loads(subscribe.note)
|
||||
except JSONDecodeError:
|
||||
return False
|
||||
if set(episodes).issubset(set(note)):
|
||||
return True
|
||||
return False
|
||||
@ -1023,7 +1033,10 @@ class SubscribeChain(ChainBase):
|
||||
for subscribe in self.subscribeoper.list():
|
||||
if not subscribe.sites:
|
||||
continue
|
||||
sites = json.loads(subscribe.sites) or []
|
||||
try:
|
||||
sites = json.loads(subscribe.sites)
|
||||
except JSONDecodeError:
|
||||
sites = []
|
||||
if site_id not in sites:
|
||||
continue
|
||||
sites.remove(site_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user