Handle the None or '' cases without logs

This was happening way more often than I expected.
This commit is contained in:
tcely 2025-03-04 15:51:12 -05:00 committed by GitHub
parent 2a0555376e
commit acb74dcc41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1190,11 +1190,13 @@ class Media(models.Model):
@property
def upload_date(self):
upload_date_str = self.get_metadata_first_value('upload_date', '')
upload_date_str = self.get_metadata_first_value('upload_date')
if not upload_date_str:
return None
try:
return datetime.strptime(upload_date_str, '%Y%m%d')
except (AttributeError, ValueError) as e:
log.debug(f'Media.upload_date: {self.source} / {self}: strptime: {upload_date_str=}: {e}')
log.debug(f'Media.upload_date: {self.source} / {self}: strptime: {e}')
pass
return None