3 from .common
import InfoExtractor
7 get_elements_text_and_html_by_attribute
,
14 # https://codex.wordpress.org/Playlist_Shortcode
15 class WordpressPlaylistEmbedIE(InfoExtractor
):
17 IE_NAME
= 'wordpress:playlist'
19 # 5 WordPress playlists. This is using wpse-playlist, which is similar.
20 # See: https://github.com/birgire/wpse-playlist
21 'url': 'https://xlino.com/wordpress-playlist-shortcode-with-external-audio-or-video-files/',
23 'id': 'wordpress-playlist-shortcode-with-external-audio-or-video-files',
24 'title': 'WordPress: Playlist shortcode with external audio or video files – Birgir Erlendsson (birgire)',
29 'url': 'https://pianoadventures.com/products/piano-adventures-level-1-lesson-book-enhanced-cd/',
31 'id': 'piano-adventures-level-1-lesson-book-enhanced-cd-wp-playlist-1',
32 'title': 'Wordpress Playlist',
33 'thumbnail': 'https://pianoadventures.com/wp-content/uploads/sites/13/2022/01/CD1002cover.jpg',
40 'title': '21 Half-Time Show',
41 'thumbnail': 'https://pianoadventures.com/wp-content/plugins/media-library-assistant/images/crystal/audio.png',
42 'album': 'Piano Adventures Level 1 Lesson Book (2nd Edition)',
45 'artist': 'Nancy and Randall Faber',
46 'description': 'md5:a9f8e9aeabbd2912bc13cc0fab1a4ce8',
50 'params': {'skip_download': True},
53 def _extract_from_webpage(self
, url
, webpage
):
54 # class should always be "wp-playlist-script"
55 # See: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/media.php#L2930
56 for i
, j
in enumerate(get_elements_by_class('wp-playlist-script', webpage
)):
57 playlist_json
= self
._parse
_json
(j
, self
._generic
_id
(url
), fatal
=False, ignore_extra
=True, errnote
='') or {}
61 'id': self
._generic
_id
(track
['src']),
62 'title': track
.get('title'),
63 'url': track
.get('src'),
64 'thumbnail': traverse_obj(track
, ('thumb', 'src')),
65 'album': traverse_obj(track
, ('meta', 'album')),
66 'artist': traverse_obj(track
, ('meta', 'artist')),
67 'genre': traverse_obj(track
, ('meta', 'genre')),
68 'duration': parse_duration(traverse_obj(track
, ('meta', 'length_formatted'))),
69 'description': track
.get('description'),
70 'height': int_or_none(traverse_obj(track
, ('dimensions', 'original', 'height'))),
71 'width': int_or_none(traverse_obj(track
, ('dimensions', 'original', 'width'))),
72 } for track
in traverse_obj(playlist_json
, ('tracks', ...), expected_type
=dict)]
73 yield self
.playlist_result(entries
, self
._generic
_id
(url
) + f
'-wp-playlist-{i + 1}', 'Wordpress Playlist')
76 class WordpressMiniAudioPlayerEmbedIE(InfoExtractor
):
77 # WordPress MB Mini Player Plugin
78 # https://wordpress.org/plugins/wp-miniaudioplayer/
79 # Note: This is for the WordPress plugin version only.
81 IE_NAME
= 'wordpress:mb.miniAudioPlayer'
83 # Version 1.8.10: https://plugins.trac.wordpress.org/browser/wp-miniaudioplayer/tags/1.8.10
84 'url': 'https://news.samsung.com/global/over-the-horizon-the-evolution-of-the-samsung-galaxy-brand-sound',
86 'id': 'over-the-horizon-the-evolution-of-the-samsung-galaxy-brand-sound',
87 'title': 'Over the Horizon: The Evolution of the Samsung Galaxy Brand Sound',
89 'thumbnail': 'https://img.global.news.samsung.com/global/wp-content/uploads/2015/04/OTH_Main_Title-e1429612467870.jpg',
90 'description': 'md5:bc3dd738d1f11d9232e94e6629983bf7',
94 'id': 'over_the_horizon_2013',
96 'title': 'Over the Horizon 2013',
97 'url': 'http://news.samsung.com/global/wp-content/uploads/ringtones/over_the_horizon_2013.mp3',
101 'params': {'skip_download': True},
103 # Version 1.9.3: https://plugins.trac.wordpress.org/browser/wp-miniaudioplayer/tags/1.9.3
104 'url': 'https://www.booksontape.com/collections/audiobooks-with-teacher-guides/',
106 'id': 'audiobooks-with-teacher-guides',
107 'title': 'Audiobooks with Teacher Guides | Books on Tape',
109 'thumbnail': 'https://www.booksontape.com/wp-content/uploads/2016/09/bot-logo-1200x630.jpg',
111 'playlist_mincount': 12,
113 # Version 1.9.7: https://plugins.trac.wordpress.org/browser/wp-miniaudioplayer/tags/1.9.7
114 # But has spaces around href filter
115 'url': 'https://www.estudiords.com.br/temas/',
118 'title': 'Temas Variados',
122 'thumbnail': 'https://www.estudiords.com.br/wp-content/uploads/2021/03/LOGO-TEMAS.png',
123 'description': 'md5:ab24d6a7ed0312ad2d466e721679f5a0',
125 'playlist_mincount': 30,
128 def _extract_from_webpage(self
, url
, webpage
):
129 # Common function for the WordPress plugin version only.
130 mb_player_params
= self
._search
_regex
(
131 r
'function\s*initializeMiniAudioPlayer\(\){[^}]+jQuery([^;]+)\.mb_miniPlayer',
132 webpage
, 'mb player params', default
=None)
133 if not mb_player_params
:
135 # v1.55 - 1.9.3 has "a[href*='.mp3'] ,a[href*='.m4a']"
136 # v1.9.4+ has "a[href*='.mp3']" only
137 file_exts
= re
.findall(r
'a\[href\s*\*=\s*\'\
.([a
-zA
-Z\d
]+)\'', mb_player_params)
141 candidates = get_elements_text_and_html_by_attribute(
142 'href
', rf'(?
:[^
\"\']+\
.(?
:{"|".join(file_exts
)}))', webpage, escape_value=False, tag='a
')
144 for title, html in candidates:
145 attrs = extract_attributes(html)
146 # XXX: not tested - have not found any example of it being used
147 if any(c in (attrs.get('class') or '') for c in re.findall(r'\
.not\
("\.([^"]+)', mb_player_params)):
151 'id': self._generic_id(href),
152 'title
': title or self._generic_title(href),