]>
Commit | Line | Data |
---|---|---|
61f317c2 BC |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
86f63633 RA |
5 | from ..utils import ( |
6 | clean_html, | |
7 | float_or_none, | |
8 | ) | |
61f317c2 BC |
9 | |
10 | ||
11 | class AudioBoomIE(InfoExtractor): | |
3eaaa8ab YCH |
12 | _VALID_URL = r'https?://(?:www\.)?audioboom\.com/(?:boos|posts)/(?P<id>[0-9]+)' |
13 | _TESTS = [{ | |
86f63633 RA |
14 | 'url': 'https://audioboom.com/posts/7398103-asim-chaudhry', |
15 | 'md5': '7b00192e593ff227e6a315486979a42d', | |
61f317c2 | 16 | 'info_dict': { |
86f63633 | 17 | 'id': '7398103', |
61f317c2 | 18 | 'ext': 'mp3', |
86f63633 RA |
19 | 'title': 'Asim Chaudhry', |
20 | 'description': 'md5:2f3fef17dacc2595b5362e1d7d3602fc', | |
21 | 'duration': 4000.99, | |
22 | 'uploader': 'Sue Perkins: An hour or so with...', | |
23 | 'uploader_url': r're:https?://(?:www\.)?audioboom\.com/channel/perkins', | |
61f317c2 | 24 | } |
3eaaa8ab YCH |
25 | }, { |
26 | 'url': 'https://audioboom.com/posts/4279833-3-09-2016-czaban-hour-3?t=0', | |
27 | 'only_matching': True, | |
28 | }] | |
61f317c2 BC |
29 | |
30 | def _real_extract(self, url): | |
31 | video_id = self._match_id(url) | |
883c0523 | 32 | |
61f317c2 BC |
33 | webpage = self._download_webpage(url, video_id) |
34 | ||
883c0523 S |
35 | clip = None |
36 | ||
37 | clip_store = self._parse_json( | |
86f63633 RA |
38 | self._html_search_regex( |
39 | r'data-new-clip-store=(["\'])(?P<json>{.+?})\1', | |
883c0523 S |
40 | webpage, 'clip store', default='{}', group='json'), |
41 | video_id, fatal=False) | |
42 | if clip_store: | |
43 | clips = clip_store.get('clips') | |
44 | if clips and isinstance(clips, list) and isinstance(clips[0], dict): | |
45 | clip = clips[0] | |
46 | ||
47 | def from_clip(field): | |
48 | if clip: | |
2583c0b5 | 49 | return clip.get(field) |
883c0523 S |
50 | |
51 | audio_url = from_clip('clipURLPriorToLoading') or self._og_search_property( | |
52 | 'audio', webpage, 'audio url') | |
86f63633 RA |
53 | title = from_clip('title') or self._html_search_meta( |
54 | ['og:title', 'og:audio:title', 'audio_title'], webpage) | |
55 | description = from_clip('description') or clean_html(from_clip('formattedDescription')) or self._og_search_description(webpage) | |
61f317c2 | 56 | |
883c0523 S |
57 | duration = float_or_none(from_clip('duration') or self._html_search_meta( |
58 | 'weibo:audio:duration', webpage)) | |
61f317c2 | 59 | |
86f63633 RA |
60 | uploader = from_clip('author') or self._html_search_meta( |
61 | ['og:audio:artist', 'twitter:audio:artist_name', 'audio_artist'], webpage, 'uploader') | |
883c0523 S |
62 | uploader_url = from_clip('author_url') or self._html_search_meta( |
63 | 'audioboo:channel', webpage, 'uploader url') | |
61f317c2 BC |
64 | |
65 | return { | |
66 | 'id': video_id, | |
883c0523 | 67 | 'url': audio_url, |
61f317c2 | 68 | 'title': title, |
883c0523 | 69 | 'description': description, |
61f317c2 | 70 | 'duration': duration, |
883c0523 S |
71 | 'uploader': uploader, |
72 | 'uploader_url': uploader_url, | |
61f317c2 | 73 | } |