forked from HarshCasper/Rotten-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrap_latest_torrents.py
More file actions
77 lines (60 loc) · 1.88 KB
/
scrap_latest_torrents.py
File metadata and controls
77 lines (60 loc) · 1.88 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
"""
This script downloads the torrents in our Torrent client from the
website https://rarbg.to/ from an entered label.
"""
import subprocess
import os
import sys
import rarbgapi
def main():
"""
Principal function
"""
count = 0
# Label to search
label = input("Enter a label: ")
# Search Torrents
torrents = search_torrents(label)
# If no torrents were found
if len(torrents) == 0:
another_search = input(
str(len(torrents))
+ " torrents found, do you want to do another search? y/n :"
)
if another_search.upper() == "Y" or another_search.upper() == "YES":
main()
else:
# Option User
option = input(
str(len(torrents)) + " torrents found Do you want to download them? y/n :"
)
if option.upper() == "Y" or option.upper() == "YES":
print("Downloading torrents... please wait")
for torrent in torrents:
open_file(torrent.download)
count += 1
print(str(count) + " - " + str(torrent))
else:
exit_option = input("Do you want to do another search? y/n :")
if exit_option.upper() == "Y" or exit_option.upper() == "YES":
main()
print("Exit")
def open_file(filename):
"""
Function that opens the torrent file according to the operating system
"""
if sys.platform == "win32":
os.startfile(filename)
else:
opener = "open" if sys.platform == "darwin" else "xdg-open"
subprocess.call([opener, filename])
def search_torrents(label):
"""
Function that searches for torrents from the RARBG API
"""
print("Searching torrents... please wait")
client = rarbgapi.RarbgAPI()
torrents = client.search(search_string=label, limit=100)
return torrents
if __name__ == "__main__":
main()