123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import os
- import logging
-
- try:
- from config import APP_NAME as ROOT_LOGGER_NAME
- except ImportError:
- ROOT_LOGGER_NAME = 'root'
- logger = logging.getLogger(ROOT_LOGGER_NAME).getChild(__name__)
-
- # make module usable without discid dependency
- try:
- import discid
- except ModuleNotFoundError:
- logger.warning("Python module discid not installed")
- except OSError:
- logger.exception("You might install python3-libdiscid")
-
- KEY_ALBUM = 'album'
- KEY_APERTURE = 'aperture'
- KEY_ARTIST = 'artist'
- KEY_BITRATE = 'bitrate'
- KEY_CAMERA = 'camera'
- KEY_DURATION = 'duration'
- KEY_EXPOSURE_PROGRAM = 'exposure_program'
- KEY_EXPOSURE_TIME = 'exposure_time'
- KEY_FLASH = 'flash'
- KEY_FOCAL_LENGTH = 'focal_length'
- KEY_GENRE = 'genre'
- KEY_GPS = 'gps'
- KEY_HEIGHT = 'height'
- KEY_ISO = 'iso'
- KEY_ORIENTATION = 'orientation'
- KEY_RATIO = 'ratio'
- KEY_SIZE = 'size'
- KEY_TIME = 'time' # USE time.localtime(value) or datetime.fromtimestamp(value) to convert the timestamp
- KEY_TIME_IS_SUBSTITUTION = 'tm_is_subst'
- KEY_TITLE = 'title'
- KEY_TRACK = 'track'
- KEY_WIDTH = 'width'
- KEY_YEAR = 'year'
-
- FILETYPE_AUDIO = 'audio'
- FILETYPE_IMAGE = 'image'
- FILETYPE_VIDEO = 'video'
- FILETYPE_DISC = 'disc'
-
- CALLBACK_CDDB_CHOICE = 0
- CALLBACK_MAN_INPUT = 1
-
- EXTENTIONS_AUDIO = ['.mp3', ]
- EXTENTIONS_IMAGE = ['.jpg', '.jpeg', '.jpe', '.png', '.tif', '.tiff', '.gif', ]
- EXTENTIONS_VIDEO = ['.avi', '.mpg', '.mpeg', '.mpe', '.mov', '.qt', '.mp4', '.webm', '.ogv', '.flv', '.3gp', ]
- PREFIX_DISC = '/dev/'
-
-
- def get_filetype(full_path):
- ext = os.path.splitext(full_path.lower())[1]
- if ext in EXTENTIONS_AUDIO:
- return FILETYPE_AUDIO
- elif ext in EXTENTIONS_IMAGE:
- return FILETYPE_IMAGE
- elif ext in EXTENTIONS_VIDEO:
- return FILETYPE_VIDEO
- elif full_path.startswith(PREFIX_DISC):
- return FILETYPE_DISC
-
-
- def get_disc_device():
- return discid.get_default_device()
|