mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-14 15:22:35 +00:00
[extractor/audioboom] Support direct URLs and refactor (#4803)
Authored by: tpikonen, pukkandan
This commit is contained in:
parent
11398b922c
commit
8dbad2a439
1 changed files with 31 additions and 39 deletions
|
@ -2,6 +2,8 @@ from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
clean_html,
|
clean_html,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
|
unescapeHTML,
|
||||||
|
traverse_obj,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,16 +11,28 @@ class AudioBoomIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(?:www\.)?audioboom\.com/(?:boos|posts)/(?P<id>[0-9]+)'
|
_VALID_URL = r'https?://(?:www\.)?audioboom\.com/(?:boos|posts)/(?P<id>[0-9]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://audioboom.com/posts/7398103-asim-chaudhry',
|
'url': 'https://audioboom.com/posts/7398103-asim-chaudhry',
|
||||||
'md5': '7b00192e593ff227e6a315486979a42d',
|
'md5': '4d68be11c9f9daf3dab0778ad1e010c3',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '7398103',
|
'id': '7398103',
|
||||||
'ext': 'mp3',
|
'ext': 'mp3',
|
||||||
'title': 'Asim Chaudhry',
|
'title': 'Asim Chaudhry',
|
||||||
'description': 'md5:2f3fef17dacc2595b5362e1d7d3602fc',
|
'description': 'md5:0ed714ae0e81e5d9119cac2f618ad679',
|
||||||
'duration': 4000.99,
|
'duration': 4000.99,
|
||||||
'uploader': 'Sue Perkins: An hour or so with...',
|
'uploader': 'Sue Perkins: An hour or so with...',
|
||||||
'uploader_url': r're:https?://(?:www\.)?audioboom\.com/channel/perkins',
|
'uploader_url': r're:https?://(?:www\.)?audioboom\.com/channel/perkins',
|
||||||
}
|
}
|
||||||
|
}, { # Direct mp3-file link
|
||||||
|
'url': 'https://audioboom.com/posts/8128496.mp3',
|
||||||
|
'md5': 'e329edf304d450def95c7f86a9165ee1',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '8128496',
|
||||||
|
'ext': 'mp3',
|
||||||
|
'title': 'TCRNo8 / DAILY 03 - In Control',
|
||||||
|
'description': 'md5:44665f142db74858dfa21c5b34787948',
|
||||||
|
'duration': 1689.7,
|
||||||
|
'uploader': 'Lost Dot Podcast: The Trans Pyrenees and Transcontinental Race',
|
||||||
|
'uploader_url': r're:https?://(?:www\.)?audioboom\.com/channels/5003904',
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://audioboom.com/posts/4279833-3-09-2016-czaban-hour-3?t=0',
|
'url': 'https://audioboom.com/posts/4279833-3-09-2016-czaban-hour-3?t=0',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
|
@ -26,45 +40,23 @@ class AudioBoomIE(InfoExtractor):
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
webpage = self._download_webpage(f'https://audioboom.com/posts/{video_id}', video_id)
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
clip_store = self._search_json(
|
||||||
|
r'data-react-class="V5DetailPagePlayer"\s*data-react-props=["\']',
|
||||||
clip = None
|
webpage, 'clip store', video_id, fatal=False, transform_source=unescapeHTML)
|
||||||
|
clip = traverse_obj(clip_store, ('clips', 0), expected_type=dict) or {}
|
||||||
clip_store = self._parse_json(
|
|
||||||
self._html_search_regex(
|
|
||||||
r'data-new-clip-store=(["\'])(?P<json>{.+?})\1',
|
|
||||||
webpage, 'clip store', default='{}', group='json'),
|
|
||||||
video_id, fatal=False)
|
|
||||||
if clip_store:
|
|
||||||
clips = clip_store.get('clips')
|
|
||||||
if clips and isinstance(clips, list) and isinstance(clips[0], dict):
|
|
||||||
clip = clips[0]
|
|
||||||
|
|
||||||
def from_clip(field):
|
|
||||||
if clip:
|
|
||||||
return clip.get(field)
|
|
||||||
|
|
||||||
audio_url = from_clip('clipURLPriorToLoading') or self._og_search_property(
|
|
||||||
'audio', webpage, 'audio url')
|
|
||||||
title = from_clip('title') or self._html_search_meta(
|
|
||||||
['og:title', 'og:audio:title', 'audio_title'], webpage)
|
|
||||||
description = from_clip('description') or clean_html(from_clip('formattedDescription')) or self._og_search_description(webpage)
|
|
||||||
|
|
||||||
duration = float_or_none(from_clip('duration') or self._html_search_meta(
|
|
||||||
'weibo:audio:duration', webpage))
|
|
||||||
|
|
||||||
uploader = from_clip('author') or self._html_search_meta(
|
|
||||||
['og:audio:artist', 'twitter:audio:artist_name', 'audio_artist'], webpage, 'uploader')
|
|
||||||
uploader_url = from_clip('author_url') or self._html_search_meta(
|
|
||||||
'audioboo:channel', webpage, 'uploader url')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': audio_url,
|
'url': clip.get('clipURLPriorToLoading') or self._og_search_property('audio', webpage, 'audio url'),
|
||||||
'title': title,
|
'title': clip.get('title') or self._html_search_meta(['og:title', 'og:audio:title', 'audio_title'], webpage),
|
||||||
'description': description,
|
'description': (clip.get('description') or clean_html(clip.get('formattedDescription'))
|
||||||
'duration': duration,
|
or self._og_search_description(webpage)),
|
||||||
'uploader': uploader,
|
'duration': float_or_none(clip.get('duration') or self._html_search_meta('weibo:audio:duration', webpage)),
|
||||||
'uploader_url': uploader_url,
|
'uploader': clip.get('author') or self._html_search_meta(
|
||||||
|
['og:audio:artist', 'twitter:audio:artist_name', 'audio_artist'], webpage, 'uploader'),
|
||||||
|
'uploader_url': clip.get('author_url') or self._html_search_regex(
|
||||||
|
r'<div class="avatar flex-shrink-0">\s*<a href="(?P<uploader_url>http[^"]+)"',
|
||||||
|
webpage, 'uploader url', fatal=False),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue