diff --git a/tubesync/sync/migrations/0012_alter_media_downloaded_format.py b/tubesync/sync/migrations/0012_alter_media_downloaded_format.py new file mode 100644 index 0000000..3e733ef --- /dev/null +++ b/tubesync/sync/migrations/0012_alter_media_downloaded_format.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.12 on 2022-04-06 06:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('sync', '0011_auto_20220201_1654'), + ] + + operations = [ + migrations.AlterField( + model_name='media', + name='downloaded_format', + field=models.CharField(blank=True, help_text='Video format (resolution) of the downloaded media', max_length=30, null=True, verbose_name='downloaded format'), + ), + ] diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index f65611f..15437f6 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -691,7 +691,7 @@ class Media(models.Model): max_length=30, blank=True, null=True, - help_text=_('Audio codec of the downloaded media') + help_text=_('Video format (resolution) of the downloaded media') ) downloaded_height = models.PositiveIntegerField( _('downloaded height'), @@ -832,7 +832,10 @@ class Media(models.Model): 'hdr': hdr, 'format': tuple(fmt), } - resolution = f'{self.downloaded_height}p' + if self.downloaded_format: + resolution = self.downloaded_format.lower() + elif self.downloaded_height: + resolution = f'{self.downloaded_height}p' if self.downloaded_format != 'audio': vcodec = self.downloaded_video_codec.lower() fmt.append(vcodec) @@ -1064,7 +1067,10 @@ class Media(models.Model): @property def thumbname(self): - filename = self.filename + if self.downloaded and self.media_file: + filename = os.path.basename(self.media_file.path) + else: + filename = self.filename prefix, ext = os.path.splitext(filename) return f'{prefix}.jpg' @@ -1074,7 +1080,10 @@ class Media(models.Model): @property def nfoname(self): - filename = self.filename + if self.downloaded and self.media_file: + filename = os.path.basename(self.media_file.path) + else: + filename = self.filename prefix, ext = os.path.splitext(filename) return f'{prefix}.nfo' @@ -1084,7 +1093,10 @@ class Media(models.Model): @property def jsonname(self): - filename = os.path.basename(self.media_file.path) + if self.downloaded and self.media_file: + filename = os.path.basename(self.media_file.path) + else: + filename = self.filename prefix, ext = os.path.splitext(filename) return f'{prefix}.info.json'