|
|
|
@ -265,43 +265,43 @@ class MovieQuerySet(models.QuerySet):
|
|
|
|
|
else:
|
|
|
|
|
return f"{num}{sym}"
|
|
|
|
|
|
|
|
|
|
def get_sub_lang(self, key):
|
|
|
|
|
"""
|
|
|
|
|
Obtiene los lenguajes de los subtítulos en diversas nomenclaturas.
|
|
|
|
|
# ~ def get_sub_lang(self, key):
|
|
|
|
|
# ~ """
|
|
|
|
|
# ~ Obtiene los lenguajes de los subtítulos en diversas nomenclaturas.
|
|
|
|
|
|
|
|
|
|
La llave está en ISO-639-2 o ISO-639-3.
|
|
|
|
|
Cfr. https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
|
|
|
|
https://en.wikipedia.org/wiki/ISO_639-2
|
|
|
|
|
OJO: hay más variantes de Tarahumara y de Mixteco
|
|
|
|
|
"""
|
|
|
|
|
langs = {
|
|
|
|
|
"spa": {"iso639_1": "es", "label": "Español"},
|
|
|
|
|
"eng": {"iso639_1": "en", "label": "Inglés"},
|
|
|
|
|
"fra": {"iso639_1": "fr", "label": "Francés"},
|
|
|
|
|
"por": {"iso639_1": "pt", "label": "Portugués"},
|
|
|
|
|
"rum": {"iso639_1": "ro", "label": "Rumano"},
|
|
|
|
|
"cat": {"iso639_1": "ca", "label": "Catalán"},
|
|
|
|
|
"glg": {"iso639_1": "gl", "label": "Gallego"},
|
|
|
|
|
"grn": {"iso639_1": "gn", "label": "Guaraní"},
|
|
|
|
|
"gug": {"iso639_1": "gn", "label": "Guaraní"},
|
|
|
|
|
"nah": {"iso639_1": "!!", "label": "Náhuatl"},
|
|
|
|
|
"myn": {"iso639_1": "!!", "label": "Maya"},
|
|
|
|
|
"zap": {"iso639_1": "!!", "label": "Zapoteco"},
|
|
|
|
|
"oto": {"iso639_1": "!!", "label": "Otomí"},
|
|
|
|
|
"tar": {"iso639_1": "!!", "label": "Tarahumara"},
|
|
|
|
|
"mix": {"iso639_1": "!!", "label": "Mixteco"},
|
|
|
|
|
"apa": {"iso639_1": "!!", "label": "Apache"},
|
|
|
|
|
"rus": {"iso639_1": "ru", "label": "Ruso"},
|
|
|
|
|
"deu": {"iso639_1": "de", "label": "Alemán"},
|
|
|
|
|
"ger": {"iso639_1": "de", "label": "Alemán"},
|
|
|
|
|
"chi": {"iso639_1": "zh", "label": "Chino"},
|
|
|
|
|
"zho": {"iso639_1": "zh", "label": "Chino"},
|
|
|
|
|
}
|
|
|
|
|
if key in langs:
|
|
|
|
|
lang = langs[key]
|
|
|
|
|
lang["suffix"] = key
|
|
|
|
|
return lang
|
|
|
|
|
return {"suffix": key, "iso639_1": "!!", "label": key}
|
|
|
|
|
# ~ La llave está en ISO-639-2 o ISO-639-3.
|
|
|
|
|
# ~ Cfr. https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
|
|
|
|
# ~ https://en.wikipedia.org/wiki/ISO_639-2
|
|
|
|
|
# ~ OJO: hay más variantes de Tarahumara y de Mixteco
|
|
|
|
|
# ~ """
|
|
|
|
|
# ~ langs = {
|
|
|
|
|
# ~ "spa": {"iso639_1": "es", "label": "Español"},
|
|
|
|
|
# ~ "eng": {"iso639_1": "en", "label": "Inglés"},
|
|
|
|
|
# ~ "fra": {"iso639_1": "fr", "label": "Francés"},
|
|
|
|
|
# ~ "por": {"iso639_1": "pt", "label": "Portugués"},
|
|
|
|
|
# ~ "rum": {"iso639_1": "ro", "label": "Rumano"},
|
|
|
|
|
# ~ "cat": {"iso639_1": "ca", "label": "Catalán"},
|
|
|
|
|
# ~ "glg": {"iso639_1": "gl", "label": "Gallego"},
|
|
|
|
|
# ~ "grn": {"iso639_1": "gn", "label": "Guaraní"},
|
|
|
|
|
# ~ "gug": {"iso639_1": "gn", "label": "Guaraní"},
|
|
|
|
|
# ~ "nah": {"iso639_1": "!!", "label": "Náhuatl"},
|
|
|
|
|
# ~ "myn": {"iso639_1": "!!", "label": "Maya"},
|
|
|
|
|
# ~ "zap": {"iso639_1": "!!", "label": "Zapoteco"},
|
|
|
|
|
# ~ "oto": {"iso639_1": "!!", "label": "Otomí"},
|
|
|
|
|
# ~ "tar": {"iso639_1": "!!", "label": "Tarahumara"},
|
|
|
|
|
# ~ "mix": {"iso639_1": "!!", "label": "Mixteco"},
|
|
|
|
|
# ~ "apa": {"iso639_1": "!!", "label": "Apache"},
|
|
|
|
|
# ~ "rus": {"iso639_1": "ru", "label": "Ruso"},
|
|
|
|
|
# ~ "deu": {"iso639_1": "de", "label": "Alemán"},
|
|
|
|
|
# ~ "ger": {"iso639_1": "de", "label": "Alemán"},
|
|
|
|
|
# ~ "chi": {"iso639_1": "zh", "label": "Chino"},
|
|
|
|
|
# ~ "zho": {"iso639_1": "zh", "label": "Chino"},
|
|
|
|
|
# ~ }
|
|
|
|
|
# ~ if key in langs:
|
|
|
|
|
# ~ lang = langs[key]
|
|
|
|
|
# ~ lang["suffix"] = key
|
|
|
|
|
# ~ return lang
|
|
|
|
|
# ~ return {"suffix": key, "iso639_1": "!!", "label": key}
|
|
|
|
|
|
|
|
|
|
def get_subs(self, id):
|
|
|
|
|
"""
|
|
|
|
@ -309,17 +309,25 @@ class MovieQuerySet(models.QuerySet):
|
|
|
|
|
|
|
|
|
|
TODO: en la restructuración de la DB no debería hacer requests.
|
|
|
|
|
"""
|
|
|
|
|
file = self._fix_path_movie(Movie.objects.get(pk=id).file_name)
|
|
|
|
|
file = Path(re.sub(r"^https?://", "", file))
|
|
|
|
|
page = requests.get(f"https://{file.parent}").text
|
|
|
|
|
soup = BeautifulSoup(page, 'html.parser')
|
|
|
|
|
file_name = Movie.objects.get(pk=id).file_name
|
|
|
|
|
if not file_name:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
letter = file_name[0].upper()
|
|
|
|
|
if letter.isdigit():
|
|
|
|
|
letter = "0"
|
|
|
|
|
|
|
|
|
|
url_base = f"{settings.URL_CDN}/{letter}"
|
|
|
|
|
base_name = Path(file_name).stem
|
|
|
|
|
|
|
|
|
|
subs = []
|
|
|
|
|
for node in soup.find_all("a"):
|
|
|
|
|
if node.get("href").endswith("vtt"):
|
|
|
|
|
url = node.get("href")
|
|
|
|
|
lang = self.get_sub_lang(Path(url).suffixes[0][1:])
|
|
|
|
|
lang["path"] = "https://" + str(file.parent / url)
|
|
|
|
|
subs.append(lang)
|
|
|
|
|
for k, v in settings.LANG_SUBTITLES.items():
|
|
|
|
|
url_sub = f'{settings.URL_BASE}{url_base}/{base_name}.{k}.vtt'
|
|
|
|
|
response = requests.get(url_sub)
|
|
|
|
|
if response.status_code==200:
|
|
|
|
|
v['path'] = url_sub
|
|
|
|
|
subs.append(v)
|
|
|
|
|
|
|
|
|
|
return subs
|
|
|
|
|
|
|
|
|
|
def get_wiki(self, movie, again=True):
|
|
|
|
|