From e36d50c5dd35973c090f87df05d4e94963e8036c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 21 Jun 2021 22:53:17 +0530 Subject: [websockets] Add `WebSocketFragmentFD` (#399) Necessary for #392 Co-authored by: nao20010128nao, pukkandan --- yt_dlp/compat.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'yt_dlp/compat.py') diff --git a/yt_dlp/compat.py b/yt_dlp/compat.py index 863bd2287..cffaa74a6 100644 --- a/yt_dlp/compat.py +++ b/yt_dlp/compat.py @@ -3030,6 +3030,21 @@ except AttributeError: compat_Match = type(re.compile('').match('')) +import asyncio +try: + compat_asyncio_run = asyncio.run +except AttributeError: + def compat_asyncio_run(coro): + try: + loop = asyncio.get_event_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + loop.run_until_complete(coro) + + asyncio.run = compat_asyncio_run + + __all__ = [ 'compat_HTMLParseError', 'compat_HTMLParser', @@ -3037,6 +3052,7 @@ __all__ = [ 'compat_Match', 'compat_Pattern', 'compat_Struct', + 'compat_asyncio_run', 'compat_b64decode', 'compat_basestring', 'compat_chr', -- cgit v1.2.3