diff --git a/tubesync/sync/views.py b/tubesync/sync/views.py
index c5840e29..5aa5095a 100644
--- a/tubesync/sync/views.py
+++ b/tubesync/sync/views.py
@@ -31,7 +31,8 @@ from .utils import validate_url, delete_file
from .tasks import (map_task_to_instance, get_error_message,
get_source_completed_tasks, get_media_download_task,
delete_task_by_media, index_source_task)
-from .choices import (YouTube_SourceType, youtube_long_source_types, youtube_validation_urls)
+from .choices import (YouTube_SourceType, youtube_long_source_types,
+ youtube_help, youtube_validation_urls)
from . import signals
from . import youtube
@@ -163,44 +164,14 @@ class ValidateSourceView(FormView):
'the format of "{example}". The error was: {error}.'),
}
source_types = youtube_long_source_types
- help_item = {
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL: _('YouTube channel'),
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL_ID: _('YouTube channel ID'),
- Source.SOURCE_TYPE_YOUTUBE_PLAYLIST: _('YouTube playlist'),
- }
- help_texts = {
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL: _(
- 'Enter a YouTube channel URL into the box below. A channel URL will be in '
- 'the format of https://www.youtube.com/CHANNELNAME '
- 'where CHANNELNAME is the name of the channel you want '
- 'to add.'
- ),
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL_ID: _(
- 'Enter a YouTube channel URL by channel ID into the box below. A channel '
- 'URL by channel ID will be in the format of '
- 'https://www.youtube.com/channel/BiGLoNgUnIqUeId '
- 'where BiGLoNgUnIqUeId is the ID of the channel you want '
- 'to add.'
- ),
- Source.SOURCE_TYPE_YOUTUBE_PLAYLIST: _(
- 'Enter a YouTube playlist URL into the box below. A playlist URL will be '
- 'in the format of https://www.youtube.com/playlist?list='
- 'BiGLoNgUnIqUeId where BiGLoNgUnIqUeId is the '
- 'unique ID of the playlist you want to add.'
- ),
- }
- help_examples = {
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL: 'https://www.youtube.com/google',
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL_ID: ('https://www.youtube.com/channel/'
- 'UCK8sQmJBp8GCxrOtXWBpyEA'),
- Source.SOURCE_TYPE_YOUTUBE_PLAYLIST: ('https://www.youtube.com/playlist?list='
- 'PL590L5WQmH8dpP0RyH5pCfIaDEdt9nk7r')
- }
+ help_item = dict(YouTube_SourceType.choices)
+ help_texts = youtube_help.get('texts')
+ help_examples = youtube_help.get('examples')
validation_urls = youtube_validation_urls
prepopulate_fields = {
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL: ('source_type', 'key', 'name', 'directory'),
- Source.SOURCE_TYPE_YOUTUBE_CHANNEL_ID: ('source_type', 'key'),
- Source.SOURCE_TYPE_YOUTUBE_PLAYLIST: ('source_type', 'key'),
+ YouTube_SourceType.CHANNEL.value: ('source_type', 'key', 'name', 'directory'),
+ YouTube_SourceType.CHANNEL_ID.value: ('source_type', 'key'),
+ YouTube_SourceType.PLAYLIST.value: ('source_type', 'key'),
}
def __init__(self, *args, **kwargs):
@@ -233,7 +204,7 @@ class ValidateSourceView(FormView):
# Perform extra validation on the URL, we need to extract the channel name or
# playlist ID and check they are valid
source_type = form.cleaned_data['source_type']
- if source_type not in self.source_types.values():
+ if source_type not in YouTube_SourceType.values:
form.add_error(
'source_type',
ValidationError(self.errors['invalid_source'])