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
1bed39e6
Unverified
Commit
1bed39e6
authored
Aug 01, 2019
by
Alexandre Flament
Committed by
GitHub
Aug 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1658 from dalf/video-fixes
Fix dailymotion, google_videos and youtube_noapi engines
parents
7f56c788
0c032c84
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
dailymotion.py
searx/engines/dailymotion.py
+2
-2
google_videos.py
searx/engines/google_videos.py
+11
-9
youtube_noapi.py
searx/engines/youtube_noapi.py
+9
-6
No files found.
searx/engines/dailymotion.py
View file @
1bed39e6
...
...
@@ -15,7 +15,7 @@
from
json
import
loads
from
datetime
import
datetime
from
searx.url_utils
import
urlencode
from
searx.utils
import
match_language
from
searx.utils
import
match_language
,
html_to_text
# engine dependent config
categories
=
[
'videos'
]
...
...
@@ -59,7 +59,7 @@ def response(resp):
for
res
in
search_res
[
'list'
]:
title
=
res
[
'title'
]
url
=
res
[
'url'
]
content
=
res
[
'description'
]
content
=
html_to_text
(
res
[
'description'
])
thumbnail
=
res
[
'thumbnail_360_url'
]
publishedDate
=
datetime
.
fromtimestamp
(
res
[
'created_time'
],
None
)
embedded
=
embedded_url
.
format
(
videoid
=
res
[
'id'
])
...
...
searx/engines/google_videos.py
View file @
1bed39e6
...
...
@@ -75,15 +75,17 @@ def response(resp):
# get thumbnails
script
=
str
(
dom
.
xpath
(
'//script[contains(., "_setImagesSrc")]'
)[
0
]
.
text
)
id
=
result
.
xpath
(
'.//div[@class="s"]//img/@id'
)[
0
]
thumbnails_data
=
re
.
findall
(
's=
\'
(.*?)(?:
\\\\
[a-z,1-9,
\\\\
]+
\'
|
\'
)
\
;var ii=
\
[(?:|[
\'
vidthumb
\
d+
\'
,]+)
\'
'
+
id
,
script
)
tmp
=
[]
if
len
(
thumbnails_data
)
!=
0
:
tmp
=
re
.
findall
(
'(data:image/jpeg;base64,[a-z,A-Z,0-9,/,
\
+]+)'
,
thumbnails_data
[
0
])
thumbnail
=
''
if
len
(
tmp
)
!=
0
:
thumbnail
=
tmp
[
-
1
]
ids
=
result
.
xpath
(
'.//div[@class="s"]//img/@id'
)
if
len
(
ids
)
>
0
:
thumbnails_data
=
\
re
.
findall
(
's=
\'
(.*?)(?:
\\\\
[a-z,1-9,
\\\\
]+
\'
|
\'
)
\
;var ii=
\
[(?:|[
\'
vidthumb
\
d+
\'
,]+)
\'
'
+
ids
[
0
],
script
)
tmp
=
[]
if
len
(
thumbnails_data
)
!=
0
:
tmp
=
re
.
findall
(
'(data:image/jpeg;base64,[a-z,A-Z,0-9,/,
\
+]+)'
,
thumbnails_data
[
0
])
thumbnail
=
''
if
len
(
tmp
)
!=
0
:
thumbnail
=
tmp
[
-
1
]
# append result
results
.
append
({
'url'
:
url
,
...
...
searx/engines/youtube_noapi.py
View file @
1bed39e6
...
...
@@ -67,12 +67,8 @@ def response(resp):
if
videoid
is
not
None
:
url
=
base_youtube_url
+
videoid
thumbnail
=
'https://i.ytimg.com/vi/'
+
videoid
+
'/hqdefault.jpg'
title
=
video
.
get
(
'title'
,
{})
.
get
(
'simpleText'
,
videoid
)
description_snippet
=
video
.
get
(
'descriptionSnippet'
,
{})
if
'runs'
in
description_snippet
:
content
=
reduce
(
lambda
a
,
b
:
a
+
b
.
get
(
'text'
,
''
),
description_snippet
.
get
(
'runs'
),
''
)
else
:
content
=
description_snippet
.
get
(
'simpleText'
,
''
)
title
=
get_text_from_json
(
video
.
get
(
'title'
,
{}))
content
=
get_text_from_json
(
video
.
get
(
'descriptionSnippet'
,
{}))
embedded
=
embedded_url
.
format
(
videoid
=
videoid
)
# append result
...
...
@@ -85,3 +81,10 @@ def response(resp):
# return results
return
results
def
get_text_from_json
(
element
):
if
'runs'
in
element
:
return
reduce
(
lambda
a
,
b
:
a
+
b
.
get
(
'text'
,
''
),
element
.
get
(
'runs'
),
''
)
else
:
return
element
.
get
(
'simpleText'
,
''
)
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