|
@@ -0,0 +1,58 @@
|
|
1
|
+"""
|
|
2
|
+ DigBT (Videos, Music, Files)
|
|
3
|
+
|
|
4
|
+ @website https://digbt.org
|
|
5
|
+ @provide-api no
|
|
6
|
+
|
|
7
|
+ @using-api no
|
|
8
|
+ @results HTML (using search portal)
|
|
9
|
+ @stable no (HTML can change)
|
|
10
|
+ @parse url, title, content, magnetlink
|
|
11
|
+"""
|
|
12
|
+
|
|
13
|
+from urlparse import urljoin
|
|
14
|
+from lxml import html
|
|
15
|
+from searx.engines.xpath import extract_text
|
|
16
|
+from searx.utils import get_torrent_size
|
|
17
|
+
|
|
18
|
+categories = ['videos', 'music', 'files']
|
|
19
|
+paging = True
|
|
20
|
+
|
|
21
|
+URL = 'https://digbt.org'
|
|
22
|
+SEARCH_URL = URL + '/search/{query}-time-{pageno}'
|
|
23
|
+FILESIZE = 3
|
|
24
|
+FILESIZE_MULTIPLIER = 4
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+def request(query, params):
|
|
28
|
+ params['url'] = SEARCH_URL.format(query=query, pageno=params['pageno'])
|
|
29
|
+
|
|
30
|
+ return params
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+def response(resp):
|
|
34
|
+ dom = html.fromstring(resp.content)
|
|
35
|
+ search_res = dom.xpath('.//td[@class="x-item"]')
|
|
36
|
+
|
|
37
|
+ if not search_res:
|
|
38
|
+ return list()
|
|
39
|
+
|
|
40
|
+ results = list()
|
|
41
|
+ for result in search_res:
|
|
42
|
+ url = urljoin(URL, result.xpath('.//a[@title]/@href')[0])
|
|
43
|
+ title = result.xpath('.//a[@title]/text()')[0]
|
|
44
|
+ content = extract_text(result.xpath('.//div[@class="files"]'))
|
|
45
|
+ files_data = extract_text(result.xpath('.//div[@class="tail"]')).split()
|
|
46
|
+ filesize = get_torrent_size(files_data[FILESIZE], files_data[FILESIZE_MULTIPLIER])
|
|
47
|
+ magnetlink = result.xpath('.//div[@class="tail"]//a[@class="title"]/@href')[0]
|
|
48
|
+
|
|
49
|
+ results.append({'url': url,
|
|
50
|
+ 'title': title,
|
|
51
|
+ 'content': content,
|
|
52
|
+ 'filesize': filesize,
|
|
53
|
+ 'magnetlink': magnetlink,
|
|
54
|
+ 'seed': 'N/A',
|
|
55
|
+ 'leech': 'N/A',
|
|
56
|
+ 'template': 'torrent.html'})
|
|
57
|
+
|
|
58
|
+ return results
|