]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/audioboom.py
debian/rules: Adapt to new upstream build system.
[youtubedl] / youtube_dl / extractor / audioboom.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import float_or_none
6
7
8 class AudioBoomIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?audioboom\.com/boos/(?P<id>[0-9]+)'
10 _TEST = {
11 'url': 'https://audioboom.com/boos/4279833-3-09-2016-czaban-hour-3?t=0',
12 'md5': '63a8d73a055c6ed0f1e51921a10a5a76',
13 'info_dict': {
14 'id': '4279833',
15 'ext': 'mp3',
16 'title': '3/09/2016 Czaban Hour 3',
17 'description': 'Guest: Nate Davis - NFL free agency, Guest: Stan Gans',
18 'duration': 2245.72,
19 'uploader': 'Steve Czaban',
20 'uploader_url': 're:https?://(?:www\.)?audioboom\.com/channel/steveczabanyahoosportsradio',
21 }
22 }
23
24 def _real_extract(self, url):
25 video_id = self._match_id(url)
26
27 webpage = self._download_webpage(url, video_id)
28
29 clip = None
30
31 clip_store = self._parse_json(
32 self._search_regex(
33 r'data-new-clip-store=(["\'])(?P<json>{.*?"clipId"\s*:\s*%s.*?})\1' % video_id,
34 webpage, 'clip store', default='{}', group='json'),
35 video_id, fatal=False)
36 if clip_store:
37 clips = clip_store.get('clips')
38 if clips and isinstance(clips, list) and isinstance(clips[0], dict):
39 clip = clips[0]
40
41 def from_clip(field):
42 if clip:
43 clip.get(field)
44
45 audio_url = from_clip('clipURLPriorToLoading') or self._og_search_property(
46 'audio', webpage, 'audio url')
47 title = from_clip('title') or self._og_search_title(webpage)
48 description = from_clip('description') or self._og_search_description(webpage)
49
50 duration = float_or_none(from_clip('duration') or self._html_search_meta(
51 'weibo:audio:duration', webpage))
52
53 uploader = from_clip('author') or self._og_search_property(
54 'audio:artist', webpage, 'uploader', fatal=False)
55 uploader_url = from_clip('author_url') or self._html_search_meta(
56 'audioboo:channel', webpage, 'uploader url')
57
58 return {
59 'id': video_id,
60 'url': audio_url,
61 'title': title,
62 'description': description,
63 'duration': duration,
64 'uploader': uploader,
65 'uploader_url': uploader_url,
66 }