mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-25 14:36:34 +00:00
Use Media.has_metadata
in Media.save
function
This commit is contained in:
parent
98c031ed5f
commit
60ffc4cdc8
@ -830,12 +830,19 @@ class Media(models.Model):
|
|||||||
update_fields = {'media_file', 'skip'}.union(update_fields)
|
update_fields = {'media_file', 'skip'}.union(update_fields)
|
||||||
|
|
||||||
# Trigger an update of derived fields from metadata
|
# Trigger an update of derived fields from metadata
|
||||||
if update_fields is None or 'metadata' in update_fields:
|
update_md = (
|
||||||
|
self.created and
|
||||||
|
self.has_metadata and
|
||||||
|
(
|
||||||
|
update_fields is None or
|
||||||
|
'metadata' in update_fields
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if update_md:
|
||||||
setattr(self, '_cached_metadata_dict', None)
|
setattr(self, '_cached_metadata_dict', None)
|
||||||
if self.metadata:
|
|
||||||
self.title = self.metadata_title[:200]
|
self.title = self.metadata_title[:200]
|
||||||
self.duration = self.metadata_duration
|
self.duration = self.metadata_duration
|
||||||
if update_fields is not None and "metadata" in update_fields:
|
if update_fields is not None:
|
||||||
# If only some fields are being updated, make sure we update title and duration if metadata changes
|
# If only some fields are being updated, make sure we update title and duration if metadata changes
|
||||||
update_fields = {"title", "duration"}.union(update_fields)
|
update_fields = {"title", "duration"}.union(update_fields)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user