Add duration for uploaded items (closes #96)
This commit is contained in:
parent
7974715afd
commit
79148aab5a
3 changed files with 13 additions and 6 deletions
|
|
@ -45,13 +45,10 @@ def parse_playlist_items(results, menu_entries: List[List] = None):
|
|||
|
||||
duration = None
|
||||
if 'fixedColumns' in data:
|
||||
if 'simpleText' in data['fixedColumns'][0][
|
||||
'musicResponsiveListItemFixedColumnRenderer']['text']:
|
||||
duration = data['fixedColumns'][0][
|
||||
'musicResponsiveListItemFixedColumnRenderer']['text']['simpleText']
|
||||
if 'simpleText' in get_fixed_column_item(data, 0)['text']:
|
||||
duration = get_fixed_column_item(data, 0)['text']['simpleText']
|
||||
else:
|
||||
duration = data['fixedColumns'][0][
|
||||
'musicResponsiveListItemFixedColumnRenderer']['text']['runs'][0]['text']
|
||||
duration = get_fixed_column_item(data, 0)['text']['runs'][0]['text']
|
||||
|
||||
thumbnails = None
|
||||
if 'thumbnail' in data:
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@ def parse_uploaded_items(results):
|
|||
title = get_item_text(data, 0)
|
||||
like = nav(data, MENU_LIKE_STATUS)
|
||||
thumbnails = nav(data, THUMBNAILS) if 'thumbnail' in data else None
|
||||
duration = get_fixed_column_item(data, 0)['text']['runs'][0]['text']
|
||||
song = {
|
||||
'entityId': entityId,
|
||||
'videoId': videoId,
|
||||
'title': title,
|
||||
'duration': duration,
|
||||
'artist': None,
|
||||
'album': None,
|
||||
'likeStatus': like,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,14 @@ def get_flex_column_item(item, index):
|
|||
return item['flexColumns'][index]['musicResponsiveListItemFlexColumnRenderer']
|
||||
|
||||
|
||||
def get_fixed_column_item(item, index):
|
||||
if 'text' not in item['fixedColumns'][index]['musicResponsiveListItemFixedColumnRenderer'] or \
|
||||
'runs' not in item['fixedColumns'][index]['musicResponsiveListItemFixedColumnRenderer']['text']:
|
||||
return None
|
||||
|
||||
return item['fixedColumns'][index]['musicResponsiveListItemFixedColumnRenderer']
|
||||
|
||||
|
||||
def get_browse_id(item, index):
|
||||
if 'navigationEndpoint' not in item['text']['runs'][index]:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue