2016-08-13 12:55:47 +00:00
|
|
|
"""
|
|
|
|
DigBT (Videos, Music, Files)
|
|
|
|
|
|
|
|
@website https://digbt.org
|
|
|
|
@provide-api no
|
|
|
|
|
|
|
|
@using-api no
|
|
|
|
@results HTML (using search portal)
|
|
|
|
@stable no (HTML can change)
|
|
|
|
@parse url, title, content, magnetlink
|
|
|
|
"""
|
|
|
|
|
2016-11-30 17:43:03 +00:00
|
|
|
from sys import version_info
|
2016-08-13 12:55:47 +00:00
|
|
|
from lxml import html
|
|
|
|
from searx.engines.xpath import extract_text
|
|
|
|
from searx.utils import get_torrent_size
|
2016-11-30 17:43:03 +00:00
|
|
|
from searx.url_utils import urljoin
|
|
|
|
|
|
|
|
if version_info[0] == 3:
|
|
|
|
unicode = str
|
2016-08-13 12:55:47 +00:00
|
|
|
|
|
|
|
categories = ['videos', 'music', 'files']
|
|
|
|
paging = True
|
|
|
|
|
|
|
|
URL = 'https://digbt.org'
|
|
|
|
SEARCH_URL = URL + '/search/{query}-time-{pageno}'
|
|
|
|
FILESIZE = 3
|
|
|
|
FILESIZE_MULTIPLIER = 4
|
|
|
|
|
|
|
|
|
|
|
|
def request(query, params):
|
|
|
|
params['url'] = SEARCH_URL.format(query=query, pageno=params['pageno'])
|
|
|
|
|
|
|
|
return params
|
|
|
|
|
|
|
|
|
|
|
|
def response(resp):
|
2016-11-30 17:43:03 +00:00
|
|
|
dom = html.fromstring(resp.text)
|
2016-08-13 12:55:47 +00:00
|
|
|
search_res = dom.xpath('.//td[@class="x-item"]')
|
|
|
|
|
|
|
|
if not search_res:
|
|
|
|
return list()
|
|
|
|
|
|
|
|
results = list()
|
|
|
|
for result in search_res:
|
|
|
|
url = urljoin(URL, result.xpath('.//a[@title]/@href')[0])
|
2016-09-20 20:35:54 +00:00
|
|
|
title = extract_text(result.xpath('.//a[@title]'))
|
2016-08-13 12:55:47 +00:00
|
|
|
content = extract_text(result.xpath('.//div[@class="files"]'))
|
|
|
|
files_data = extract_text(result.xpath('.//div[@class="tail"]')).split()
|
|
|
|
filesize = get_torrent_size(files_data[FILESIZE], files_data[FILESIZE_MULTIPLIER])
|
|
|
|
magnetlink = result.xpath('.//div[@class="tail"]//a[@class="title"]/@href')[0]
|
|
|
|
|
|
|
|
results.append({'url': url,
|
|
|
|
'title': title,
|
|
|
|
'content': content,
|
|
|
|
'filesize': filesize,
|
|
|
|
'magnetlink': magnetlink,
|
|
|
|
'seed': 'N/A',
|
|
|
|
'leech': 'N/A',
|
|
|
|
'template': 'torrent.html'})
|
|
|
|
|
|
|
|
return results
|