Skip to content

Commit a6236d3

Browse files
Add Scrap Latest Torrents (HarshCasper#859)
* Add Script * Some minor changes * Add blank line * Some suggested changes
1 parent 400fca7 commit a6236d3

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Scrap Latest Torrents
2+
3+
This script downloads the torrents in our Torrent client from the website https://rarbg.to/ from an entered label.
4+
5+
### Requirements
6+
7+
1. You must have a torrent client, for example: uTorrent, BitTorrent, etc
8+
a. You can download **uTorrent** from here: www.utorrent.com
9+
b. You can download **BitTorrent** from here: www.bittorrent.com
10+
11+
### Setup
12+
13+
1. Create a Virtual Environment.
14+
a. `$ git clone <Project> # Cloning project repository`
15+
b. `$ cd <Project> # Enter to project directory`
16+
c. `$ python3 -m venv my_venv # If not created, creating virtualenv`
17+
&nbsp;&nbsp;&nbsp;&nbsp; - If you use Windows: `my_env/Script/activate # Activating virtualenv`
18+
&nbsp;&nbsp;&nbsp;&nbsp; - If you use Linux or Mac: `$ source ./my_env/bin/activate # Activating virtualenv`
19+
**More Info**: [Virtual Environments and Packages](https://docs.python.org/3/tutorial/venv.html)
20+
2. Install the requirements by using `pip3 install -r requirements.txt`
21+
22+
### Running a File
23+
24+
1. Run the Script `python scrap_latest_torrents.py`
25+
2. Enter the label to search, example: Mr Robot.
26+
3. The number of Torrents found will be displayed, you must confirm the download
27+
28+
![How to use the script](https://i.ibb.co/PD3sPLf/Scrap-Latest-Torrents.png)
29+
30+
## Author(s)
31+
32+
**_ Made By [Diego Caraballo](https://github.com/DiegoCaraballo) _**
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
certifi==2020.12.5
2+
chardet==4.0.0
3+
idna==2.10
4+
RarbgAPI==0.4.2
5+
requests==2.25.1
6+
urllib3==1.26.4
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""
2+
This script downloads the torrents in our Torrent client from the
3+
website https://rarbg.to/ from an entered label.
4+
"""
5+
6+
import subprocess
7+
import os
8+
import sys
9+
import rarbgapi
10+
11+
12+
def main():
13+
"""
14+
Principal function
15+
"""
16+
count = 0
17+
18+
# Label to search
19+
label = input("Enter a label: ")
20+
21+
# Search Torrents
22+
torrents = search_torrents(label)
23+
24+
# If no torrents were found
25+
if len(torrents) == 0:
26+
another_search = input(
27+
str(len(torrents))
28+
+ " torrents found, do you want to do another search? y/n :"
29+
)
30+
if another_search.upper() == "Y" or another_search.upper() == "YES":
31+
main()
32+
else:
33+
# Option User
34+
option = input(
35+
str(len(torrents)) + " torrents found Do you want to download them? y/n :"
36+
)
37+
38+
if option.upper() == "Y" or option.upper() == "YES":
39+
print("Downloading torrents... please wait")
40+
for torrent in torrents:
41+
open_file(torrent.download)
42+
count += 1
43+
print(str(count) + " - " + str(torrent))
44+
else:
45+
exit_option = input("Do you want to do another search? y/n :")
46+
if exit_option.upper() == "Y" or exit_option.upper() == "YES":
47+
main()
48+
49+
print("Exit")
50+
51+
52+
def open_file(filename):
53+
"""
54+
Function that opens the torrent file according to the operating system
55+
"""
56+
if sys.platform == "win32":
57+
os.startfile(filename)
58+
else:
59+
opener = "open" if sys.platform == "darwin" else "xdg-open"
60+
subprocess.call([opener, filename])
61+
62+
63+
def search_torrents(label):
64+
"""
65+
Function that searches for torrents from the RARBG API
66+
"""
67+
68+
print("Searching torrents... please wait")
69+
70+
client = rarbgapi.RarbgAPI()
71+
torrents = client.search(search_string=label, limit=100)
72+
73+
return torrents
74+
75+
76+
if __name__ == "__main__":
77+
main()
78+

0 commit comments

Comments
 (0)