Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tubesync/sync/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from django import forms, VERSION as DJANGO_VERSION
from django.conf import settings
from django.utils.translation import gettext_lazy as _

from .models import Source
Expand Down Expand Up @@ -29,6 +30,12 @@
},
)

def source_clean_media_format(self):
data = self.cleaned_data.get('media_format', '').strip()
return data or getattr(settings, 'MEDIA_FORMATSTR', settings.MEDIA_FORMATSTR_DEFAULT)

SourceForm.clean_media_format = source_clean_media_format

class ValidateSourceForm(forms.Form):

source_url = forms.URLField(
Expand Down
4 changes: 4 additions & 0 deletions tubesync/sync/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def dispatch(self, request, *args, **kwargs):
# Inject the adjustable media format default
self.prepopulated_data['media_format'] = getattr(
settings, 'MEDIA_FORMATSTR', settings.MEDIA_FORMATSTR_DEFAULT
)
source_type = request.GET.get('source_type', '')
if source_type and source_type in YouTube_SourceType.values:
self.prepopulated_data['source_type'] = source_type
Expand Down