You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
from enum import Enum
|
|
import difflib
|
|
|
|
class TrackDisposition(Enum):
|
|
|
|
DEFAULT = {"name": "default", "index": 0}
|
|
FORCED = {"name": "forced", "index": 1}
|
|
|
|
DUB = {"name": "dub", "index": 2}
|
|
ORIGINAL = {"name": "original", "index": 3}
|
|
COMMENT = {"name": "comment", "index": 4}
|
|
LYRICS = {"name": "lyrics", "index": 5}
|
|
KARAOKE = {"name": "karaoke", "index": 6}
|
|
HEARING_IMPAIRED = {"name": "hearing_impaired", "index": 7}
|
|
VISUAL_IMPAIRED = {"name": "visual_impaired", "index": 8}
|
|
CLEAN_EFFECTS = {"name": "clean_effects", "index": 9}
|
|
ATTACHED_PIC = {"name": "attached_pic", "index": 10}
|
|
TIMED_THUMBNAILS = {"name": "timed_thumbnails", "index": 11}
|
|
NON_DIEGETICS = {"name": "non_diegetic", "index": 12}
|
|
CAPTIONS = {"name": "captions", "index": 13}
|
|
DESCRIPTIONS = {"name": "descriptions", "index": 14}
|
|
METADATA = {"name": "metadata", "index": 15}
|
|
DEPENDENT = {"name": "dependent", "index": 16}
|
|
STILL_IMAGE = {"name": "still_image", "index": 17}
|
|
|
|
def label(self):
|
|
return str(self.value['name'])
|
|
|
|
def index(self):
|
|
return int(self.value['index'])
|
|
|
|
|
|
@staticmethod
|
|
def toFlags(dispositionList):
|
|
"""Flags stored in integer bits (2**index)"""
|
|
|
|
flags = 0
|
|
for d in dispositionList:
|
|
flags += 2 ** d.index()
|
|
return flags
|
|
|
|
@staticmethod
|
|
def toList(flags):
|
|
|
|
dispositionList = []
|
|
for d in TrackDisposition:
|
|
if flags & int(2 ** d.index()):
|
|
dispositionList += [d]
|
|
return dispositionList
|
|
|
|
@staticmethod
|
|
def find(disposition):
|
|
matchingDispositions = [d for d in TrackDisposition if d.label() == str(disposition)]
|
|
if matchingDispositions:
|
|
return matchingDispositions[0]
|
|
else:
|
|
return None
|