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.

69 lines
2.5 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|posts)/(?P<id>[0-9]+)'
  7. _TESTS = [{
  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': r're:https?://(?:www\.)?audioboom\.com/channel/steveczabanyahoosportsradio',
  18. }
  19. }, {
  20. 'url': 'https://audioboom.com/posts/4279833-3-09-2016-czaban-hour-3?t=0',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. clip = None
  27. clip_store = self._parse_json(
  28. self._search_regex(
  29. r'data-new-clip-store=(["\'])(?P<json>{.*?"clipId"\s*:\s*%s.*?})\1' % video_id,
  30. webpage, 'clip store', default='{}', group='json'),
  31. video_id, fatal=False)
  32. if clip_store:
  33. clips = clip_store.get('clips')
  34. if clips and isinstance(clips, list) and isinstance(clips[0], dict):
  35. clip = clips[0]
  36. def from_clip(field):
  37. if clip:
  38. clip.get(field)
  39. audio_url = from_clip('clipURLPriorToLoading') or self._og_search_property(
  40. 'audio', webpage, 'audio url')
  41. title = from_clip('title') or self._og_search_title(webpage)
  42. description = from_clip('description') or self._og_search_description(webpage)
  43. duration = float_or_none(from_clip('duration') or self._html_search_meta(
  44. 'weibo:audio:duration', webpage))
  45. uploader = from_clip('author') or self._og_search_property(
  46. 'audio:artist', webpage, 'uploader', fatal=False)
  47. uploader_url = from_clip('author_url') or self._html_search_meta(
  48. 'audioboo:channel', webpage, 'uploader url')
  49. return {
  50. 'id': video_id,
  51. 'url': audio_url,
  52. 'title': title,
  53. 'description': description,
  54. 'duration': duration,
  55. 'uploader': uploader,
  56. 'uploader_url': uploader_url,
  57. }