-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathrockbox.py
More file actions
73 lines (64 loc) · 2.67 KB
/
rockbox.py
File metadata and controls
73 lines (64 loc) · 2.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
# VERSION: 1.1
# AUTHORS: LightDestory (https://github.com/LightDestory)
import re
from helpers import retrieve_url
from novaprinter import prettyPrinter
class rockbox(object):
url = 'https://rawkbawx.rocks/'
name = 'RockBox'
"""
TLDR; It is safer to force an 'all' research
RockBox's categories are very specific for music-type
qBittorrent does not provide enough categories to implement a good filtering.
"""
supported_categories = {'all': '0'}
class HTMLParser:
def __init__(self, url):
self.url = url
self.noTorrents = False
def feed(self, html):
self.noTorrents = False
torrents = self.__findTorrents(html)
if len(torrents) == 0:
self.noTorrents = True
return
for torrent in range(len(torrents)):
data = {
'link': torrents[torrent][0],
'name': torrents[torrent][1],
'size': torrents[torrent][2],
'seeds': torrents[torrent][3],
'leech': torrents[torrent][4],
'engine_url': self.url,
'desc_link': torrents[torrent][5]
}
prettyPrinter(data)
def __findTorrents(self, html):
torrents = []
trs = re.findall(r'<TR><td align=\"center\".*?</TR>', html)
for tr in trs:
# Extract from the A node all the needed information
url_titles = re.search(
r'.+?HREF=\"(.+?)\".+?details\: ?(.+?)\">.+?rating.+?HREF=(.+?)>.+?([0-9\,\.]+ (TB|GB|MB|KB)).+?peers details\">([0-9,]+).+?peers details\">([0-9,]+).+?',
tr)
if url_titles:
torrents.append([
'{0}{1}'.format(self.url, url_titles.group(3)),
url_titles.group(2),
url_titles.group(4).replace(",", ""),
url_titles.group(6).replace(",", ""),
url_titles.group(7).replace(",", ""),
'{0}{1}'.format(self.url, url_titles.group(1))
])
return torrents
def search(self, what, cat='all'):
what = what.replace("%20", "+")
parser = self.HTMLParser(self.url)
counter: int = 0
while True:
url = '{0}torrents.php?active=0&search={1}&options=0&order=data&page={2}'.format(self.url, what, counter)
html = re.sub(r'\s+', ' ', retrieve_url(url)).strip()
parser.feed(html)
if parser.noTorrents:
break
counter += 1