from dynamic_preferences.types import BooleanPreference, StringPreference, IntegerPreference, ChoicePreference from dynamic_preferences.preferences import Section from dynamic_preferences.registries import global_preferences_registry from dynamic_preferences.users.registries import user_preferences_registry from YtManagerApp.models import VIDEO_ORDER_CHOICES from django.conf import settings import os # we create some section objects to link related preferences together hidden = Section('hidden') general = Section('general') scheduler = Section('scheduler') # Hidden settings @global_preferences_registry.register class Initialized(BooleanPreference): section = hidden name = 'initialized' default = False # General settings @global_preferences_registry.register class YouTubeAPIKey(StringPreference): section = general name = 'youtube_api_key' default = 'AIzaSyBabzE4Bup77WexdLMa9rN9z-wJidEfNX8' required = True @global_preferences_registry.register class AllowRegistrations(BooleanPreference): section = general name = 'allow_registrations' default = True required = True @global_preferences_registry.register class SyncSchedule(StringPreference): section = scheduler name = 'synchronization_schedule' default = '5 * * * *' # hourly required = True @global_preferences_registry.register class SchedulerConcurrency(IntegerPreference): section = scheduler name = 'concurrency' default = 2 required = True # User settings @user_preferences_registry.register class MarkDeletedAsWatched(BooleanPreference): name = 'mark_deleted_as_watched' default = True required = True @user_preferences_registry.register class AutoDeleteWatched(BooleanPreference): name = 'automatically_delete_watched' default = True required = True @user_preferences_registry.register class AutoDownloadEnabled(BooleanPreference): name = 'auto_download' default = True required = True @user_preferences_registry.register class DownloadGlobalLimit(IntegerPreference): name = 'download_global_limit' default = -1 required = False @user_preferences_registry.register class DownloadGlobalSizeLimit(IntegerPreference): name = 'download_global_size_limit' default = -1 required = False @user_preferences_registry.register class DownloadSubscriptionLimit(IntegerPreference): name = 'download_subscription_limit' default = 5 required = False @user_preferences_registry.register class DownloadMaxAttempts(IntegerPreference): name = 'max_download_attempts' default = 3 required = True @user_preferences_registry.register class DownloadOrder(ChoicePreference): name = 'download_order' choices = VIDEO_ORDER_CHOICES default = 'playlist' required = True @user_preferences_registry.register class DownloadPath(StringPreference): name = 'download_path' default = os.path.join(settings.DATA_DIR, 'downloads') required = False @user_preferences_registry.register class DownloadFilePattern(StringPreference): name = 'download_file_pattern' default = '${channel}/${playlist}/S01E${playlist_index} - ${title} [${id}]' required = True @user_preferences_registry.register class DownloadFormat(StringPreference): name = 'download_format' default = 'bestvideo+bestaudio' required = True @user_preferences_registry.register class DownloadSubtitles(BooleanPreference): name = 'download_subtitles' default = True required = True @user_preferences_registry.register class DownloadAutogeneratedSubtitles(BooleanPreference): name = 'download_autogenerated_subtitles' default = False required = True @user_preferences_registry.register class DownloadAllSubtitles(BooleanPreference): name = 'download_subtitles_all' default = False required = False @user_preferences_registry.register class DownloadSubtitlesLangs(StringPreference): name = 'download_subtitles_langs' default = 'en,ro' required = False @user_preferences_registry.register class DownloadSubtitlesFormat(StringPreference): name = 'download_subtitles_format' default = '' required = False