A simple torrent scraper using Python
Currently scrapes sites: 1337x, ThePirateBay, Rarbg, Ettvdl
http://samcloud.tplinkdns.com/torrent
Get a list of sites:
/getSites
Search a site for torrents:
/getTorrents
Parameters:
{"search_key" : search_key, "site" : site}
Get magnet link and file list:
/getTorrentData
Parameters:
{"link" : link, "site" : site}
Geting list of sites:
http://samcloud.tplinkdns.com:50000/getSites
Returns JSON:
{
"sites": [
"1337x",
"ThePirateBay",
"Rarbg",
"Ettvdl"
]
}
Searching 1337x for Call of duty torrents:
http://samcloud.tplinkdns.com:50000/getTorrents?search_key=call%20of%20duty&site=1337x
Returns JSON:
{
"torrents": [
{
"name": "Call of Duty…",
"seeds": 949,
"leeches": 61,
"size": "3.5 GB",
"uploader": "Sigaint",
"link": "http://1337x.to/torrent/183…"
}
]
…
}
Geting magnet link and file list from 1337x site:
Returns JSON:
{
"magnet": "magnet:?xt=urn:btih:97A1E506E2A0…",
"files": [
"Torrent downl..txt (0.0 KB)",
"Torrent Downl….txt (0.0 KB)",
"Torrent downl….txt (0.0 KB)",
"autorun.inf (0.1 KB)",
"Instructions.txt (1.3 KB)",
"Icon.ico (14.0 KB)",
"Setup.exe (21.2 MB)",
"DJ.bin (3.4 GB)"
]
}
You need Python version 3.x to run this
Use the package manager pip to install necessary libraries:
flask, flask-cors, waitress, requests, bs4, lxml
pip install {package name}
Place blocklist.txt in any location and update the path in TorrentServer.py file
with open("path to blocklist.txt", "r") as file:
This list is used to block adult torrents
Run the torrent_server.py file
python torrent_server.py
By default it runs on 0.0.0.0 (accept requests from everywhere) and port: 50000
Then access it using
http://server-ip:port/api