mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2024-11-14 17:40:24 -08:00
f05b09f349
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
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
# -*- 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)
|