Skip to content

Commit

Permalink
add WindowsSelectorEventLoopPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
xhlove committed Mar 6, 2022
1 parent faeb6fc commit 4cf200f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions XstreamDL_CLI/extractor.py
@@ -1,4 +1,5 @@
import asyncio
import platform
from typing import List
from pathlib import Path
from aiohttp.connector import TCPConnector
Expand Down Expand Up @@ -46,6 +47,8 @@ def fetch_metadata(self, uri: str, parent_stream: Stream = None):
从链接/文件/文件夹等加载内容 解析metadata
'''
if uri.startswith('http://') or uri.startswith('https://') or uri.startswith('ftp://'):
if platform.system() == 'Windows':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
loop = asyncio.get_event_loop()
return self.raw2streams('url', *loop.run_until_complete(self.fetch(uri)), parent_stream)
if '\\' in uri:
Expand Down
4 changes: 3 additions & 1 deletion XstreamDL_CLI/extractors/hls/ext/xkey.py
@@ -1,5 +1,5 @@

import asyncio
import platform
from aiohttp_socks import ProxyConnector
from aiohttp import ClientSession, ClientResponse
from aiohttp.connector import TCPConnector
Expand Down Expand Up @@ -105,6 +105,8 @@ def load(self, args: CmdArgs, custom_xkey: 'XKey'):
return True
if self.uri.startswith('http://') or self.uri.startswith('https://'):
logger.info(f'key uri => {self.uri}')
if platform.system() == 'Windows':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
loop = asyncio.get_event_loop()
self.key = loop.run_until_complete(self.fetch(self.uri, args))
elif self.uri.startswith('ftp://'):
Expand Down

0 comments on commit 4cf200f

Please sign in to comment.