.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.btdigg Namespace Reference

Functions

 request (query, params)
 
 response (resp)
 

Variables

dict about
 
list categories = ['files']
 
bool paging = True
 
str url = 'https://btdig.com'
 
str search_url = url + '/search?q={search_term}&p={pageno}'
 

Detailed Description

 BTDigg (Videos, Music, Files)

Function Documentation

◆ request()

searx.engines.btdigg.request ( query,
params )

Definition at line 31 of file btdigg.py.

31def request(query, params):
32 params['url'] = search_url.format(search_term=quote(query), pageno=params['pageno'] - 1)
33
34 return params
35
36
37# get response from search-request

◆ response()

searx.engines.btdigg.response ( resp)

Definition at line 38 of file btdigg.py.

38def response(resp):
39 results = []
40
41 dom = html.fromstring(resp.text)
42
43 search_res = dom.xpath('//div[@class="one_result"]')
44
45 # return empty array if nothing is found
46 if not search_res:
47 return []
48
49 # parse results
50 for result in search_res:
51 link = result.xpath('.//div[@class="torrent_name"]//a')[0]
52 href = urljoin(url, link.attrib.get('href'))
53 title = extract_text(link)
54
55 excerpt = result.xpath('.//div[@class="torrent_excerpt"]')[0]
56 content = html.tostring(excerpt, encoding='unicode', method='text', with_tail=False)
57 # it is better to emit <br/> instead of |, but html tags are verboten
58 content = content.strip().replace('\n', ' | ')
59 content = ' '.join(content.split())
60
61 filesize = result.xpath('.//span[@class="torrent_size"]/text()')[0].split()[0]
62 filesize_multiplier = result.xpath('.//span[@class="torrent_size"]/text()')[0].split()[1]
63 files = (result.xpath('.//span[@class="torrent_files"]/text()') or ['1'])[0]
64
65 # convert filesize to byte if possible
66 filesize = get_torrent_size(filesize, filesize_multiplier)
67
68 # convert files to int if possible
69 try:
70 files = int(files)
71 except: # pylint: disable=bare-except
72 files = None
73
74 magnetlink = result.xpath('.//div[@class="torrent_magnet"]//a')[0].attrib['href']
75
76 # append result
77 results.append(
78 {
79 'url': href,
80 'title': title,
81 'content': content,
82 'filesize': filesize,
83 'files': files,
84 'magnetlink': magnetlink,
85 'template': 'torrent.html',
86 }
87 )
88
89 # return results sorted by seeder
90 return results

Variable Documentation

◆ about

dict searx.engines.btdigg.about
Initial value:
1= {
2 "website": 'https://btdig.com',
3 "wikidata_id": 'Q4836698',
4 "official_api_documentation": {'url': 'https://btdig.com/contacts', 'comment': 'on demand'},
5 "use_official_api": False,
6 "require_api_key": False,
7 "results": 'HTML',
8}

Definition at line 12 of file btdigg.py.

◆ categories

list searx.engines.btdigg.categories = ['files']

Definition at line 22 of file btdigg.py.

◆ paging

bool searx.engines.btdigg.paging = True

Definition at line 23 of file btdigg.py.

◆ search_url

str searx.engines.btdigg.search_url = url + '/search?q={search_term}&p={pageno}'

Definition at line 27 of file btdigg.py.

◆ url

str searx.engines.btdigg.url = 'https://btdig.com'

Definition at line 26 of file btdigg.py.