]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/wordpress.py
1 from .common
import InfoExtractor
10 # https://codex.wordpress.org/Playlist_Shortcode
11 class WordpressPlaylistEmbedIE(InfoExtractor
):
13 IE_NAME
= 'wordpress:playlist'
15 # 5 WordPress playlists. This is using wpse-playlist, which is similar.
16 # See: https://github.com/birgire/wpse-playlist
17 'url': 'https://xlino.com/wordpress-playlist-shortcode-with-external-audio-or-video-files/',
19 'id': 'wordpress-playlist-shortcode-with-external-audio-or-video-files',
20 'title': 'WordPress: Playlist shortcode with external audio or video files – Birgir Erlendsson (birgire)',
25 'url': 'https://pianoadventures.com/products/piano-adventures-level-1-lesson-book-enhanced-cd/',
27 'id': 'piano-adventures-level-1-lesson-book-enhanced-cd-wp-playlist-1',
28 'title': 'Wordpress Playlist',
29 'thumbnail': 'https://pianoadventures.com/wp-content/uploads/sites/13/2022/01/CD1002cover.jpg',
36 'title': '21 Half-Time Show',
37 'thumbnail': 'https://pianoadventures.com/wp-content/plugins/media-library-assistant/images/crystal/audio.png',
38 'album': 'Piano Adventures Level 1 Lesson Book (2nd Edition)',
41 'artist': 'Nancy and Randall Faber',
42 'description': 'md5:a9f8e9aeabbd2912bc13cc0fab1a4ce8',
46 'params': {'skip_download': True}
49 def _extract_from_webpage(self
, url
, webpage
):
50 # class should always be "wp-playlist-script"
51 # See: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/media.php#L2930
52 for i
, j
in enumerate(get_elements_by_class('wp-playlist-script', webpage
)):
53 playlist_json
= self
._parse
_json
(j
, self
._generic
_id
(url
), fatal
=False, ignore_extra
=True, errnote
='') or {}
57 'id': self
._generic
_id
(track
['src']),
58 'title': track
.get('title'),
59 'url': track
.get('src'),
60 'thumbnail': traverse_obj(track
, ('thumb', 'src')),
61 'album': traverse_obj(track
, ('meta', 'album')),
62 'artist': traverse_obj(track
, ('meta', 'artist')),
63 'genre': traverse_obj(track
, ('meta', 'genre')),
64 'duration': parse_duration(traverse_obj(track
, ('meta', 'length_formatted'))),
65 'description': track
.get('description'),
66 'height': int_or_none(traverse_obj(track
, ('dimensions', 'original', 'height'))),
67 'width': int_or_none(traverse_obj(track
, ('dimensions', 'original', 'width'))),
68 } for track
in traverse_obj(playlist_json
, ('tracks', ...), expected_type
=dict)]
69 yield self
.playlist_result(entries
, self
._generic
_id
(url
) + f
'-wp-playlist-{i+1}', 'Wordpress Playlist')