This repository has been archived on 2023-10-01. You can view files and clone it, but cannot push or open issues or pull requests.
PyNyaaTa/pynyaata/connectors/__init__.py

34 lines
918 B
Python
Raw Normal View History

2021-01-03 19:41:58 +00:00
from asyncio import gather
2020-04-24 19:01:44 +00:00
from .animeultime import AnimeUltime
from .core import Other
from .nyaa import Nyaa
from .pantsu import Pantsu
from .yggtorrent import YggTorrent, YggAnimation
2021-01-07 20:19:50 +00:00
from ..config import CLOUDPROXY_ENDPOINT
2020-04-24 19:01:44 +00:00
2021-01-03 19:41:58 +00:00
async def run_all(*args, **kwargs):
2021-01-07 20:19:50 +00:00
coroutines = [Nyaa(*args, **kwargs).run(),
Pantsu(*args, **kwargs).run(),
AnimeUltime(*args, **kwargs).run()]
if CLOUDPROXY_ENDPOINT:
coroutines.extend([YggTorrent(*args, **kwargs).run(),
YggAnimation(*args, **kwargs).run()])
return list(await gather(*coroutines))
2020-04-24 19:01:44 +00:00
def get_instance(url, query):
if 'nyaa.si' in url:
return Nyaa(query)
elif 'nyaa.net' in url:
return Pantsu(query)
elif 'anime-ultime' in url:
return AnimeUltime(query)
elif 'ygg' in url:
return YggTorrent(query)
else:
return Other(query)