Skip to content

Commit

Permalink
prestige.py: 调整重试机制中的异常处理逻辑以避免'UnboundLocalError'问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuukiy committed Dec 3, 2021
1 parent a92a6a6 commit 8ba83ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions web/prestige.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def parse_data(movie: MovieInfo):
for _ in range(cfg.Network.retry):
try:
resp = request_get(url, cookies=cookies, delay_raise=True)
resp.raise_for_status()
html = resp2html(resp)
break
except Exception as e:
# 500错误表明prestige没有这部影片的数据,不是网络问题,因此不再重试
if resp.status_code == 500:
logger.debug('Prestige无影片: ' + repr(movie))
break
else:
resp.raise_for_status()
html = resp2html(resp)
break
except Exception as e:
logger.debug(e)
if html is not None:
try:
Expand Down Expand Up @@ -99,6 +99,8 @@ def parse_data_raw(movie: MovieInfo, html):


if __name__ == "__main__":
import pretty_errors
pretty_errors.configure(display_link=True)
logger.setLevel(logging.DEBUG)
movie = MovieInfo('ABP-647')
if parse_data(movie):
Expand Down

0 comments on commit 8ba83ed

Please sign in to comment.