-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
116 lines (93 loc) · 4.32 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import requests
import os
from bs4 import BeautifulSoup
from termcolor import colored
os.system("clear")
banner = colored("""
▄▄▄ ███▄ █ ██▓ ███▄ ▄███▓▓█████ ▄████ ▒█████ ▓█████▄
▒████▄ ██ ▀█ █ ▓██▒▓██▒▀█▀ ██▒▓█ ▀ ██▒ ▀█▒▒██▒ ██▒▒██▀ ██▌
▒██ ▀█▄ ▓██ ▀█ ██▒▒██▒▓██ ▓██░▒███ ▒██░▄▄▄░▒██░ ██▒░██ █▌
░██▄▄▄▄██ ▓██▒ ▐▌██▒░██░▒██ ▒██ ▒▓█ ▄ ░▓█ ██▓▒██ ██░░▓█▄ ▌
▓█ ▓██▒▒██░ ▓██░░██░▒██▒ ░██▒░▒████▒ ░▒▓███▀▒░ ████▓▒░░▒████▓
▒▒ ▓▒█░░ ▒░ ▒ ▒ ░▓ ░ ▒░ ░ ░░░ ▒░ ░ ░▒ ▒ ░ ▒░▒░▒░ ▒▒▓ ▒
▒ ▒▒ ░░ ░░ ░ ▒░ ▒ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ▒░ ░ ▒ ▒
░ ▒ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░
""", 'cyan')
print(banner)
#scrapping the anime names after searching
url = "https://gogoanime.vc//search.html?keyword="
name = input(colored("Enter the name of the anime: ", 'yellow'))
url = url+name
r = requests.get(url)
soup = BeautifulSoup(r.content, 'html5lib')
names = soup.find("div", class_="last_episodes").find("ul", class_="items").find_all("li")
#quiting if no anime for the given name found
if(not len(names)):
exit
#getting the specific season or type
os.system('clear')
print(banner)
print(colored(f"Search topic: {name}\n", 'green', attrs=['bold']))
print(colored("Choose the correct series and season:\n", 'yellow'))
d = {}
n = {}
index = 1
for name in names:
ele = name.find("p", class_="name").find("a")
d[index] = ele["href"]
n[index] = ele['title']
print(colored(f"{index}) {ele['title']}", 'green'))
index += 1
num = input(colored(f"\nEnter your choice(1-{index-1}): ", 'yellow'))
#scrapping the specific anime for episode selection
os.system("clear")
print(banner)
print(colored(f"Chosen anime: {n[int(num)]}", 'green', attrs=['bold']))
url = "https://gogoanime.vc"+d[int(num)]
r = requests.get(url)
soup = BeautifulSoup(r.content, "html5lib")
episodes = soup.find("div", class_="anime_video_body").find("ul").find("li").find("a")
ep_start = int(episodes['ep_start'])
ep_end = int(episodes['ep_end'])
ep_num = input(colored(f"\nChoose an episode({ep_start+1}-{ep_end}): ", 'yellow'))
series_name = url.split('/')[-1]
while True:
os.system('clear')
print(banner)
print(colored(f"\nCurrent Episode Number: {ep_num}", 'green'))
print(colored(f"Total Episodes: {ep_end}", 'green'))
url = f"https://gogoanime.vc/{series_name}-episode-{ep_num}"
#downloading / streaming the anime episode
r = requests.get(url)
soup = BeautifulSoup(r.content, "html5lib")
download_page_link = soup.find("div", class_="download-anime").find("ul").find_all("li")[0].find('a')['href']
url = download_page_link
r = requests.get(url)
soup = BeautifulSoup(r.content, "html5lib")
divs = soup.find_all("div", class_="mirror_link")
#getting the resolution
d = {}
index = 1
for div in divs[:-1]:
qualities = div.find_all('div')
for quality in qualities:
q=quality.find('a')
# print(index, q.text.split()[1][1:])
d[index] = q['href']
index += 1
# quality_num = input("Choose the quality: ")
# url = d[int(quality_num)]
url = d[1]
#running the anime on mpv
cmd = f"mpv {url} > /dev/null 2>&1"
os.system(cmd)
ans = input(colored("\nNext Episode? (y/n): ", 'yellow'))
if(ans == 'n' or ans == 'N'):
print(colored("Quitting, bye", 'red'))
break
if(int(ep_num) >= ep_end):
print(colored("Quitting, no more episodes in the current season", 'red'))
break
ep_num = int(ep_num) + 1