From 37b15ed625838c2bdfe2cda066597e6924fcac6a Mon Sep 17 00:00:00 2001 From: tcely Date: Mon, 17 Feb 2025 08:23:49 -0500 Subject: [PATCH] Use `Media.metadata_published` for indexing also --- tubesync/sync/tasks.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index b90113cb..fd6ec53b 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -217,15 +217,9 @@ def index_source_task(source_id): media.duration = float(video.get(fields('duration', media), None) or 0) or None media.title = str(video.get(fields('title', media), ''))[:200] timestamp = video.get(fields('timestamp', media), None) - if timestamp is not None: - try: - timestamp_float = float(timestamp) - posix_epoch = datetime(1970, 1, 1, tzinfo=tz.utc) - published_dt = posix_epoch + timedelta(seconds=timestamp_float) - except Exception as e: - log.warn(f'Could not set published for: {source} / {media} with "{e}"') - else: - media.published = published_dt + published_dt = media.metadata_published(timestamp) + if published_dt is not None: + media.published = published_dt try: media.save() log.debug(f'Indexed media: {source} / {media}')