-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTorrentyPy_win.py
More file actions
256 lines (203 loc) · 8.67 KB
/
TorrentyPy_win.py
File metadata and controls
256 lines (203 loc) · 8.67 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import requests
import os
from time import sleep as sp
import json
mov_url_json = 'https://yts.lt/api/v2/list_movies.json?limit='
search_url = 'https://yts.lt/api/v2/list_movies.json?query_term='
class color:
pink = '\033[95m'
purple = '\33[35m'
orange = '\033[33m'
blue = '\033[94m'
green = '\033[92m'
yellow = '\033[93m'
red = '\033[91m'
end = '\033[0m'
class TorrentyPy:
@staticmethod
def mov_list(limit):
r = requests.get(mov_url_json + str(limit))
if r.status_code == 200:
print('\nPlease Wait Getting Data.')
with open('.temp.json', 'w') as js:
json.dump(r.json(), js)
mov = json.load(open('.temp.json', 'r'))
print("\n\t\tMovies List\n")
for i in mov["data"]["movies"]:
print('**************************************')
print('Name : ' + i["title_english"])
print('URL : ' + i["url"])
print('Genre :' + str(i["genres"]))
print('Year Released : ' + str(i["year"]))
print("Rating : " + str(i["rating"]))
print('Total Time : ' + str(i["runtime"]))
print('\n')
@staticmethod
def search(query):
r = requests.get(search_url + str(query))
with open('.temp.json', 'w') as js:
json.dump(r.json(), js)
mov = json.load(open('.temp.json', 'r'))
if mov["status_message"] == "Query was successful":
print("\nSearch Successfull.\n")
for i in mov["data"]["movies"]:
print('**************************************')
print('Name : ' + i["title_english"])
print('URL : ' + i["url"])
print('Genre :' + str(i["genres"]))
print('Year Released : ' + str(i["year"]))
print("Rating : " + str(i["rating"]))
print('Total Time :' + str(i["runtime"]))
print('\n')
query = query.replace(' ', '-')
a = input('\nDo U Wish To Download Torrent[y/N]: ').lower()
if a == 'y':
for k in i["torrents"]:
global url
url = str(k["url"])
url = url.replace("\\", '')
print('\nDownloading Torrent File\n')
if os.path.exists('TorrentyPy/downloads'):
pass
else:
os.system('mkdir TorrentyPy')
os.system('mkdir TorrentyPy\downloads')
n = requests.get(url=url)
open('TorrentyPy\downloads\\'+ query + '.torrent', 'wb').write(n.content)
else:
sp(1)
return main()
else:
print("Movie Not Found...")
@staticmethod
def chk_movies(movies_list):
if os.path.exists(movies_list):
pass
else:
raise FileNotFoundError
if os.path.exists('TorrentyPy'):
pass
else:
os.system('mkdir TorrentyPy')
with open(movies_list, 'r') as movie_list:
for line in movie_list:
line = line.strip('\n')
r = requests.get(search_url + str(line))
with open('.temp.json', 'w') as js:
json.dump(r.json(), js)
mov = json.load(open('.temp.json', 'r'))
if mov["status_message"] == "Query was successful":
res = line + "\t\t--Movie Found.\n"
print(res)
if os.path.exists('\TorrentyPy\TorrentyPy_res.txt'):
with open('TorrentyPy\TorrentyPy_res.txt', 'a') as results:
results.write(res)
else:
os.system('type NUL > TorrentyPy\TorrentyPy_res.txt')
with open('TorrentyPy\TorrentyPy_res.txt', 'a') as results:
results.write(res)
else:
print(line + "\t\t--Movie Not Found.\n")
@staticmethod
def chk_down(movies_list):
if os.path.exists(movies_list):
pass
else:
raise FileNotFoundError
if os.path.exists('TorrentyPy'):
pass
else:
os.system('mkdir TorrentyPy')
with open(movies_list, 'r') as movie_list:
for line in movie_list:
line = line.strip('\n')
r = requests.get(search_url + str(line))
with open('.temp.json', 'w') as js:
json.dump(r.json(), js)
mov = json.load(open('.temp.json', 'r'))
if mov["status_message"] == "Query was successful":
print('\n' + line + "\t\t--Movie Found.\n")
print('Downloading Torrent Please Wait...\n')
line = line.replace(' ', '-')
for i in mov["data"]["movies"]:
for k in i["torrents"]:
global url
url = str(k["url"])
url = url.replace("\\", '')
if os.path.exists('TorrentyPy\downloads'):
pass
else:
os.system('mkdir TorrentyPy\downloads')
n = requests.get(url=url)
open('TorrentyPy\downloads\\'+ line + '.torrent', 'wb').write(n.content)
else:
print(line + "\t\t--Movie Not Found.\n")
sp(1)
print('\n\nAll The Files Have Been Downloaded To TorrentyPy\downloads')
def main():
print('\n\t\tMENU\n')
print('1.Get Latest Movie List.')
print('2.Search For A Movie.')
print('3.Perform Mass Movie Search.')
print('4.Download Huge List Of Torrent Files.')
print('5.Exit.')
opt = input('\nEnter Your Choice: ')
if opt == '1':
print('\nGetting A Fresh Movie List Please Wait..')
TorrentyPy.mov_list(20)
os.system('del .temp.json')
sp(2)
input('\nPress Enter Key To Continue...')
return main()
elif opt == '2':
query = input('\nMovie To Search: ')
TorrentyPy.search(query=query)
os.system('del .temp.json')
sp(2)
input('\nPress Enter Key To Continue...')
return main()
elif opt == '3':
print('\nInitiating The Searcher Please Wait...\n')
TorrentyPy.chk_movies(movies_list='movie_list.txt')
os.system('del .temp.json')
sp(2)
return main()
elif opt == '4':
print('\nInitiating The Downloader Please Wait...\n')
TorrentyPy.chk_down(movies_list='movie_list.txt')
os.system('del .temp.json')
sp(2)
return main()
elif opt == '5':
print('\nSorry To See You Go..\n')
sp(2)
exit(0)
else:
print('\nUnknow Option Selected.Please Retry...')
sp(2)
return main()
if __name__ == '__main__':
print('''
_____ _ ______
|_ _| | | | ___ \
| | ___ _ __ _ __ ___ _ __ | |_ _ _ | |_/ /_ _
| | / _ \ | '__|| '__|/ _ \| '_ \ | __|| | | || __/| | | |
| || (_) || | | | | __/| | | || |_ | |_| || | | |_| |
\_/ \___/ |_| |_| \___||_| |_| \__| \__, |\_| \__, |
_/ | __/ |
|___/ |___/
Torrent CLI Client by 41_alderson
''')
sp(1.5)
print('''
\t\tAuthor: 41_alderson
\t\tGithub: https://github.com/41alderson/TorrentyPy
\t\tTelegram: @destroyer41
\nIf You Find Any Problem Or Want Any New Feature To Be Added To The Script
Please Pull A New Request On Github (Or) Contact Me.''')
sp(1.5)
print(
'''\n\nNote1: Currently Its Gets Top 20 Movie List.If You Want To get More Movie List Change The Limit In The Script.\n\n'''
+ '''Note2: To Perform Mass Movie Search Or Mass Download Please Keep Rename The txt Containing The list Of The Movies as \'movie_list.txt\' And Make Sure Both Script And File are In Same Folder.''')
sp(1)
main()