mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 06:35:12 +00:00 
			
		
		
		
	[BravoTV] Improve metadata extraction (#483)
Authored by: kevinoconnor7
This commit is contained in:
		| @@ -8,6 +8,9 @@ from ..utils import ( | ||||
|     smuggle_url, | ||||
|     update_url_query, | ||||
|     int_or_none, | ||||
|     float_or_none, | ||||
|     try_get, | ||||
|     dict_get, | ||||
| ) | ||||
|  | ||||
|  | ||||
| @@ -24,6 +27,11 @@ class BravoTVIE(AdobePassIE): | ||||
|             'uploader': 'NBCU-BRAV', | ||||
|             'upload_date': '20190314', | ||||
|             'timestamp': 1552591860, | ||||
|             'season_number': 16, | ||||
|             'episode_number': 15, | ||||
|             'series': 'Top Chef', | ||||
|             'episode': 'The Top Chef Season 16 Winner Is...', | ||||
|             'duration': 190.0, | ||||
|         } | ||||
|     }, { | ||||
|         'url': 'http://www.bravotv.com/below-deck/season-3/ep-14-reunion-part-1', | ||||
| @@ -79,12 +87,34 @@ class BravoTVIE(AdobePassIE): | ||||
|                 'episode_number': int_or_none(metadata.get('episode_num')), | ||||
|             }) | ||||
|             query['switch'] = 'progressive' | ||||
|  | ||||
|         tp_url = 'http://link.theplatform.com/s/%s/%s' % (account_pid, tp_path) | ||||
|  | ||||
|         tp_metadata = self._download_json( | ||||
|             update_url_query(tp_url, {'format': 'preview'}), | ||||
|             display_id, fatal=False) | ||||
|         if tp_metadata: | ||||
|             info.update({ | ||||
|                 'title': tp_metadata.get('title'), | ||||
|                 'description': tp_metadata.get('description'), | ||||
|                 'duration': float_or_none(tp_metadata.get('duration'), 1000), | ||||
|                 'season_number': int_or_none( | ||||
|                     dict_get(tp_metadata, ('pl1$seasonNumber', 'nbcu$seasonNumber'))), | ||||
|                 'episode_number': int_or_none( | ||||
|                     dict_get(tp_metadata, ('pl1$episodeNumber', 'nbcu$episodeNumber'))), | ||||
|                 # For some reason the series is sometimes wrapped into a single element array. | ||||
|                 'series': try_get( | ||||
|                     dict_get(tp_metadata, ('pl1$show', 'nbcu$show')), | ||||
|                     lambda x: x[0] if isinstance(x, list) else x, | ||||
|                     expected_type=str), | ||||
|                 'episode': dict_get( | ||||
|                     tp_metadata, ('pl1$episodeName', 'nbcu$episodeName', 'title')), | ||||
|             }) | ||||
|  | ||||
|         info.update({ | ||||
|             '_type': 'url_transparent', | ||||
|             'id': release_pid, | ||||
|             'url': smuggle_url(update_url_query( | ||||
|                 'http://link.theplatform.com/s/%s/%s' % (account_pid, tp_path), | ||||
|                 query), {'force_smil_url': True}), | ||||
|             'url': smuggle_url(update_url_query(tp_url, query), {'force_smil_url': True}), | ||||
|             'ie_key': 'ThePlatform', | ||||
|         }) | ||||
|         return info | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kevin O'Connor
					Kevin O'Connor