Updates vendored subliminal to 2.1.0

Updates rarfile to 3.1
Updates stevedore to 3.5.0
Updates appdirs to 1.4.4
Updates click to 8.1.3
Updates decorator to 5.1.1
Updates dogpile.cache to 1.1.8
Updates pbr to 5.11.0
Updates pysrt to 1.1.2
Updates pytz to 2022.6
Adds importlib-metadata version 3.1.1
Adds typing-extensions version 4.1.1
Adds zipp version 3.11.0
This commit is contained in:
Labrys of Knossos 2022-11-29 00:08:39 -05:00
commit f05b09f349
694 changed files with 16621 additions and 11056 deletions

View file

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
import logging
from ..extensions import provider_manager, default_providers
from ..utils import hash_napiprojekt, hash_opensubtitles, hash_shooter, hash_thesubdb
logger = logging.getLogger(__name__)
hash_functions = {
'napiprojekt': hash_napiprojekt,
'opensubtitles': hash_opensubtitles,
'opensubtitlesvip': hash_opensubtitles,
'shooter': hash_shooter,
'thesubdb': hash_thesubdb
}
def refine(video, providers=None, languages=None, **kwargs):
"""Refine a video computing required hashes for the given providers.
The following :class:`~subliminal.video.Video` attribute can be found:
* :attr:`~subliminal.video.Video.hashes`
"""
if video.size <= 10485760:
logger.warning('Size is lower than 10MB: hashes not computed')
return
logger.debug('Computing hashes for %r', video.name)
for name in providers or default_providers:
provider = provider_manager[name].plugin
if name not in hash_functions:
continue
if not provider.check_types(video):
continue
if languages and not provider.check_languages(languages):
continue
video.hashes[name] = hash_functions[name](video.name)
logger.debug('Computed hashes %r', video.hashes)

View file

@ -45,13 +45,13 @@ def refine(video, embedded_subtitles=True, **kwargs):
# video codec
if video_track.codec_id == 'V_MPEG4/ISO/AVC':
video.video_codec = 'h264'
video.video_codec = 'H.264'
logger.debug('Found video_codec %s', video.video_codec)
elif video_track.codec_id == 'V_MPEG4/ISO/SP':
video.video_codec = 'DivX'
logger.debug('Found video_codec %s', video.video_codec)
elif video_track.codec_id == 'V_MPEG4/ISO/ASP':
video.video_codec = 'XviD'
video.video_codec = 'Xvid'
logger.debug('Found video_codec %s', video.video_codec)
else:
logger.warning('MKV has no video track')
@ -61,7 +61,7 @@ def refine(video, embedded_subtitles=True, **kwargs):
audio_track = mkv.audio_tracks[0]
# audio codec
if audio_track.codec_id == 'A_AC3':
video.audio_codec = 'AC3'
video.audio_codec = 'Dolby Digital'
logger.debug('Found audio_codec %s', video.audio_codec)
elif audio_track.codec_id == 'A_DTS':
video.audio_codec = 'DTS'

View file

@ -7,7 +7,6 @@ import requests
from .. import __short_version__
from ..cache import REFINER_EXPIRATION_TIME, region
from ..video import Episode, Movie
from ..utils import sanitize
logger = logging.getLogger(__name__)
@ -68,7 +67,8 @@ class OMDBClient(object):
return j
omdb_client = OMDBClient(headers={'User-Agent': 'Subliminal/%s' % __short_version__})
user_agent = 'Subliminal/%s' % __short_version__
omdb_client = OMDBClient(headers={'User-Agent': user_agent})
@region.cache_on_arguments(expiration_time=REFINER_EXPIRATION_TIME)
@ -89,7 +89,7 @@ def search(title, type, year):
return all_results
def refine(video, **kwargs):
def refine(video, apikey=None, **kwargs):
"""Refine a video by searching `OMDb API <http://omdbapi.com/>`_.
Several :class:`~subliminal.video.Episode` attributes can be found:
@ -105,6 +105,12 @@ def refine(video, **kwargs):
* :attr:`~subliminal.video.Video.imdb_id`
"""
if not apikey:
logger.warning('No apikey. Skipping omdb refiner.')
return
omdb_client.session.params['apikey'] = apikey
if isinstance(video, Episode):
# exit if the information is complete
if video.series_imdb_id:
@ -119,7 +125,7 @@ def refine(video, **kwargs):
logger.debug('Found %d results', len(results))
# filter the results
results = [r for r in results if sanitize(r['Title']) == sanitize(video.series)]
results = [r for r in results if video.matches(r['Title'])]
if not results:
logger.warning('No matching series found')
return
@ -154,12 +160,12 @@ def refine(video, **kwargs):
# search the movie
results = search(video.title, 'movie', video.year)
if not results:
logger.warning('No results')
logger.warning('No results for movie')
return
logger.debug('Found %d results', len(results))
# filter the results
results = [r for r in results if sanitize(r['Title']) == sanitize(video.title)]
results = [r for r in results if video.matches(r['Title'])]
if not results:
logger.warning('No matching movie found')
return

View file

@ -4,6 +4,8 @@ from functools import wraps
import logging
import re
from babelfish import Country
import guessit
import requests
from .. import __short_version__
@ -190,8 +192,14 @@ class TVDBClient(object):
return r.json()['data']
#: User-Agent to use
user_agent = 'Subliminal/%s' % __short_version__
#: Configured instance of :class:`TVDBClient`
tvdb_client = TVDBClient('5EC930FB90DA1ADA', headers={'User-Agent': 'Subliminal/%s' % __short_version__})
tvdb_client = TVDBClient('5EC930FB90DA1ADA', headers={'User-Agent': user_agent})
#: Configure guessit in order to use GuessitCountryConverter
guessit.api.configure()
@region.cache_on_arguments(expiration_time=REFINER_EXPIRATION_TIME)
@ -294,21 +302,33 @@ def refine(video, **kwargs):
# iterate over series names
for series_name in series_names:
# parse as series and year
# parse as series, year and country
series, year, country = series_re.match(series_name).groups()
if year:
year = int(year)
if country:
country = Country.fromguessit(country)
# discard mismatches on year
if year and (video.original_series or video.year != year):
logger.debug('Discarding series name %r mismatch on year %d', series, year)
continue
# discard mismatches on country
if video.country and video.country != country:
logger.debug('Discarding series name %r mismatch on country %r', series, country)
continue
# match on sanitized series name
if sanitize(series) == sanitize(video.series):
logger.debug('Found exact match on series %r', series_name)
matching_result['match'] = {'series': original_match['series'], 'year': series_year,
'original_series': original_match['year'] is None}
matching_result['match'] = {
'series': original_match['series'],
'year': series_year or year,
'country': country,
'original_series': original_match['year'] is None and country is None
}
break
# add the result on match
@ -331,7 +351,9 @@ def refine(video, **kwargs):
# add series information
logger.debug('Found series %r', series)
video.series = matching_result['match']['series']
video.alternative_series.extend(series['aliases'])
video.year = matching_result['match']['year']
video.country = matching_result['match']['country']
video.original_series = matching_result['match']['original_series']
video.series_tvdb_id = series['id']
video.series_imdb_id = series['imdbId'] or None