mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-28 02:27:28 +00:00
8086bce5c4
* fese library was updated * mergerfs_mode support was dropped. Too much false positives * extended codec support (two new codecs added: webvtt and mov_text) * disable conversion to srt by default
68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
import re
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class FFprobeSubtitleDisposition:
|
|
def __init__(self, data: dict):
|
|
self.default = False
|
|
self.generic = False
|
|
self.dub = False
|
|
self.original = False
|
|
self.comment = False
|
|
self.lyrics = False
|
|
self.karaoke = False
|
|
self.forced = False
|
|
self.hearing_impaired = False
|
|
self.visual_impaired = False
|
|
self.clean_effects = False
|
|
self.attached_pic = False
|
|
self.timed_thumbnails = False
|
|
self._content_type = None
|
|
|
|
for key, val in data.items():
|
|
if hasattr(self, key):
|
|
setattr(self, key, bool(val))
|
|
|
|
for key in _content_types.keys():
|
|
if getattr(self, key, None):
|
|
self._content_type = key
|
|
|
|
def update_from_tags(self, tags):
|
|
tag_title = tags.get("title")
|
|
if tag_title is None:
|
|
logger.debug("Title not found. Marking as generic")
|
|
self.generic = True
|
|
return None
|
|
|
|
l_tag_title = tag_title.lower()
|
|
|
|
for key, val in _content_types.items():
|
|
if val.search(l_tag_title) is not None:
|
|
logger.debug("Found %s: %s", key, l_tag_title)
|
|
self._content_type = key
|
|
setattr(self, key, True)
|
|
return None
|
|
|
|
logger.debug("Generic disposition title found: %s", l_tag_title)
|
|
self.generic = True
|
|
return None
|
|
|
|
@property
|
|
def suffix(self):
|
|
return self._content_type or ""
|
|
|
|
def __str__(self):
|
|
return self.suffix.upper() or "GENERIC"
|
|
|
|
|
|
_content_types = {
|
|
"hearing_impaired": re.compile(r"sdh|hearing impaired|cc"),
|
|
"forced": re.compile(r"forced|non[- ]english"),
|
|
"comment": re.compile(r"comment"),
|
|
"visual_impaired": re.compile(r"signs|visual impair"),
|
|
"karaoke": re.compile(r"karaoke|songs"),
|
|
}
|