Fix handling when specified video length is too long
This commit is contained in:
@@ -65,10 +65,12 @@ class Downloader:
|
|||||||
async def _create_block(session, pos, seektime):
|
async def _create_block(session, pos, seektime):
|
||||||
continuation = arcparam.getparam(
|
continuation = arcparam.getparam(
|
||||||
self.video_id, seektime = seektime)
|
self.video_id, seektime = seektime)
|
||||||
|
|
||||||
url = f"{REPLAY_URL}{quote(continuation)}&pbj=1"
|
url = f"{REPLAY_URL}{quote(continuation)}&pbj=1"
|
||||||
async with session.get(url, headers = headers) as resp:
|
async with session.get(url, headers = headers) as resp:
|
||||||
text = await resp.text()
|
text = await resp.text()
|
||||||
next_continuation, actions = parser.parse(json.loads(text))
|
next_continuation, actions = parser.parse(json.loads(text))
|
||||||
|
if actions:
|
||||||
first = parser.get_offset(actions[0])
|
first = parser.get_offset(actions[0])
|
||||||
last = parser.get_offset(actions[-1])
|
last = parser.get_offset(actions[-1])
|
||||||
if self.callback:
|
if self.callback:
|
||||||
@@ -80,9 +82,11 @@ class Downloader:
|
|||||||
first = first,
|
first = first,
|
||||||
last = last
|
last = last
|
||||||
)
|
)
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
self.blocks = loop.run_until_complete(
|
result = loop.run_until_complete(
|
||||||
_get_blocks(self.duration, self.div))
|
_get_blocks(self.duration, self.div))
|
||||||
|
self.blocks = [block for block in result if block]
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def remove_duplicate_head(self):
|
def remove_duplicate_head(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user