-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplay_list_finder.py
47 lines (38 loc) · 1.71 KB
/
play_list_finder.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
# this module will find and list all video of playlist url with given quality
from bs4 import BeautifulSoup as bs
import requests
import re
import sys
videos = list()
# def find_from_inside(pllink):
#TODO this fucking shit does not work, may becasue the aparat change the fron, how ever this should change to a nother crowlwe
def main(link):
if(link[0:32] == "https://www.aparat.com/playlist/"):
req = requests.get(link)
if(req.status_code == 200):
soup = bs(req.content, "html.parser")
soup = soup.find_all("a",attrs={"class":"light-80 dark-10"})
soup = bs(str(soup), "html.parser")
for i in soup.find_all("a", attrs={"class":"light-80 dark-10"}):
videos.append('https://aparat.com'+i["href"])
return videos
else:
print("err: http status code:", req.status_code)
sys.exit(req.status_code)
elif(link[0:23] == "https://www.aparat.com/"):
link = "https://aparat.com/playlist/" + re.findall("\=(.*)", link)[0] # this regex return play list address
print(link)
req = requests.get(link)
if(req.status_code == 200):
soup = bs(req.content, "html.parser")
soup = soup.find_all("a",attrs={"class":"light-80 dark-10"})
soup = bs(str(soup), "html.parser")
for i in soup.find_all("a", attrs={"class":"light-80 dark-10"}):
videos.append('https://aparat.com'+i["href"])
return videos
else:
print("err: http status code:", req.status_code)
sys.exit(req.status_code)
if __name__ == '__main__':
print('running')
print(main('https://www.aparat.com/v/FKi9I?playlist=1284902'))