Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Add SepiaSearch #2227

Merged
merged 7 commits into from Oct 3, 2020
Merged

Add SepiaSearch #2227

merged 7 commits into from Oct 3, 2020

Conversation

0xhtml
Copy link
Contributor

@0xhtml 0xhtml commented Sep 28, 2020

What does this PR do?

This PR adds the SepiaSearch engine (https://sepiasearch.org).

Why is this change important?

SepiaSearch is a PeerTube search engine that searches through multiple instances of PeerTube. It seems like a nice engine to add.

How to test this PR locally?

Test by searching e.g. !sep test.

Related issues

Closes #2217

@dalf dalf added the engine label Sep 29, 2020
@dalf
Copy link
Contributor

dalf commented Oct 3, 2020

Sorry for the delay.

LGTM.

even if it is possible to add more information:

diff --git a/searx/engines/sepiasearch.py b/searx/engines/sepiasearch.py
index f69d8043..bb2f2289 100644
--- a/searx/engines/sepiasearch.py
+++ b/searx/engines/sepiasearch.py
@@ -38,6 +38,15 @@ time_range_table = {
 }
 
 
+embedded_url = '<iframe width="540" height="304" src="{url}" frameborder="0" allowfullscreen></iframe>'
+
+
+def minute_to_hm(minute):
+    if isinstance(minute, int):
+        return "%d:%02d"%(divmod(minute, 60))
+    return None
+
+
 def request(query, params):
     params['url'] = base_url + '?' + urlencode({
         'search': query,
@@ -70,13 +79,19 @@ def response(resp):
         content = result['description']
         thumbnail = result['thumbnailUrl']
         publishedDate = parser.parse(result['publishedAt'])
+        embedded = embedded_url.format(url=result.get('embedUrl'))
+        author = result.get('account', {}).get('displayName')
+        length = minute_to_hm(result.get('duration'))
         url = result['url']
 
         results.append({'url': url,
                         'title': title,
                         'content': content,
+                        'author': author,
+                        'length': length,
                         'template': 'videos.html',
                         'publishedDate': publishedDate,
+                        'embedded': embedded,
                         'thumbnail': thumbnail})
 
     return results

@dalf dalf merged commit 53c8d94 into searx:master Oct 3, 2020
@dalf
Copy link
Contributor

dalf commented Oct 3, 2020

Thank you !

@0xhtml 0xhtml deleted the engine-sepia-search branch October 3, 2020 11:17
@TheEvilSkeleton
Copy link
Contributor

Thank you so much @0xhtml

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SepiaSearch
3 participants