1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-23 16:23:41 +00:00
bazarr/custom_libs/subliminal_patch/extensions.py

67 lines
2 KiB
Python
Raw Normal View History

2018-10-31 16:08:29 +00:00
# coding=utf-8
2019-09-17 02:04:27 +00:00
from __future__ import absolute_import
2018-10-31 16:08:29 +00:00
from collections import OrderedDict
import subliminal
import babelfish
class ProviderRegistry(object):
providers = None
def __init__(self):
self.providers = OrderedDict()
def __cmp__(self, d):
return cmp(self.providers, d)
def __contains__(self, item):
return item in self.providers
def __setitem__(self, key, item):
self.providers[key] = item
def __iter__(self):
return iter(self.providers)
def __getitem__(self, key):
if key in self.providers:
return self.providers[key]
def __repr__(self):
return repr(self.providers)
def __str__(self):
return str(self.providers)
def __len__(self):
return len(self.providers)
def __delitem__(self, key):
del self.providers[key]
def register(self, name, cls):
self.providers[name] = cls
def names(self):
2019-09-17 02:04:27 +00:00
return list(self.providers.keys())
2018-10-31 16:08:29 +00:00
provider_registry = ProviderRegistry()
# add language converters
try:
babelfish.language_converters.unregister('addic7ed = subliminal.converters.addic7ed:Addic7edConverter')
except ValueError:
pass
babelfish.language_converters.register('addic7ed = subliminal_patch.language:PatchedAddic7edConverter')
babelfish.language_converters.register('szopensubtitles = subliminal_patch.language:PatchedOpenSubtitlesConverter')
subliminal.refiner_manager.register('sz_metadata = subliminal_patch.refiners.metadata:refine')
subliminal.refiner_manager.register('sz_omdb = subliminal_patch.refiners.omdb:refine')
subliminal.refiner_manager.register('sz_tvdb = subliminal_patch.refiners.tvdb:refine')
subliminal.refiner_manager.register('drone = subliminal_patch.refiners.drone:refine')
subliminal.refiner_manager.register('filebot = subliminal_patch.refiners.filebot:refine')
subliminal.refiner_manager.register('file_info_file = subliminal_patch.refiners.file_info_file:refine')
subliminal.refiner_manager.register('symlinks = subliminal_patch.refiners.symlinks:refine')