-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.py
44 lines (29 loc) · 1.16 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import asyncio
from jutsu import JutSu, get_link_and_download
async def main():
url = input("Enter the link or name: ")
if url.startswith("http"):
slug = url.split("/")[3]
season = url.split("/")[4] if len(url.split("/")) > 4 else None
print('Anime name:', slug)
print('Season:', season)
else:
return print("Enter the correct link!")
res = input("Enter the resolution (1080, 720, 480, 360): ")
download_type = input("Download synchronously? (1)\nDownload asynchronously (2)\nYour Choice: ")
if res not in ("1080", "720", "480", "360"):
return print("Enter the correct resolution!")
jutsu = JutSu(slug)
episodes = await jutsu.get_all_episodes(season=season)
print(f"Fetched {len(episodes)} episodes")
if download_type == "1":
for episode in episodes:
await get_link_and_download(jutsu, episode, res)
elif download_type == "2":
tasks = [get_link_and_download(jutsu, episode, res, False) for episode in episodes]
await asyncio.gather(*tasks)
else:
print(":/")
await jutsu.close()
if __name__ == "__main__":
asyncio.run(main())