add {HH} for hour and {min} for minutes to output media format path formats, part of #133

This commit is contained in:
meeb 2021-10-15 20:53:06 +11:00
parent 00fbd53b11
commit 3c1d64a089
3 changed files with 29 additions and 8 deletions

View File

@ -428,12 +428,15 @@ class Source(models.Model):
fmt.append('60fps')
if self.prefer_hdr:
fmt.append('hdr')
now = timezone.now()
return {
'yyyymmdd': timezone.now().strftime('%Y%m%d'),
'yyyy_mm_dd': timezone.now().strftime('%Y-%m-%d'),
'yyyy': timezone.now().strftime('%Y'),
'mm': timezone.now().strftime('%m'),
'dd': timezone.now().strftime('%d'),
'yyyymmdd': now.strftime('%Y%m%d'),
'yyyy_mm_dd': now.strftime('%Y-%m-%d'),
'yyyy': now.strftime('%Y'),
'mm': now.strftime('%m'),
'dd': now.strftime('%d'),
'hh': now.strftime('%H'),
'min': now.strftime('%M'),
'source': self.slugname,
'source_full': self.name,
'title': 'some-media-title-name',
@ -917,6 +920,8 @@ class Media(models.Model):
'yyyy': dateobj.strftime('%Y'),
'mm': dateobj.strftime('%m'),
'dd': dateobj.strftime('%d'),
'hh': dateobj.strftime('%H'),
'min': dateobj.strftime('%M'),
'source': self.source.slugname,
'source_full': self.source.name,
'title': self.slugtitle,

View File

@ -25,14 +25,24 @@
</tr>
<tr>
<td>{mm}</td>
<td>Media publish year in MM</td>
<td>Media publish month in MM</td>
<td>01</td>
</tr>
<tr>
<td>{dd}</td>
<td>Media publish year in DD</td>
<td>Media publish day in DD</td>
<td>31</td>
</tr>
<tr>
<td>{hh}</td>
<td>Media publish hour in HH</td>
<td>12</td>
</tr>
<tr>
<td>{min}</td>
<td>Media publish minutes in MM</td>
<td>46</td>
</tr>
<tr>
<td>{source}</td>
<td>Lower case source name, max 80 chars</td>

View File

@ -491,7 +491,7 @@ class FilepathTestCase(TestCase):
metadata=metadata,
)
def test_source_dirname(self):
def test_source_media_format(self):
# Check media format validation is working
# Empty
self.source.media_format = ''
@ -521,6 +521,12 @@ class FilepathTestCase(TestCase):
self.source.media_format = 'test-{dd}'
self.assertEqual(self.source.get_example_media_format(),
'test-' + timezone.now().strftime('%d'))
self.source.media_format = 'test-{hh}'
self.assertEqual(self.source.get_example_media_format(),
'test-' + timezone.now().strftime('%H'))
self.source.media_format = 'test-{min}'
self.assertEqual(self.source.get_example_media_format(),
'test-' + timezone.now().strftime('%M'))
self.source.media_format = 'test-{source}'
self.assertEqual(self.source.get_example_media_format(),
'test-' + self.source.slugname)