summaryrefslogtreecommitdiff
path: root/searx/engines/peertube.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2023-01-29 09:59:44 +0000
committerAlexandre Flament <alex@al-f.net>2023-01-29 10:01:54 +0000
commit8256de2fe85a8b11497289d8e6884710838b20cf (patch)
treec80fe42b2dd0a90dfc623b93421abbf9d11a703a /searx/engines/peertube.py
parent6b71721ce80948d72ad656620a35507b73fc55d4 (diff)
downloadsearxng-8256de2fe85a8b11497289d8e6884710838b20cf.tar.gz
searxng-8256de2fe85a8b11497289d8e6884710838b20cf.zip
peertube engine: update _fetch_supported_languages
There is now an API to get the list of supported languages https://docs.joinpeertube.org/api-rest-reference.html#tag/Video/operation/getLanguages
Diffstat (limited to 'searx/engines/peertube.py')
-rw-r--r--searx/engines/peertube.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py
index 089775694..345c2f991 100644
--- a/searx/engines/peertube.py
+++ b/searx/engines/peertube.py
@@ -22,9 +22,7 @@ about = {
categories = ["videos"]
paging = True
base_url = "https://peer.tube"
-supported_languages_url = (
- 'https://framagit.org/framasoft/peertube/search-index/-/raw/master/client/src/views/Search.vue'
-)
+supported_languages_url = 'https://peer.tube/api/v1/videos/languages'
# do search-request
@@ -84,9 +82,6 @@ def response(resp):
def _fetch_supported_languages(resp):
- import re
-
- # https://docs.python.org/3/howto/regex.html#greedy-versus-non-greedy
- videolanguages = re.search(r"videoLanguages \(\)[^\n]+(.*?)\]", resp.text, re.DOTALL)
- peertube_languages = [m.group(1) for m in re.finditer(r"\{ id: '([a-z]+)', label:", videolanguages.group(1))]
+ videolanguages = resp.json()
+ peertube_languages = list(videolanguages.keys())
return peertube_languages