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')
|
|
|
|
manager = Section('manager')
|
|
|
|
downloader = Section('downloader')
|
|
|
|
|
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 AllowCDN(BooleanPreference):
|
|
|
|
section = general
|
|
|
|
name = 'allow_cdn'
|
|
|
|
default = True
|
|
|
|
required = True
|
|
|
|
|
|
|
|
|
|
|
|
@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):
|
|
|
|
section = manager
|
|
|
|
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):
|
|
|
|
section = manager
|
|
|
|
name = 'auto_delete_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 AutoDownloadEnabled(BooleanPreference):
|
|
|
|
section = downloader
|
2018-12-10 21:23:00 +00:00
|
|
|
name = 'auto_enabled'
|
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):
|
|
|
|
section = downloader
|
2018-12-10 21:23:00 +00:00
|
|
|
name = 'global_limit'
|
2018-12-01 15:28:37 +00:00
|
|
|
default = None
|
|
|
|
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):
|
|
|
|
section = downloader
|
|
|
|
name = 'global_size_limit_mb'
|
|
|
|
default = None
|
|
|
|
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):
|
|
|
|
section = downloader
|
2018-12-10 21:23:00 +00:00
|
|
|
name = 'limit_per_subscription'
|
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):
|
|
|
|
section = downloader
|
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):
|
|
|
|
section = downloader
|
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):
|
|
|
|
section = downloader
|
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):
|
|
|
|
section = downloader
|
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):
|
|
|
|
section = downloader
|
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):
|
|
|
|
section = downloader
|
|
|
|
name = 'subtitles_enabled'
|
|
|
|
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):
|
|
|
|
section = downloader
|
|
|
|
name = 'autogenerated_subtitles'
|
|
|
|
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):
|
|
|
|
section = downloader
|
|
|
|
name = 'all_subtitles'
|
|
|
|
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):
|
|
|
|
section = downloader
|
|
|
|
name = 'subtitles_langs'
|
|
|
|
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):
|
|
|
|
section = downloader
|
|
|
|
name = 'subtitles_format'
|
|
|
|
default = False
|
2018-12-09 23:15:10 +00:00
|
|
|
required = False
|