This repository was archived by the owner on Apr 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathx1337.py
More file actions
70 lines (63 loc) · 2.7 KB
/
x1337.py
File metadata and controls
70 lines (63 loc) · 2.7 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
import sys
import requests
from bs4 import BeautifulSoup
user_agent = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36'
}
def getMegnet(url):
response = requests.get(url, headers=user_agent)
soup = BeautifulSoup(response.content, 'html.parser')
magnetLink = soup.select('a[href^="magnet"]')[0]['href']
return magnetLink
def search(somestring):
url = f'https://1337x.to/srch?search={somestring}'
response = requests.get(url, headers=user_agent)
soup = BeautifulSoup(response.content, 'html.parser')
if "Attention Required!" in str(soup.select('head > title')):
print("IP blocked! Try changing VPN. I can't solve captcha")
sys.exit(0)
else:
torrent_list = soup.select('a[href*="/torrent/"]')
seeds = soup.select('td.coll-2')
leeches = soup.select('td.coll-3')
size = soup.select('td.coll-4')
uploader = soup.select('td.coll-5')
torrents_dict = {
'torrents': []
}
try:
print("SN".ljust(4), "TORRENT NAME".ljust(80), "SEEDS".ljust(6),
"LEECHES".ljust(6), "SIZE".center(12), "UPLOADER")
for i in range(10):
torrent_name = torrent_list[i].getText()[:75]
torrent_seeds = seeds[i].getText()
torrent_leeches = leeches[i].getText()
torrent_size = size[i].contents[0]
torrent_uploader = uploader[i].getText()
print(str(i + 1).ljust(4), torrent_name.ljust(80), torrent_seeds.ljust(6),
torrent_leeches.ljust(6), torrent_size.center(12), torrent_uploader)
href_link = "https://1337x.to" + torrent_list[i]['href']
temp_dict = {
'name': torrent_name,
'size': torrent_size,
'seeds': torrent_seeds,
'leeches': torrent_leeches,
'uploader': torrent_uploader,
'href': href_link
}
torrents_dict['torrents'].append(temp_dict)
except IndexError:
pass
while 1:
try:
input_index = int(input("Select torrent to add...\n")) - 1
if input_index >= 0 and input_index < len(torrents_dict['torrents']):
goto_link = torrents_dict['torrents'][input_index]['href']
return getMegnet(goto_link)
else:
print("Invalid input")
except ValueError:
print("Invlid input")
except KeyboardInterrupt:
print("\nExiting...")
sys.exit(0)