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