if media is downloaded use the downloaded filename and not generated filenames based on metadata parameters for addtional metadata files, resolves, resolves #67, resolves #83, resolves #204

This commit is contained in:
meeb 2022-04-06 16:24:53 +10:00
parent 2335ceb2dc
commit 538b3cb319
2 changed files with 35 additions and 5 deletions

View File

@ -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'),
),
]

View File

@ -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'