subssabbz, yavkanet - prevent country detection with guessit #958

pull/1014/head
josdion 5 years ago
parent 466aebd8c7
commit 51bf6964bf

@ -13,7 +13,6 @@ from guessit import guessit
from subliminal_patch.providers import Provider from subliminal_patch.providers import Provider
from subliminal_patch.subtitle import Subtitle from subliminal_patch.subtitle import Subtitle
from subliminal_patch.utils import sanitize, fix_inconsistent_naming from subliminal_patch.utils import sanitize, fix_inconsistent_naming
from subliminal.exceptions import ProviderError
from subliminal.utils import sanitize_release_group from subliminal.utils import sanitize_release_group
from subliminal.subtitle import guess_matches from subliminal.subtitle import guess_matches
from subliminal.video import Episode, Movie from subliminal.video import Episode, Movie
@ -88,14 +87,14 @@ class SubsSabBzSubtitle(Subtitle):
if video.imdb_id and self.imdb_id == video.imdb_id: if video.imdb_id and self.imdb_id == video.imdb_id:
matches.add('imdb_id') matches.add('imdb_id')
matches |= guess_matches(video, guessit(self.title, {'type': self.type})) matches |= guess_matches(video, guessit(self.title, {'type': self.type, 'allowed_countries': [None]}))
matches |= guess_matches(video, guessit(self.filename, {'type': self.type})) matches |= guess_matches(video, guessit(self.filename, {'type': self.type, 'allowed_countries': [None]}))
return matches return matches
class SubsSabBzProvider(Provider): class SubsSabBzProvider(Provider):
"""SubsSabBz Provider.""" """SubsSabBz Provider."""
languages = {Language('por', 'BR')} | {Language(l) for l in [ languages = {Language(l) for l in [
'bul', 'eng' 'bul', 'eng'
]} ]}
@ -214,11 +213,11 @@ class SubsSabBzProvider(Provider):
def process_archive_subtitle_files(self, archiveStream, language, video, link, fps, num_cds): def process_archive_subtitle_files(self, archiveStream, language, video, link, fps, num_cds):
subtitles = [] subtitles = []
type = 'episode' if isinstance(video, Episode) else 'movie' type = 'episode' if isinstance(video, Episode) else 'movie'
for file_name in archiveStream.namelist(): for file_name in sorted(archiveStream.namelist()):
if file_name.lower().endswith(('.srt', '.sub')): if file_name.lower().endswith(('.srt', '.sub')):
logger.info('Found subtitle file %r', file_name) logger.info('Found subtitle file %r', file_name)
subtitle = SubsSabBzSubtitle(language, file_name, type, video, link, fps, num_cds) subtitle = SubsSabBzSubtitle(language, file_name, type, video, link, fps, num_cds)
subtitle.content = archiveStream.read(file_name) subtitle.content = fix_line_ending(archiveStream.read(file_name))
subtitles.append(subtitle) subtitles.append(subtitle)
return subtitles return subtitles

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import from __future__ import absolute_import
import logging import logging
import re
import io import io
import os import os
from random import randint from random import randint
@ -13,7 +12,6 @@ from guessit import guessit
from subliminal_patch.providers import Provider from subliminal_patch.providers import Provider
from subliminal_patch.subtitle import Subtitle from subliminal_patch.subtitle import Subtitle
from subliminal_patch.utils import sanitize from subliminal_patch.utils import sanitize
from subliminal.exceptions import ProviderError
from subliminal.utils import sanitize_release_group from subliminal.utils import sanitize_release_group
from subliminal.subtitle import guess_matches from subliminal.subtitle import guess_matches
from subliminal.video import Episode, Movie from subliminal.video import Episode, Movie
@ -67,8 +65,8 @@ class YavkaNetSubtitle(Subtitle):
if video.year and self.year == video.year: if video.year and self.year == video.year:
matches.add('year') matches.add('year')
matches |= guess_matches(video, guessit(self.title, {'type': self.type})) matches |= guess_matches(video, guessit(self.title, {'type': self.type, 'allowed_countries': [None]}))
matches |= guess_matches(video, guessit(self.filename, {'type': self.type})) matches |= guess_matches(video, guessit(self.filename, {'type': self.type, 'allowed_countries': [None]}))
return matches return matches
@ -183,7 +181,7 @@ class YavkaNetProvider(Provider):
if file_name.lower().endswith(('.srt', '.sub')): if file_name.lower().endswith(('.srt', '.sub')):
logger.info('Found subtitle file %r', file_name) logger.info('Found subtitle file %r', file_name)
subtitle = YavkaNetSubtitle(language, file_name, type, video, link, fps) subtitle = YavkaNetSubtitle(language, file_name, type, video, link, fps)
subtitle.content = archiveStream.read(file_name) subtitle.content = fix_line_ending(archiveStream.read(file_name))
subtitles.append(subtitle) subtitles.append(subtitle)
return subtitles return subtitles

Loading…
Cancel
Save