Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
eb182df1
Commit
eb182df1
authored
Jul 25, 2019
by
volth
Committed by
Alexandre Flament
Jul 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[mod] restore btdigg engine as btdig.com (#1515)
parent
3b1122c5
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
369 deletions
+94
-369
btdigg.py
searx/engines/btdigg.py
+16
-23
settings.yml
searx/settings.yml
+4
-0
torrent.html
searx/templates/courgette/result_templates/torrent.html
+1
-1
torrent.html
searx/templates/legacy/result_templates/torrent.html
+1
-1
torrent.html
searx/templates/oscar/result_templates/torrent.html
+1
-1
test_btdigg.py
tests/unit/engines/test_btdigg.py
+71
-343
No files found.
searx/engines/btdigg.py
View file @
eb182df1
"""
BTDigg (Videos, Music, Files)
@website https://btdig
g.org
@website https://btdig
.com
@provide-api yes (on demand)
@using-api no
...
...
@@ -21,7 +21,7 @@ categories = ['videos', 'music', 'files']
paging
=
True
# search-url
url
=
'https://btdig
g.org
'
url
=
'https://btdig
.com
'
search_url
=
url
+
'/search?q={search_term}&p={pageno}'
...
...
@@ -39,7 +39,7 @@ def response(resp):
dom
=
html
.
fromstring
(
resp
.
text
)
search_res
=
dom
.
xpath
(
'//div[@
id="search_res"]/table/tr
'
)
search_res
=
dom
.
xpath
(
'//div[@
class="one_result"]
'
)
# return empty array if nothing is found
if
not
search_res
:
...
...
@@ -47,46 +47,39 @@ def response(resp):
# parse results
for
result
in
search_res
:
link
=
result
.
xpath
(
'.//
td
[@class="torrent_name"]//a'
)[
0
]
link
=
result
.
xpath
(
'.//
div
[@class="torrent_name"]//a'
)[
0
]
href
=
urljoin
(
url
,
link
.
attrib
.
get
(
'href'
))
title
=
extract_text
(
link
)
content
=
extract_text
(
result
.
xpath
(
'.//pre[@class="snippet"]'
)[
0
])
content
=
"<br />"
.
join
(
content
.
split
(
"
\n
"
))
filesize
=
result
.
xpath
(
'.//span[@class="attr_val"]/text()'
)[
0
]
.
split
()[
0
]
filesize_multiplier
=
result
.
xpath
(
'.//span[@class="attr_val"]/text()'
)[
0
]
.
split
()[
1
]
files
=
result
.
xpath
(
'.//span[@class="attr_val"]/text()'
)[
1
]
seed
=
result
.
xpath
(
'.//span[@class="attr_val"]/text()'
)[
2
]
excerpt
=
result
.
xpath
(
'.//div[@class="torrent_excerpt"]'
)[
0
]
content
=
html
.
tostring
(
excerpt
,
encoding
=
'unicode'
,
method
=
'text'
,
with_tail
=
False
)
# it is better to emit <br/> instead of |, but html tags are verboten
content
=
content
.
strip
()
.
replace
(
'
\n
'
,
' | '
)
content
=
' '
.
join
(
content
.
split
())
# convert seed to int if possible
if
seed
.
isdigit
():
seed
=
int
(
seed
)
else
:
seed
=
0
leech
=
0
filesize
=
result
.
xpath
(
'.//span[@class="torrent_size"]/text()'
)[
0
]
.
split
()[
0
]
filesize_multiplier
=
result
.
xpath
(
'.//span[@class="torrent_size"]/text()'
)[
0
]
.
split
()[
1
]
files
=
(
result
.
xpath
(
'.//span[@class="torrent_files"]/text()'
)
or
[
'1'
])[
0
]
# convert filesize to byte if possible
filesize
=
get_torrent_size
(
filesize
,
filesize_multiplier
)
# convert files to int if possible
if
files
.
isdigit
()
:
try
:
files
=
int
(
files
)
e
lse
:
e
xcept
:
files
=
None
magnetlink
=
result
.
xpath
(
'.//
td[@class="ttth
"]//a'
)[
0
]
.
attrib
[
'href'
]
magnetlink
=
result
.
xpath
(
'.//
div[@class="torrent_magnet
"]//a'
)[
0
]
.
attrib
[
'href'
]
# append result
results
.
append
({
'url'
:
href
,
'title'
:
title
,
'content'
:
content
,
'seed'
:
seed
,
'leech'
:
leech
,
'filesize'
:
filesize
,
'files'
:
files
,
'magnetlink'
:
magnetlink
,
'template'
:
'torrent.html'
})
# return results sorted by seeder
return
sorted
(
results
,
key
=
itemgetter
(
'seed'
),
reverse
=
True
)
return
results
searx/settings.yml
View file @
eb182df1
...
...
@@ -115,6 +115,10 @@ engines:
disabled
:
True
shortcut
:
bb
-
name
:
btdigg
engine
:
btdigg
shortcut
:
bt
-
name
:
ccc-tv
engine
:
xpath
paging
:
False
...
...
searx/templates/courgette/result_templates/torrent.html
View file @
eb182df1
...
...
@@ -4,7 +4,7 @@
{% endif %}
<h3
class=
"result_title"
><a
href=
"{{ result.url }}"
{%
if
results_on_new_tab
%}
target=
"_blank"
rel=
"noopener noreferrer"
{%
else
%}
rel=
"noreferrer"
{%
endif
%}
>
{{ result.title|safe }}
</a></h3>
{% if result.content %}
<span
class=
"content"
>
{{ result.content|safe }}
</span><br
/>
{% endif %}
<span
class=
"stats"
>
{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}
</span><br
/>
{% if result.seed %}
<span
class=
"stats"
>
{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}
</span><br
/>
{% endif %}
<span>
{% if result.magnetlink %}
<a
href=
"{{ result.magnetlink }}"
class=
"magnetlink"
>
{{ _('magnet link') }}
</a>
{% endif %}
{% if result.torrentfile %}
<a
href=
"{{ result.torrentfile }}"
class=
"torrentfile"
{%
if
results_on_new_tab
%}
target=
"_blank"
rel=
"noopener noreferrer"
{%
else
%}
rel=
"noreferrer"
{%
endif
%}
>
{{ _('torrent file') }}
</a>
{% endif %}
...
...
searx/templates/legacy/result_templates/torrent.html
View file @
eb182df1
...
...
@@ -8,6 +8,6 @@
<p>
{% if result.magnetlink %}
<a
href=
"{{ result.magnetlink }}"
class=
"magnetlink"
>
{{ _('magnet link') }}
</a>
{% endif %}
{% if result.torrentfile %}
<a
href=
"{{ result.torrentfile }}"
{%
if
results_on_new_tab
%}
target=
"_blank"
rel=
"noopener noreferrer"
{%
else
%}
rel=
"noreferrer"
{%
endif
%}
class=
"torrentfile"
>
{{ _('torrent file') }}
</a>
{% endif %} -
<span
class=
"stats"
>
{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}
</span>
{% if result.seed %}
<span
class=
"stats"
>
{{ _('Seeder') }} : {{ result.seed }}, {{ _('Leecher') }} : {{ result.leech }}
</span>
{% endif %}
</p>
</div>
searx/templates/oscar/result_templates/torrent.html
View file @
eb182df1
...
...
@@ -3,7 +3,7 @@
{{ result_header(result, favicons) }}
{{ result_sub_header(result) }}
<p
class=
"result-content"
>
{{ icon('transfer') }} {{ _('Seeder') }}
<span
class=
"badge"
>
{{ result.seed }}
</span>
•
{{ _('Leecher') }}
<span
class=
"badge"
>
{{ result.leech }}
</span>
{% if result.seed %}
<p
class=
"result-content"
>
{{ icon('transfer') }} {{ _('Seeder') }}
<span
class=
"badge"
>
{{ result.seed }}
</span>
•
{{ _('Leecher') }}
<span
class=
"badge"
>
{{ result.leech }}
</span>
{% endif %}
{% if result.filesize %}
<br
/>
{{ icon('floppy-disk') }} {{ _('Filesize') }}
<span
class=
"badge"
>
{% if result.filesize
<
1024
%}{{
result
.
filesize
}}
{{
_
('
Bytes
')
}}
...
...
tests/unit/engines/test_btdigg.py
View file @
eb182df1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment