2016-12-17 04:02:08 +00:00
|
|
|
import converter
|
2017-01-30 01:47:59 +00:00
|
|
|
import logging
|
2016-11-06 04:24:43 +00:00
|
|
|
import string
|
2016-12-17 04:02:08 +00:00
|
|
|
import traceback
|
|
|
|
|
|
|
|
try:
|
|
|
|
ffmpeg = converter.Converter(
|
|
|
|
ffmpeg_path='C:\\software\\ffmpeg\\bin\\ffmpeg.exe',
|
|
|
|
ffprobe_path='C:\\software\\ffmpeg\\bin\\ffprobe.exe',
|
|
|
|
)
|
|
|
|
except converter.ffmpeg.FFMpegError:
|
|
|
|
traceback.print_exc()
|
|
|
|
ffmpeg = None
|
2016-11-06 04:24:43 +00:00
|
|
|
|
2016-12-21 01:44:22 +00:00
|
|
|
FILENAME_BADCHARS = '\\/:*?<>|"'
|
|
|
|
|
2016-12-13 03:49:36 +00:00
|
|
|
ALLOWED_ORDERBY_COLUMNS = [
|
|
|
|
'extension',
|
|
|
|
'width',
|
|
|
|
'height',
|
|
|
|
'ratio',
|
|
|
|
'area',
|
|
|
|
'duration',
|
|
|
|
'bytes',
|
|
|
|
'created',
|
|
|
|
'tagged_at',
|
|
|
|
'random',
|
|
|
|
]
|
|
|
|
|
2016-12-17 04:02:08 +00:00
|
|
|
SQL_LASTID_COLUMNS = [
|
|
|
|
'table',
|
|
|
|
'last_id',
|
|
|
|
]
|
|
|
|
SQL_ALBUM_COLUMNS = [
|
|
|
|
'id',
|
|
|
|
'title',
|
|
|
|
'description',
|
|
|
|
'associated_directory',
|
|
|
|
]
|
|
|
|
SQL_PHOTO_COLUMNS = [
|
|
|
|
'id',
|
|
|
|
'filepath',
|
|
|
|
'override_filename',
|
|
|
|
'extension',
|
|
|
|
'width',
|
|
|
|
'height',
|
|
|
|
'ratio',
|
|
|
|
'area',
|
|
|
|
'duration',
|
|
|
|
'bytes',
|
|
|
|
'created',
|
|
|
|
'thumbnail',
|
|
|
|
'tagged_at',
|
2016-12-20 22:54:23 +00:00
|
|
|
'author_id',
|
2016-12-17 04:02:08 +00:00
|
|
|
]
|
|
|
|
SQL_TAG_COLUMNS = [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
]
|
|
|
|
SQL_SYN_COLUMNS = [
|
|
|
|
'name',
|
|
|
|
'master',
|
|
|
|
]
|
|
|
|
SQL_ALBUMPHOTO_COLUMNS = [
|
|
|
|
'albumid',
|
|
|
|
'photoid',
|
|
|
|
]
|
|
|
|
SQL_PHOTOTAG_COLUMNS = [
|
|
|
|
'photoid',
|
|
|
|
'tagid',
|
|
|
|
]
|
|
|
|
SQL_TAGGROUP_COLUMNS = [
|
|
|
|
'parentid',
|
|
|
|
'memberid',
|
|
|
|
]
|
|
|
|
SQL_USER_COLUMNS = [
|
|
|
|
'id',
|
|
|
|
'username',
|
|
|
|
'password',
|
|
|
|
'created',
|
|
|
|
]
|
|
|
|
|
|
|
|
_sql_dictify = lambda columns: {key:index for (index, key) in enumerate(columns)}
|
|
|
|
SQL_ALBUM = _sql_dictify(SQL_ALBUM_COLUMNS)
|
|
|
|
SQL_ALBUMPHOTO = _sql_dictify(SQL_ALBUMPHOTO_COLUMNS)
|
|
|
|
SQL_LASTID = _sql_dictify(SQL_LASTID_COLUMNS)
|
|
|
|
SQL_PHOTO = _sql_dictify(SQL_PHOTO_COLUMNS)
|
|
|
|
SQL_PHOTOTAG = _sql_dictify(SQL_PHOTOTAG_COLUMNS)
|
|
|
|
SQL_SYN = _sql_dictify(SQL_SYN_COLUMNS)
|
|
|
|
SQL_TAG = _sql_dictify(SQL_TAG_COLUMNS)
|
|
|
|
SQL_TAGGROUP = _sql_dictify(SQL_TAGGROUP_COLUMNS)
|
|
|
|
SQL_USER = _sql_dictify(SQL_USER_COLUMNS)
|
|
|
|
|
|
|
|
|
2016-11-06 04:24:43 +00:00
|
|
|
# Errors and warnings
|
2016-11-29 04:18:44 +00:00
|
|
|
ERROR_DATABASE_OUTOFDATE = 'Database is out-of-date. {current} should be {new}. Please use etiquette_upgrader.py'
|
2016-11-06 04:24:43 +00:00
|
|
|
ERROR_INVALID_ACTION = 'Invalid action'
|
|
|
|
ERROR_NO_SUCH_TAG = 'Doesn\'t exist'
|
|
|
|
ERROR_NO_TAG_GIVEN = 'No tag name supplied'
|
|
|
|
ERROR_SYNONYM_ITSELF = 'Cant apply synonym to itself'
|
|
|
|
ERROR_TAG_TOO_SHORT = 'Not enough valid chars'
|
2016-12-21 02:31:09 +00:00
|
|
|
ERROR_RECURSIVE_GROUPING = 'Recursive grouping'
|
2016-11-06 04:24:43 +00:00
|
|
|
WARNING_MINMAX_INVALID = 'Field "{field}": "{value}" is not a valid request. Ignored.'
|
|
|
|
WARNING_MINMAX_OOO = 'Field "{field}": minimum "{min}" maximum "{max}" are out of order. Ignored.'
|
|
|
|
WARNING_NO_SUCH_TAG = 'Tag "{tag}" does not exist. Ignored.'
|
2016-12-25 01:13:45 +00:00
|
|
|
WARNING_NO_SUCH_USER = 'User "{username}" does not exist. Ignored.'
|
|
|
|
WARNING_ORDERBY_INVALID = 'Invalid orderby request "{request}". Ignored.'
|
2016-11-06 04:24:43 +00:00
|
|
|
WARNING_ORDERBY_BADCOL = '"{column}" is not a sorting option. Ignored.'
|
2016-12-25 01:13:45 +00:00
|
|
|
WARNING_ORDERBY_BADDIRECTION = 'You can\'t order "{column}" by "{direction}". Defaulting to descending.'
|
2016-11-06 04:24:43 +00:00
|
|
|
|
2016-12-17 02:53:12 +00:00
|
|
|
# Operational info
|
|
|
|
EXPRESSION_OPERATORS = {'(', ')', 'OR', 'AND', 'NOT'}
|
|
|
|
ADDITIONAL_MIMETYPES = {
|
|
|
|
'srt': 'text',
|
|
|
|
'mkv': 'video',
|
|
|
|
}
|
2016-11-06 04:24:43 +00:00
|
|
|
|
2016-12-13 03:49:36 +00:00
|
|
|
DEFAULT_DATADIR = '.\\_etiquette'
|
2016-12-16 09:53:51 +00:00
|
|
|
|
2016-12-17 02:53:12 +00:00
|
|
|
DEFAULT_CONFIGURATION = {
|
2017-01-30 01:47:59 +00:00
|
|
|
'log_level': logging.DEBUG,
|
|
|
|
|
2016-12-17 02:53:12 +00:00
|
|
|
'min_tag_name_length': 1,
|
|
|
|
'max_tag_name_length': 32,
|
|
|
|
'valid_tag_chars': string.ascii_lowercase + string.digits + '_',
|
2016-11-06 04:24:43 +00:00
|
|
|
|
2016-12-17 02:53:12 +00:00
|
|
|
'min_username_length': 2,
|
|
|
|
'max_username_length': 24,
|
2016-12-24 03:49:51 +00:00
|
|
|
'valid_username_chars': string.ascii_letters + string.digits + '~!@#$%^*()[]{}:;,.<>/\\-_+=',
|
2016-12-17 02:53:12 +00:00
|
|
|
'min_password_length': 6,
|
2016-11-06 04:24:43 +00:00
|
|
|
|
2016-12-17 02:53:12 +00:00
|
|
|
'id_length': 12,
|
|
|
|
'digest_exclude_files': [
|
|
|
|
'phototagger.db',
|
|
|
|
'desktop.ini',
|
|
|
|
'thumbs.db',
|
|
|
|
],
|
|
|
|
'digest_exclude_dirs': [
|
|
|
|
'_site_thumbnails',
|
|
|
|
],
|
|
|
|
|
|
|
|
'file_read_chunk': 2 ** 20,
|
|
|
|
'thumbnail_width': 400,
|
|
|
|
'thumbnail_height': 400,
|
|
|
|
'motd_strings': [
|
|
|
|
'Good morning, Paul. What will your first sequence of the day be?',
|
|
|
|
],
|
2016-11-06 04:24:43 +00:00
|
|
|
|
|
|
|
}
|