mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-27 01:16:36 +00:00
Use Media.get_metadata_field
This commit is contained in:
parent
b6334ce41c
commit
b8f8d9d7fa
@ -202,7 +202,7 @@ def index_source_task(source_id):
|
||||
source.last_crawl = timezone.now()
|
||||
source.save()
|
||||
log.info(f'Found {len(videos)} media items for source: {source}')
|
||||
fields = lambda x, t=source.source_type: Media.METADATA_FIELDS.get(x, dict()).get(t, x)
|
||||
fields = lambda f, m: m.get_metadata_field(f)
|
||||
for video in videos:
|
||||
# Create or update each video as a Media object
|
||||
key = video.get(source.key_field, None)
|
||||
@ -214,9 +214,9 @@ def index_source_task(source_id):
|
||||
except Media.DoesNotExist:
|
||||
media = Media(key=key)
|
||||
media.source = source
|
||||
media.duration = float(video.get(fields('duration'), 0)) or None
|
||||
media.title = str(video.get(fields('title'), ''))
|
||||
timestamp = video.get(fields('timestamp'), None)
|
||||
media.duration = float(video.get(fields('duration', media), 0)) or None
|
||||
media.title = str(video.get(fields('title', media), ''))
|
||||
timestamp = video.get(fields('timestamp', media), None)
|
||||
if timestamp is not None:
|
||||
try:
|
||||
timestamp_float = float(timestamp)
|
||||
|
Loading…
Reference in New Issue
Block a user