-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
88 lines (62 loc) · 1.92 KB
/
main.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
import requests
from bs4 import BeautifulSoup
movie = input()
movie = movie.split()
movie = "%20".join(movie)
# print(movie)
URL = "https://yts-subs.com/search/"+movie
header = { "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36'}
r = requests.get(URL,headers=header)
print(r.url)
soup = BeautifulSoup(r.content, 'html5lib')
# print(soup.div['media-body'])
title = soup.find_all(class_='media-movie-clickable',limit=3)
c = 1
for i in title:
# print(i)
k = str(i)
k = BeautifulSoup(k,'html5lib')
print(c,k.find(class_='media-heading').text,end="--")
print(k.find(class_='movinfo-section').text.strip())
c+=1
n = int(input("Enter number to download : "))
k = str(title[n-1])
k = BeautifulSoup(k,'html5lib')
l = (k.find(class_='media-heading').text)
print(l)
print("Getting info...")
URL = "https://yts-subs.com"+k.a['href']
print(URL)
s = requests.get(URL,headers=header)
# print(r.url)
ssoup = BeautifulSoup(s.content, 'html5lib')
print(ssoup.find(class_='high-rating'))
title = ssoup.find_all(class_='high-rating')
print(title)
c = 1
for i in title:
# print(i)
k = str(i)
k = BeautifulSoup(k,'html5lib')
print(c,k.find(class_='sub-lang').text,end=" rating: ")
print(k.find(class_='label').text)
print(k.a['href'])
c+=1
n = int(input("Enter number to download : "))
print("Getting File link...")
k = str(title[n-1])
k = BeautifulSoup(k,'html5lib')
# print(k.find(class_='media-heading').text)
URL = "https://yts-subs.com"+k.a['href']
print(URL)
print("Downloading...")
r = requests.get(URL) # create HTTP response object
l = l+'.zip'
with open(l,'wb') as f:
# Saving received content as a png file in
# binary format
# write the contents of the response (r.content)
# to a new file in binary mode.
f.write(r.content)
print("Unzipping....")
# print(soup.head)