diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 88e948628..9d1d37d2f 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -16,7 +16,7 @@ import subliminal import subliminal_patch from datetime import datetime, timedelta from subzero.language import Language -from subzero.video import parse_video +from subzero.video import parse_video, refine_video from subliminal import region, score as subliminal_scores, \ list_subtitles from subliminal_patch.core import SZAsyncProviderPool, download_best_subtitles, save_subtitles, download_subtitles @@ -58,12 +58,14 @@ def get_video(path, title, sceneName, use_scenename, providers=None, media_type= # use the sceneName but keep the folder structure for better guessing path = os.path.join(os.path.dirname(path), sceneName + os.path.splitext(path)[1]) dont_use_actual_file = True + try: if providers: video = parse_video(path, hints=hints, providers=providers, dry_run=dont_use_actual_file) video.used_scene_name = dont_use_actual_file video.original_name = original_name video.original_path = original_path + refine_video(video) return video else: logging.info("BAZARR All providers are throttled") diff --git a/bazarr/init.py b/bazarr/init.py index 44f688a55..927eb98c0 100644 --- a/bazarr/init.py +++ b/bazarr/init.py @@ -153,17 +153,18 @@ def init_binaries(): unrar_exe = None exe = None - if platform.system() == "Windows": # Windows - unrar_exe = os.path.abspath(os.path.join(binaries_dir, "Windows", "i386", "UnRAR", "UnRAR.exe")) - elif platform.system() == "Darwin": # MacOSX - unrar_exe = os.path.abspath(os.path.join(binaries_dir, "MacOSX", "i386", "UnRAR", "unrar")) + if os.path.isfile("unrar"): + unrar_exe = "unrar" + else: + if platform.system() == "Windows": # Windows + unrar_exe = os.path.abspath(os.path.join(binaries_dir, "Windows", "i386", "UnRAR", "UnRAR.exe")) - elif platform.system() == "Linux": # Linux - unrar_exe = os.path.abspath(os.path.join(binaries_dir, "Linux", platform.machine(), "UnRAR", "unrar")) + elif platform.system() == "Darwin": # MacOSX + unrar_exe = os.path.abspath(os.path.join(binaries_dir, "MacOSX", "i386", "UnRAR", "unrar")) - else: - unrar_exe = "unrar" + elif platform.system() == "Linux": # Linux + unrar_exe = os.path.abspath(os.path.join(binaries_dir, "Linux", platform.machine(), "UnRAR", "unrar")) if unrar_exe and os.path.isfile(unrar_exe): exe = unrar_exe diff --git a/bin/Linux/aarch64/UnRAR/unrar b/bin/Linux/aarch64/UnRAR/unrar old mode 100644 new mode 100755 diff --git a/bin/Linux/armv5tel/UnRAR/unrar b/bin/Linux/armv5tel/UnRAR/unrar old mode 100644 new mode 100755 diff --git a/bin/Linux/i386/UnRAR/unrar b/bin/Linux/i386/UnRAR/unrar old mode 100644 new mode 100755 diff --git a/bin/Linux/x86_64/UnRAR/unrar b/bin/Linux/x86_64/UnRAR/unrar old mode 100644 new mode 100755 diff --git a/bin/MacOSX/i386/UnRAR/unrar b/bin/MacOSX/i386/UnRAR/unrar old mode 100644 new mode 100755 diff --git a/libs/subliminal_patch/core.py b/libs/subliminal_patch/core.py index 9fe8587d9..e46ff617d 100644 --- a/libs/subliminal_patch/core.py +++ b/libs/subliminal_patch/core.py @@ -565,7 +565,7 @@ def _search_external_subtitles(path, languages=None, only_one=False, scandir_gen p = entry.name # keep only valid subtitle filenames - if not p.startswith(fileroot) or not p.endswith(SUBTITLE_EXTENSIONS): + if not p.lower().startswith(fileroot.lower()) or not p.endswith(SUBTITLE_EXTENSIONS): continue p_root, p_ext = os.path.splitext(p) diff --git a/libs/subliminal_patch/providers/titlovi.py b/libs/subliminal_patch/providers/titlovi.py index 8e2a31c65..8639cf6d9 100644 --- a/libs/subliminal_patch/providers/titlovi.py +++ b/libs/subliminal_patch/providers/titlovi.py @@ -4,6 +4,7 @@ import io import logging import math import re +from random import randint import rarfile @@ -24,6 +25,7 @@ from subliminal.subtitle import guess_matches from subliminal.video import Episode, Movie from subliminal.subtitle import fix_line_ending from subzero.language import Language +from .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST # parsing regex definitions title_re = re.compile(r'(?P(?:.+(?= [Aa][Kk][Aa] ))|.+)(?:(?:.+)(?P<altitle>(?<= [Aa][Kk][Aa] ).+))?') @@ -134,8 +136,7 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin): def initialize(self): self.session = Session() - self.session.headers['User-Agent'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3)' \ - 'Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)' + self.session.headers['User-Agent'] = AGENT_LIST[randint(0, len(AGENT_LIST) - 1)] logger.debug('User-Agent set to %s', self.session.headers['User-Agent']) self.session.headers['Referer'] = self.server_url logger.debug('Referer set to %s', self.session.headers['Referer']) @@ -223,7 +224,7 @@ class TitloviProvider(Provider, ProviderSubtitleArchiveMixin): if match: try: # decode language - lang = Language.fromtitlovi(match.group('lang')+match.group('script')) + lang = Language.fromtitlovi(match.group('lang') + match.group('script')) except ValueError: continue diff --git a/libs/subzero/language.py b/libs/subzero/language.py index 8d096e19d..0a3a5e775 100644 --- a/libs/subzero/language.py +++ b/libs/subzero/language.py @@ -8,6 +8,25 @@ repl_map = { "dk": "da", "nld": "nl", "english": "en", + "alb": "sq", + "arm": "hy", + "baq": "eu", + "bur": "my", + "chi": "zh", + "cze": "cs", + "dut": "nl", + "fre": "fr", + "geo": "ka", + "ger": "de", + "gre": "el", + "ice": "is", + "mac": "mk", + "mao": "mi", + "may": "ms", + "per": "fa", + "rum": "ro", + "slo": "sk", + "tib": "bo", } diff --git a/views/episodes.tpl b/views/episodes.tpl index 720ae0d0f..d0d8cb409 100644 --- a/views/episodes.tpl +++ b/views/episodes.tpl @@ -472,7 +472,7 @@ hi: hi, sonarrSeriesId: sonarrSeriesId, sonarrEpisodeId: sonarrEpisodeId, - title: '{{!details[0].replace("'", "\\'")}}' + title: '{{!details[0].replace("'", "\'")}}' }; $('#search_result').DataTable( { @@ -482,12 +482,13 @@ zeroRecords: 'No subtitles found for this episode' }, paging: true, + lengthChange: false, + pageLength: 5, searching: false, ordering: false, processing: false, serverSide: false, - lengthMenu: [ [ 5, 10, 25, 50, 100 , -1 ] , [ 5, 10, 25, 50, 100, "All" ] ], - ajax: { + ajax: { url: '{{base_url}}manual_search', type: 'POST', data: values diff --git a/views/movie.tpl b/views/movie.tpl index 713af411c..560c7fc87 100644 --- a/views/movie.tpl +++ b/views/movie.tpl @@ -417,7 +417,7 @@ language: language, hi: hi, radarrId: radarrId, - title: '{{!details[0].replace("'", "\\'")}}' + title: '{{!details[0].replace("'", "\'")}}' }; $('#search_result').DataTable( { @@ -427,12 +427,13 @@ zeroRecords: 'No subtitles found for this movie' }, paging: true, + lengthChange: false, + pageLength: 5, searching: false, ordering: false, processing: false, serverSide: false, - lengthMenu: [ [ 5, 10, 25, 50, 100 , -1 ] , [ 5, 10, 25, 50, 100, "All" ] ], - ajax: { + ajax: { url: '{{base_url}}manual_search_movie', type: 'POST', data: values diff --git a/views/settings.tpl b/views/settings.tpl index 48c7488b0..7eeaf37f3 100644 --- a/views/settings.tpl +++ b/views/settings.tpl @@ -1028,7 +1028,7 @@ <div class="two wide column"> <div class='field'> <div class="ui input"> - <input name="settings_general_minimum_score" type="number" min="0" max="100" step="5" onkeydown="return false" value="{{settings.general.minimum_score}}"> + <input name="settings_general_minimum_score" type="number" min="0" max="100" step="1" onkeydown="return false" value="{{settings.general.minimum_score}}"> </div> </div> </div> @@ -1048,7 +1048,7 @@ <div class="two wide column"> <div class='field'> <div class="ui input"> - <input name="settings_general_minimum_score_movies" type="number" min="0" max="100" step="5" onkeydown="return false" value="{{settings.general.minimum_score_movie}}"> + <input name="settings_general_minimum_score_movies" type="number" min="0" max="100" step="1" onkeydown="return false" value="{{settings.general.minimum_score_movie}}"> </div> </div> </div> diff --git a/views/wantedmovies.tpl b/views/wantedmovies.tpl index 80b3653ee..0537f7719 100644 --- a/views/wantedmovies.tpl +++ b/views/wantedmovies.tpl @@ -86,7 +86,7 @@ %end %end %else: - <a data-moviePath="{{row[3]}}" data-sceneName="{{row[5]}}" data-language="{{alpha3_from_alpha2(str(language))}}" data-hi="{{row[4]}}" data-radarrId={{row[2]}} class="get_subtitle ui tiny label"> + <a data-moviePath="{{row[3]}}" data-sceneName="{{row[5]}}" data-language="{{alpha3_from_alpha2(str(language))}}" data-hi="{{row[4]}}" data-radarrId="{{row[2]}}" data-title="{{row[0].replace("'", "\'")}}" class="get_subtitle ui tiny label"> {{language}} <i style="margin-left:3px; margin-right:0" class="search icon"></i> </a> @@ -119,12 +119,12 @@ backward icon"></i> {{page}} / {{max_page}} <i class="\\ - %if int(page) == int(max_page): + %if int(page) >= int(max_page): disabled\\ %end forward icon"></i> <i class="\\ - %if int(page) == int(max_page): + %if int(page) >= int(max_page): disabled\\ %end fast forward icon"></i> @@ -168,7 +168,7 @@ language: $(this).attr("data-language"), hi: $(this).attr("data-hi"), radarrId: $(this).attr("data-radarrId"), - title: '{{!row[0].replace("'", "\\'")}}' + title: $(this).attr("data-title") }; $('#loader_text').text("Downloading subtitles..."); $('#loader').addClass('active'); diff --git a/views/wantedseries.tpl b/views/wantedseries.tpl index 8897d0497..4e80152f7 100644 --- a/views/wantedseries.tpl +++ b/views/wantedseries.tpl @@ -93,7 +93,7 @@ %end %end %else: - <a data-episodePath="{{row[5]}}" data-sceneName="{{row[8]}}" data-language="{{alpha3_from_alpha2(str(language))}}" data-hi="{{row[6]}}" data-sonarrSeriesId={{row[4]}} data-sonarrEpisodeId={{row[7]}} class="get_subtitle ui tiny label"> + <a data-episodePath="{{row[5]}}" data-sceneName="{{row[8]}}" data-language="{{alpha3_from_alpha2(str(language))}}" data-hi="{{row[6]}}" data-sonarrSeriesId={{row[4]}} data-sonarrEpisodeId={{row[7]}} data-title="{{row[0].replace("'", "\'")}}" class="get_subtitle ui tiny label"> {{language}} <i style="margin-left:3px; margin-right:0" class="search icon"></i> </a> @@ -126,12 +126,12 @@ backward icon"></i> {{page}} / {{max_page}} <i class="\\ - %if int(page) == int(max_page): + %if int(page) >= int(max_page): disabled\\ %end forward icon"></i> <i class="\\ - %if int(page) == int(max_page): + %if int(page) >= int(max_page): disabled\\ %end fast forward icon"></i> @@ -176,7 +176,7 @@ hi: $(this).attr("data-hi"), sonarrSeriesId: $(this).attr("data-sonarrSeriesId"), sonarrEpisodeId: $(this).attr("data-sonarrEpisodeId"), - title: '{{!row[0].replace("'", "\\'")}}' + title: $(this).attr("data-title") }; $('#loader_text').text("Downloading subtitles..."); $('#loader').addClass('active');