Skip to content

Commit

Permalink
优化直播404分段重试逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
xhlove committed Jan 9, 2022
1 parent 34939cd commit e4101c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions XstreamDL_CLI/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ def cancel_all_task() -> None:
ts = time.time()
client = ClientSession(connector=get_connector(self.args)) # type: ClientSession
for segment in _left:
if segment.max_retry_404 <= 0:
self.xprogress.decrease_total_count()
continue
task = loop.create_task(self.download(client, stream, segment))
task.add_done_callback(_done_callback)
tasks.add(task)
Expand All @@ -426,6 +429,8 @@ async def download(self, client: ClientSession, stream: Stream, segment: Segment
flag = False
self.xprogress.decrease_total_count()
segment.skip_concat = True
if resp.status == 404:
segment.max_retry_404 -= 1
if resp.status == 405:
status = 'STATUS_CODE_ERROR'
flag = False
Expand Down
2 changes: 2 additions & 0 deletions XstreamDL_CLI/models/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def __init__(self):
# <---分段类型--->
self.segment_type = 'normal'
self.skip_concat = False
# 直播流 单个分段 最大404次数
self.max_retry_404 = 5

def is_ism(self) -> bool:
''' 请重写 '''
Expand Down

0 comments on commit e4101c9

Please sign in to comment.