Merge pull request #800 from tcely/patch-9
Some checks are pending
Run Django tests for TubeSync / test (3.10) (push) Waiting to run
Run Django tests for TubeSync / test (3.11) (push) Waiting to run
Run Django tests for TubeSync / test (3.12) (push) Waiting to run
Run Django tests for TubeSync / test (3.8) (push) Waiting to run
Run Django tests for TubeSync / test (3.9) (push) Waiting to run
Run Django tests for TubeSync / containerise (push) Waiting to run

Set `Media.download_date` for imported files
This commit is contained in:
meeb 2025-03-07 00:33:25 +11:00 committed by GitHub
commit 0856c29b4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,5 +54,18 @@ class Command(BaseCommand):
item.media_file.name = str(Path(filepath).relative_to(item.media_file.storage.location))
item.downloaded = True
item.downloaded_filesize = Path(filepath).stat().st_size
# set a reasonable download date
date = item.metadata_published(Path(filepath).stat().st_mtime)
if item.published and item.published > date:
date = item.published
if item.has_metadata:
# TODO: switch to the newer function when it is merged from PR 807
# item.get_metadata_first_value('epoch', 0)
metadata_date = item.metadata_published(item.loaded_metadata.get('epoch', 0))
if metadata_date and metadata_date > date:
date = metadata_date
if item.download_date and item.download_date > date:
date = item.download_date
item.download_date = date
item.save()
log.info('Done')