1
0
mirror of https://git.sr.ht/~cadence/NewLeaf synced 2024-11-24 16:37:29 +00:00

Remove origin from caption URL

This commit is contained in:
Cadence Ember 2021-01-20 23:00:26 +13:00
parent 6c2b67fb6f
commit b454ebd6e5
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17

View File

@ -2,7 +2,7 @@ import configuration
import datetime import datetime
import re import re
import time import time
from urllib.parse import urlparse, parse_qs, quote_plus from urllib.parse import urlparse, urlencode, parse_qs
def length_text_to_seconds(text): def length_text_to_seconds(text):
s = text.split(":") s = text.split(":")
@ -214,12 +214,12 @@ def get_language_label_from_url(url_string):
return label return label
def get_subtitle_api_url(id, label, language_code): def get_subtitle_api_url(id, label, language_code):
subtitle_api_url = "{}/api/v1/captions/{}?".format(configuration.website_origin, id) subtitle_api_url = "/api/v1/captions/{}?".format(id)
params = {}
if label == "": if label:
label = language_code params["label"] = label
subtitle_api_url += "lang=" + quote_plus(language_code)
else: else:
subtitle_api_url += "label=" + quote_plus(label) params["lang"] = language_code
return subtitle_api_url return subtitle_api_url + urlencode(params)