-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.py
63 lines (40 loc) · 1.21 KB
/
index.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
import re
import requests
from bs4 import BeautifulSoup
import urllib.request as DFU
#DFU (Download From URL)
import os
from termcolor import colored
url = input('Enter URL : ')
data = requests.get(url)
print(data)
str = data.text
match = re.findall(r'video_url\W\W\W([-\W\w]+)\W\W\Wvideo_view_count', str)
extraction = ".mp4"
if len(match) == 0:
match = re.findall(r'display_url\W\W\W([-\W\w]+)\W\W\Wdisplay_resources', str)
extraction = ".jpg"
res = match[0]
#title = re.search(r'\Wtitle\W([-\W\w]+)\W\Wtitle\W', str)
page = BeautifulSoup(str, "html.parser")
title = page.find("title")
title = title.get_text()
title = re.sub(r"\W+", "_", title)
title = "download/sarjsk991"+title+"Sarjsk991"
print("\n"+title)
title = title
if res != "" :
print('found \n \n'+'\033[1m'+colored(res, 'green')+'\033[0m'+'\n') #'found word:cat'
download = input("Do you want to download(y/N) : ")
if (download == "y" or download == "Y"):
try:
fileName = title
print("Downloading.....")
DFU.urlretrieve(res, fileName+extraction)
print("Download Successfully!")
os.system("tree download")
except:
print("Sorry! Download Unsuccessful")
else:
print('did not find or post is from private account')
exit()