cache complete result

This commit is contained in:
Roy Olav Purser 2021-05-30 19:29:35 +02:00
parent cd3bd950ae
commit a605e7c43d
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -193,6 +193,10 @@ async def get_meta(upstream, proxy, logger):
return await get_from_runner((2, upstream), MetaRunner(upstream, proxy, logger), logger)
async def get_any(upstream, proxy, logger):
cache_key = (3, upstream)
cached = upstream_cache.get(cache_key)
if isinstance(cached, StreamData):
return cached
tasks = []
tasks.append(asyncio.create_task(get_streamlink(upstream, proxy, logger)))
tasks.append(asyncio.create_task(get_ytdl(upstream, proxy, logger)))
@ -206,6 +210,7 @@ async def get_any(upstream, proxy, logger):
result.update("title", temp_result.title(), temp_result.override)
result.update("description", temp_result.description(), temp_result.override)
if result.complete():
upstream_cache[cache_key] = result
break
for task in tasks:
if not task.done():