Merge pull request #1146 from vitiko98/tusubtitulo-english

English support for TuSubtitulo and minor fixes with Sucha and Subdivx
pull/1148/head
morpheus65535 4 years ago committed by GitHub
commit 9babc4f6c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,6 +86,8 @@ class SubdivxSubtitle(Subtitle):
elif video_codecs[0] == "h.265":
video_codecs.append("h265")
video_codecs.append("x265")
elif video_codecs[0] == "divx":
video_codecs.append("divx")
for vc in video_codecs:
if vc in self.description:
matches.add('video_codec')
@ -118,9 +120,15 @@ class SubdivxSubtitlesProvider(Provider):
if isinstance(video, Episode):
query = "{} S{:02d}E{:02d}".format(video.series, video.season, video.episode)
else:
# Subdvix has problems searching foreign movies if the year is
# appended. For example: if we search "Memories of Murder 2003",
# Subdix won't return any results; but if we search "Memories of
# Murder", it will. That's because in Subdvix foreign titles have
# the year after the original title ("Salinui chueok (2003) aka
# Memories of Murder").
# A proper solution would be filtering results with the year in
# _parse_subtitles_page.
query = video.title
if video.year:
query += ' {:4d}'.format(video.year)
params = {
'q': query, # search string
@ -145,7 +153,7 @@ class SubdivxSubtitlesProvider(Provider):
subtitles += page_subtitles
if len(page_subtitles) < 20:
if len(page_subtitles) < 100:
break # this is the last page
params['pg'] += 1 # search next page
@ -188,6 +196,11 @@ class SubdivxSubtitlesProvider(Provider):
# title
title = title_soup.find("a").text.replace("Subtitulos de ", "")
# filter by year
if video.year and str(video.year) not in title:
continue
page_link = title_soup.find("a")["href"]
# description

@ -1,19 +1,18 @@
# -*- coding: utf-8 -*-
import io
import logging
import os
import io
import rarfile
import zipfile
import rarfile
from requests import Session
from subzero.language import Language
from subliminal import Movie, Episode
from subliminal_patch.exceptions import APIThrottled
from subliminal import Episode, Movie
from subliminal.exceptions import ServiceUnavailable
from subliminal_patch.subtitle import Subtitle
from subliminal.subtitle import fix_line_ending, SUBTITLE_EXTENSIONS
from subliminal.subtitle import SUBTITLE_EXTENSIONS, fix_line_ending
from subliminal_patch.exceptions import APIThrottled
from subliminal_patch.providers import Provider
from subliminal_patch.subtitle import Subtitle
from subzero.language import Language
logger = logging.getLogger(__name__)
@ -26,13 +25,21 @@ class SuchaSubtitle(Subtitle):
hash_verifiable = False
def __init__(
self, language, page_link, filename, download_link, hearing_impaired, matches
self,
language,
page_link,
filename,
guessit_dict,
download_link,
hearing_impaired,
matches,
):
super(SuchaSubtitle, self).__init__(
language, hearing_impaired=hearing_impaired, page_link=page_url
)
self.download_link = download_link
self.referer = page_link
self.guessit = guessit_dict
self.language = language
self.release_info = filename
self.filename = filename
@ -43,23 +50,33 @@ class SuchaSubtitle(Subtitle):
return self.download_link
def get_matches(self, video):
if video.resolution and video.resolution.lower() in self.release_info.lower():
self.found_matches.add("resolution")
if (
video.release_group
and str(video.release_group).lower() in self.filename.lower()
):
self.found_matches.add("release_group")
if video.source and video.source.lower() in self.release_info.lower():
if video.source and video.source.lower() in self.guessit["source"].lower():
self.found_matches.add("source")
if video.video_codec:
if video.video_codec == "H.264" and "x264" in self.release_info.lower():
self.found_matches.add("video_codec")
elif video.video_codec == "H.265" and "x265" in self.release_info.lower():
self.found_matches.add("video_codec")
elif video.video_codec.lower() in self.release_info.lower():
self.found_matches.add("video_codec")
if video.audio_codec:
if video.audio_codec.lower().replace(" ", ".") in self.release_info.lower():
self.found_matches.add("audio_codec")
if (
video.resolution
and video.resolution.lower() in self.guessit["resolution"].lower()
):
self.found_matches.add("resolution")
if (
video.audio_codec
and video.audio_codec.lower() in self.guessit["audio_codec"].lower()
):
self.found_matches.add("audio_codec")
if (
video.video_codec
and video.video_codec.lower() in self.guessit["video_codec"].lower()
):
self.found_matches.add("video_codec")
return self.found_matches
@ -115,6 +132,7 @@ class SuchaProvider(Provider):
if q["query"].lower() in i["title"].lower():
matches.add("title")
matches.add("series")
matches.add("imdb_id")
matches.add("season")
matches.add("episode")
matches.add("year")
@ -122,11 +140,24 @@ class SuchaProvider(Provider):
matches.add("year")
if imdb_id:
matches.add("imdb_id")
# We'll add release group info (if found) to the pseudo filename
# in order to show it in the manual search
filename = i["pseudo_file"]
if (
video.release_group
and str(video.release_group).lower() in i["original_description"]
):
filename = i["pseudo_file"].replace(
".es.srt", "-" + str(video.release_group) + ".es.srt"
)
subtitles.append(
SuchaSubtitle(
language,
i["referer"],
i["pseudo_file"],
filename,
i["guessit"],
i["download_url"],
i["hearing_impaired"],
matches,

@ -21,6 +21,7 @@ BASE = "https://www.tusubtitulo.com/series.php?/"
class TuSubtituloSubtitle(Subtitle):
provider_name = "tusubtitulo"
hash_verifiable = False
def __init__(self, language, filename, download_link, page_link, matches):
super(TuSubtituloSubtitle, self).__init__(
@ -52,9 +53,16 @@ class TuSubtituloSubtitle(Subtitle):
elif video.video_codec.lower() in self.release_info.lower():
self.found_matches.add("video_codec")
if (
video.release_group
and video.release_group.lower() in self.release_info.lower()
):
self.found_matches.add("release_group")
if video.audio_codec:
if video.audio_codec.lower().replace(" ", ".") in self.release_info.lower():
self.found_matches.add("audio_codec")
return self.found_matches
@ -62,8 +70,7 @@ class TuSubtituloProvider(Provider):
"""TuSubtitulo.com Provider"""
BASE = "https://www.tusubtitulo.com/series.php?/"
languages = {Language.fromalpha2(l) for l in ["es"]}
language_list = list(languages)
languages = {Language.fromietf(lang) for lang in ["en", "es"]}
logger.debug(languages)
video_types = (Episode,)
@ -146,7 +153,13 @@ class TuSubtituloProvider(Provider):
try:
content = tables[tr + inc].find_all("td")
language = content[4].text
completed = content[5]
if "eng" in language.lower():
language = "en"
elif "esp" in language.lower():
language = "es"
else:
language = None
completed = True if not "%" in content[5].text else False
url = content[6].find_all("a")[0].get("href")
sub_id = parse.parse_qs(parse.urlparse(url).query)["id"][0]
lang_id = parse.parse_qs(parse.urlparse(url).query)["lang"][0]
@ -158,12 +171,13 @@ class TuSubtituloProvider(Provider):
lang_id, sub_id, version_
)
)
if "esp" in language.lower():
if language and completed:
season_subs.append(
{
"episode_id": sub_id,
"metadata": source_var,
"download_url": download_url,
"language": language,
}
)
inc += 1
@ -180,6 +194,7 @@ class TuSubtituloProvider(Provider):
"episode_url": i["episode_url"],
"metadata": t["metadata"],
"download_url": t["download_url"],
"language": t["language"],
}
)
return final_list
@ -206,7 +221,6 @@ class TuSubtituloProvider(Provider):
logger.debug("Episode not found")
def query(self, languages, video):
language = self.language_list[0]
query = "{} {} {}".format(video.series, video.season, video.episode)
logger.debug("Searching subtitles: {}".format(query))
results = self.search(video.series, str(video.season), str(video.episode))
@ -223,7 +237,7 @@ class TuSubtituloProvider(Provider):
matches.add("year")
subtitles.append(
TuSubtituloSubtitle(
language,
Language.fromietf(i["language"]),
i["metadata"],
i["download_url"],
i["episode_url"],

@ -516,7 +516,7 @@
<div class="form-group col-sm-8">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input provider" id="subtitulamostv">
<span class="custom-control-label">Spanish subtitles provider.</span>
<span class="custom-control-label">Spanish Subtitles Provider.</span>
</label>
</div>
</div>
@ -528,7 +528,7 @@
<div class="form-group col-sm-8">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input provider" id="sucha">
<span class="custom-control-label">Spanish subtitles provider.</span>
<span class="custom-control-label">Spanish Subtitles Provider.</span>
</label>
</div>
</div>
@ -596,7 +596,7 @@
<div class="form-group col-sm-8">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input provider" id="tusubtitulo">
<span class="custom-control-label">Spanish subtitles provider.</span>
<span class="custom-control-label">Spanish/English Subtitles Provider for TV Shows.</span>
</label>
</div>
</div>

Loading…
Cancel
Save