add field for media file name format, part of #5

This commit is contained in:
meeb 2020-12-18 13:00:33 +11:00
parent 83b9c167a9
commit ff58f2811b
5 changed files with 39 additions and 8 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.4 on 2020-12-18 01:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sync', '0003_source_copy_thumbnails'),
]
operations = [
migrations.AddField(
model_name='source',
name='media_format',
field=models.CharField(default='{yyyymmdd}_{source}_{title}_{key}_{format}.{ext}', help_text='File format to use for saving files', max_length=200, verbose_name='media format'),
),
]

View File

@ -174,6 +174,12 @@ class Source(models.Model):
unique=True,
help_text=_('Directory name to save the media into')
)
media_format = models.CharField(
_('media format'),
max_length=200,
default=settings.MEDIA_FORMATSTR_DEFAULT,
help_text=_('File format to use for saving files')
)
index_schedule = models.IntegerField(
_('index schedule'),
choices=IndexSchedule.choices,

View File

@ -43,6 +43,10 @@
<td class="hide-on-small-only">Directory</td>
<td><span class="hide-on-med-and-up">Directory<br></span><strong>{{ source.directory }}</strong></td>
</tr>
<tr title="Media file name format to use for saving files">
<td class="hide-on-small-only">Media format</td>
<td><span class="hide-on-med-and-up">Media format<br></span><strong>{{ source.media_format }}</strong></td>
</tr>
<tr title="Schedule of how often to index the source for new media">
<td class="hide-on-small-only">Index schedule</td>
<td><span class="hide-on-med-and-up">Index schedule<br></span><strong>{{ source.get_index_schedule_display }}</strong></td>

View File

@ -252,10 +252,10 @@ class AddSourceView(CreateView):
template_name = 'sync/source-add.html'
model = Source
fields = ('source_type', 'key', 'name', 'directory', 'index_schedule',
'delete_old_media', 'days_to_keep', 'source_resolution', 'source_vcodec',
'source_acodec', 'prefer_60fps', 'prefer_hdr', 'fallback',
'copy_thumbnails')
fields = ('source_type', 'key', 'name', 'directory', 'media_format',
'index_schedule', 'delete_old_media', 'days_to_keep',
'source_resolution', 'source_vcodec', 'source_acodec', 'prefer_60fps',
'prefer_hdr', 'fallback', 'copy_thumbnails')
def __init__(self, *args, **kwargs):
self.prepopulated_data = {}
@ -324,10 +324,10 @@ class UpdateSourceView(UpdateView):
template_name = 'sync/source-update.html'
model = Source
fields = ('source_type', 'key', 'name', 'directory', 'index_schedule',
'delete_old_media', 'days_to_keep', 'source_resolution', 'source_vcodec',
'source_acodec', 'prefer_60fps', 'prefer_hdr', 'fallback',
'copy_thumbnails')
fields = ('source_type', 'key', 'name', 'directory', 'media_format',
'index_schedule', 'delete_old_media', 'days_to_keep',
'source_resolution', 'source_vcodec', 'source_acodec', 'prefer_60fps',
'prefer_hdr', 'fallback', 'copy_thumbnails')
def get_success_url(self):
url = reverse_lazy('sync:source', kwargs={'pk': self.object.pk})

View File

@ -147,6 +147,9 @@ YOUTUBE_DEFAULTS = {
}
MEDIA_FORMATSTR_DEFAULT = '{yyyymmdd}_{source}_{title}_{key}_{format}.{ext}'
try:
from .local_settings import *
except ImportError as e: