[youtube] Always add id and url to playlist results.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabio Manganiello 2024-07-12 03:12:04 +02:00
parent c8fa53e62f
commit 7266fe8a43
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -199,12 +199,22 @@ class PipedPlaylistSchema(Schema):
},
)
url = fields.Url(
metadata={
'description': 'Playlist URL',
'example': 'https://youtube.com/playlist?list=1234567890',
},
)
@pre_dump
def fill_urls(self, data: dict, **_):
for attr in ('url', 'uploaderUrl'):
if data.get(attr) and not data[attr].startswith('https://'):
data[attr] = f'https://youtube.com{data[attr]}'
if not data.get('id') and data.get('url'):
data['id'] = data['url'].split('=')[-1]
return data
@pre_dump