Skip to content

Commit

Permalink
Merge pull request #800 from tcely/patch-9
Browse files Browse the repository at this point in the history
Set `Media.download_date` for imported files
  • Loading branch information
meeb authored Mar 6, 2025
2 parents bddb7a6 + b8503fd commit 0856c29
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tubesync/sync/management/commands/import-existing-media.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,18 @@ def handle(self, *args, **options):
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')

0 comments on commit 0856c29

Please sign in to comment.