nightly
parent
3008d66dfe
commit
1ae52399b9
@ -0,0 +1,113 @@
|
||||
from enum import Enum
|
||||
import difflib
|
||||
|
||||
class IsoLanguage(Enum):
|
||||
|
||||
AFRIKAANS = {"name": "Afrikaans", "iso639_1": "af", "iso639_2": "afr"}
|
||||
ALBANIAN = {"name": "Albanian", "iso639_1": "sq", "iso639_2": "alb"}
|
||||
ARABIC = {"name": "Arabic", "iso639_1": "ar", "iso639_2": "ara"}
|
||||
ARMENIAN = {"name": "Armenian", "iso639_1": "hy", "iso639_2": "arm"}
|
||||
AZERBAIJANI = {"name": "Azerbaijani", "iso639_1": "az", "iso639_2": "aze"}
|
||||
BASQUE = {"name": "Basque", "iso639_1": "eu", "iso639_2": "baq"}
|
||||
BELARUSIAN = {"name": "Belarusian", "iso639_1": "be", "iso639_2": "bel"}
|
||||
BULGARIAN = {"name": "Bulgarian", "iso639_1": "bg", "iso639_2": "bul"}
|
||||
CATALAN = {"name": "Catalan", "iso639_1": "ca", "iso639_2": "cat"}
|
||||
CHINESE = {"name": "Chinese", "iso639_1": "zh", "iso639_2": "chi"}
|
||||
CROATIAN = {"name": "Croatian", "iso639_1": "hr", "iso639_2": "hrv"}
|
||||
CZECH = {"name": "Czech", "iso639_1": "cs", "iso639_2": "cze"}
|
||||
DANISH = {"name": "Danish", "iso639_1": "da", "iso639_2": "dan"}
|
||||
DUTCH = {"name": "Dutch", "iso639_1": "nl", "iso639_2": "dut"}
|
||||
ENGLISH = {"name": "English", "iso639_1": "en", "iso639_2": "eng"}
|
||||
ESTONIAN = {"name": "Estonian", "iso639_1": "et", "iso639_2": "est"}
|
||||
FINNISH = {"name": "Finnish", "iso639_1": "fi", "iso639_2": "fin"}
|
||||
FRENCH = {"name": "French", "iso639_1": "fr", "iso639_2": "fre"}
|
||||
GEORGIAN = {"name": "Georgian", "iso639_1": "ka", "iso639_2": "geo"}
|
||||
GERMAN = {"name": "German", "iso639_1": "de", "iso639_2": "ger"}
|
||||
GREEK = {"name": "Greek", "iso639_1": "el", "iso639_2": "gre"}
|
||||
HEBREW = {"name": "Hebrew", "iso639_1": "he", "iso639_2": "heb"}
|
||||
HINDI = {"name": "Hindi", "iso639_1": "hi", "iso639_2": "hin"}
|
||||
HUNGARIAN = {"name": "Hungarian", "iso639_1": "hu", "iso639_2": "hun"}
|
||||
ICELANDIC = {"name": "Icelandic", "iso639_1": "is", "iso639_2": "ice"}
|
||||
INDONESIAN = {"name": "Indonesian", "iso639_1": "id", "iso639_2": "ind"}
|
||||
IRISH = {"name": "Irish", "iso639_1": "ga", "iso639_2": "gle"}
|
||||
ITALIAN = {"name": "Italian", "iso639_1": "it", "iso639_2": "ita"}
|
||||
JAPANESE = {"name": "Japanese", "iso639_1": "ja", "iso639_2": "jpn"}
|
||||
KAZAKH = {"name": "Kazakh", "iso639_1": "kk", "iso639_2": "kaz"}
|
||||
KOREAN = {"name": "Korean", "iso639_1": "ko", "iso639_2": "kor"}
|
||||
LATIN = {"name": "Latin", "iso639_1": "la", "iso639_2": "lat"}
|
||||
LATVIAN = {"name": "Latvian", "iso639_1": "lv", "iso639_2": "lav"}
|
||||
LITHUANIAN = {"name": "Lithuanian", "iso639_1": "lt", "iso639_2": "lit"}
|
||||
MACEDONIAN = {"name": "Macedonian", "iso639_1": "mk", "iso639_2": "mac"}
|
||||
MALAY = {"name": "Malay", "iso639_1": "ms", "iso639_2": "may"}
|
||||
MALTESE = {"name": "Maltese", "iso639_1": "mt", "iso639_2": "mlt"}
|
||||
NORWEGIAN = {"name": "Norwegian", "iso639_1": "no", "iso639_2": "nor"}
|
||||
PERSIAN = {"name": "Persian", "iso639_1": "fa", "iso639_2": "per"}
|
||||
POLISH = {"name": "Polish", "iso639_1": "pl", "iso639_2": "pol"}
|
||||
PORTUGUESE = {"name": "Portuguese", "iso639_1": "pt", "iso639_2": "por"}
|
||||
ROMANIAN = {"name": "Romanian", "iso639_1": "ro", "iso639_2": "rum"}
|
||||
RUSSIAN = {"name": "Russian", "iso639_1": "ru", "iso639_2": "rus"}
|
||||
NORTHERN_SAMI = {"name": "Northern Sami", "iso639_1": "se", "iso639_2": "sme"}
|
||||
SAMOAN = {"name": "Samoan", "iso639_1": "sm", "iso639_2": "smo"}
|
||||
SANGO = {"name": "Sango", "iso639_1": "sg", "iso639_2": "sag"}
|
||||
SANSKRIT = {"name": "Sanskrit", "iso639_1": "sa", "iso639_2": "san"}
|
||||
SARDINIAN = {"name": "Sardinian", "iso639_1": "sc", "iso639_2": "srd"}
|
||||
SERBIAN = {"name": "Serbian", "iso639_1": "sr", "iso639_2": "srp"}
|
||||
SHONA = {"name": "Shona", "iso639_1": "sn", "iso639_2": "sna"}
|
||||
SINDHI = {"name": "Sindhi", "iso639_1": "sd", "iso639_2": "snd"}
|
||||
SINHALA = {"name": "Sinhala", "iso639_1": "si", "iso639_2": "sin"}
|
||||
SLOVAK = {"name": "Slovak", "iso639_1": "sk", "iso639_2": "slk"}
|
||||
SLOVENIAN = {"name": "Slovenian", "iso639_1": "sl", "iso639_2": "slv"}
|
||||
SOMALI = {"name": "Somali", "iso639_1": "so", "iso639_2": "som"}
|
||||
SOUTHERN_SOTHO = {"name": "Southern Sotho", "iso639_1": "st", "iso639_2": "sot"}
|
||||
SPANISH = {"name": "Spanish", "iso639_1": "es", "iso639_2": "spa"}
|
||||
SUNDANESE = {"name": "Sundanese", "iso639_1": "su", "iso639_2": "sun"}
|
||||
SWAHILI = {"name": "Swahili", "iso639_1": "sw", "iso639_2": "swa"}
|
||||
SWATI = {"name": "Swati", "iso639_1": "ss", "iso639_2": "ssw"}
|
||||
SWEDISH = {"name": "Swedish", "iso639_1": "sv", "iso639_2": "swe"}
|
||||
TAGALOG = {"name": "Tagalog", "iso639_1": "tl", "iso639_2": "tgl"}
|
||||
TAMIL = {"name": "Tamil", "iso639_1": "ta", "iso639_2": "tam"}
|
||||
THAI = {"name": "Thai", "iso639_1": "th", "iso639_2": "tha"}
|
||||
TURKISH = {"name": "Turkish", "iso639_1": "tr", "iso639_2": "tur"}
|
||||
UKRAINIAN = {"name": "Ukrainian", "iso639_1": "uk", "iso639_2": "ukr"}
|
||||
URDU = {"name": "Urdu", "iso639_1": "ur", "iso639_2": "urd"}
|
||||
VIETNAMESE = {"name": "Vietnamese", "iso639_1": "vi", "iso639_2": "vie"}
|
||||
WELSH = {"name": "Welsh", "iso639_1": "cy", "iso639_2": "wel"}
|
||||
|
||||
|
||||
@staticmethod
|
||||
def find(label : str):
|
||||
|
||||
closestMatches = difflib.get_close_matches(label, [l.value["name"] for l in IsoLanguage], n=1)
|
||||
|
||||
if closestMatches:
|
||||
foundLangs = [l for l in IsoLanguage if l.value['name'] == closestMatches[0]]
|
||||
return foundLangs[0] if foundLangs else None
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def findThreeLetter(theeLetter : str):
|
||||
foundLangs = [l for l in IsoLanguage if l.value['iso639_2'] == str(theeLetter)]
|
||||
return foundLangs[0] if foundLangs else None
|
||||
|
||||
|
||||
# def get(lang : str):
|
||||
#
|
||||
# selectedLangs = [l for l in IsoLanguage if l.value['iso639_2'] == lang]
|
||||
#
|
||||
# if selectedLangs:
|
||||
# return selectedLangs[0]
|
||||
# else:
|
||||
# return None
|
||||
|
||||
def label(self):
|
||||
return str(self.value['name'])
|
||||
|
||||
def twoLetter(self):
|
||||
return str(self.value['iso639_1'])
|
||||
|
||||
def threeLetter(self):
|
||||
return str(self.value['iso639_2'])
|
||||
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
# from typing import List
|
||||
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, Enum
|
||||
from sqlalchemy.orm import relationship, declarative_base, sessionmaker
|
||||
|
||||
from .show import Base
|
||||
|
||||
from ffx.track_type import TrackType
|
||||
|
||||
|
||||
class Tag(Base):
|
||||
"""
|
||||
relationship(argument, opt1, opt2, ...)
|
||||
argument is string of class or Mapped class of the target entity
|
||||
backref creates a bi-directional corresponding relationship (back_populates preferred)
|
||||
back_populates points to the corresponding relationship (the actual class attribute identifier)
|
||||
|
||||
See: https://docs.sqlalchemy.org/en/(14|20)/orm/basic_relationships.html
|
||||
"""
|
||||
|
||||
__tablename__ = 'tags'
|
||||
|
||||
# v1.x
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
||||
key = Column(String)
|
||||
value = Column(String)
|
||||
|
||||
# v1.x
|
||||
track_id = Column(Integer, ForeignKey('tracks.id', ondelete="CASCADE"))
|
||||
track = relationship('Track', back_populates='tags')
|
@ -0,0 +1,49 @@
|
||||
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
|
Loading…
Reference in New Issue