You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.4 KiB

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