diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 0ace2880..ebd35353 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -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, diff --git a/tubesync/sync/templates/sync/_mediaformatvars.html b/tubesync/sync/templates/sync/_mediaformatvars.html index 4a0b3e95..5f01a97b 100644 --- a/tubesync/sync/templates/sync/_mediaformatvars.html +++ b/tubesync/sync/templates/sync/_mediaformatvars.html @@ -25,14 +25,24 @@ {mm} - Media publish year in MM + Media publish month in MM 01 {dd} - Media publish year in DD + Media publish day in DD 31 + + {hh} + Media publish hour in HH + 12 + + + {min} + Media publish minutes in MM + 46 + {source} Lower case source name, max 80 chars diff --git a/tubesync/sync/tests.py b/tubesync/sync/tests.py index 2f40f87f..7130cbf3 100644 --- a/tubesync/sync/tests.py +++ b/tubesync/sync/tests.py @@ -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)