diff options
author | Alexandre Flament <alex@al-f.net> | 2021-06-04 11:09:36 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2021-06-04 16:17:20 +0200 |
commit | 8194db4e21558e7c3bca90464541f7ef09c8a5c6 (patch) | |
tree | 4276973118453b2875a5ce66a44ea5861ba9f378 | |
parent | cac6562a9e3edf8f5e9dffc7b49a730b4eadc634 (diff) | |
download | searxng-8194db4e21558e7c3bca90464541f7ef09c8a5c6.tar.gz searxng-8194db4e21558e7c3bca90464541f7ef09c8a5c6.zip |
[fix] peertube fetch supported languages
close #127
-rw-r--r-- | searx/engines/peertube.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/searx/engines/peertube.py b/searx/engines/peertube.py index 31b4b81ec..86cd04f2d 100644 --- a/searx/engines/peertube.py +++ b/searx/engines/peertube.py @@ -22,7 +22,9 @@ about = { categories = ["videos"] paging = True base_url = "https://peer.tube" -supported_languages_url = base_url + "/api/v1/videos/languages" +supported_languages_url = ( + 'https://framagit.org/framasoft/peertube/search-index/-/raw/master/client/src/views/Search.vue' +) # do search-request @@ -92,5 +94,9 @@ def response(resp): def _fetch_supported_languages(resp): - peertube_languages = list(loads(resp.text).keys()) + import re + + # https://docs.python.org/3/howto/regex.html#greedy-versus-non-greedy + videolanguages = re.search(r"videoLanguages \(\) \{(.*?)\]", resp.text, re.DOTALL) + peertube_languages = [m.group(1) for m in re.finditer(r"\{ id: '([a-z]+)', label:", videolanguages.group(1))] return peertube_languages |