audioboom.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. from .common import InfoExtractor
  2. from ..utils import clean_html, float_or_none, traverse_obj, unescapeHTML
  3. class AudioBoomIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?audioboom\.com/(?:boos|posts)/(?P<id>[0-9]+)'
  5. _TESTS = [{
  6. 'url': 'https://audioboom.com/posts/7398103-asim-chaudhry',
  7. 'md5': '4d68be11c9f9daf3dab0778ad1e010c3',
  8. 'info_dict': {
  9. 'id': '7398103',
  10. 'ext': 'mp3',
  11. 'title': 'Asim Chaudhry',
  12. 'description': 'md5:0ed714ae0e81e5d9119cac2f618ad679',
  13. 'duration': 4000.99,
  14. 'uploader': 'Sue Perkins: An hour or so with...',
  15. 'uploader_url': r're:https?://(?:www\.)?audioboom\.com/channel/perkins',
  16. },
  17. }, { # Direct mp3-file link
  18. 'url': 'https://audioboom.com/posts/8128496.mp3',
  19. 'md5': 'e329edf304d450def95c7f86a9165ee1',
  20. 'info_dict': {
  21. 'id': '8128496',
  22. 'ext': 'mp3',
  23. 'title': 'TCRNo8 / DAILY 03 - In Control',
  24. 'description': 'md5:44665f142db74858dfa21c5b34787948',
  25. 'duration': 1689.7,
  26. 'uploader': 'Lost Dot Podcast: The Trans Pyrenees and Transcontinental Race',
  27. 'uploader_url': r're:https?://(?:www\.)?audioboom\.com/channels/5003904',
  28. },
  29. }, {
  30. 'url': 'https://audioboom.com/posts/4279833-3-09-2016-czaban-hour-3?t=0',
  31. 'only_matching': True,
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(f'https://audioboom.com/posts/{video_id}', video_id)
  36. clip_store = self._search_json(
  37. r'data-react-class="V5DetailPagePlayer"\s*data-react-props=["\']',
  38. webpage, 'clip store', video_id, fatal=False, transform_source=unescapeHTML)
  39. clip = traverse_obj(clip_store, ('clips', 0), expected_type=dict) or {}
  40. return {
  41. 'id': video_id,
  42. 'url': clip.get('clipURLPriorToLoading') or self._og_search_property('audio', webpage, 'audio url'),
  43. 'title': clip.get('title') or self._html_search_meta(['og:title', 'og:audio:title', 'audio_title'], webpage),
  44. 'description': (clip.get('description') or clean_html(clip.get('formattedDescription'))
  45. or self._og_search_description(webpage)),
  46. 'duration': float_or_none(clip.get('duration') or self._html_search_meta('weibo:audio:duration', webpage)),
  47. 'uploader': clip.get('author') or self._html_search_meta(
  48. ['og:audio:artist', 'twitter:audio:artist_name', 'audio_artist'], webpage, 'uploader'),
  49. 'uploader_url': clip.get('author_url') or self._html_search_regex(
  50. r'<div class="avatar flex-shrink-0">\s*<a href="(?P<uploader_url>http[^"]+)"',
  51. webpage, 'uploader url', fatal=False),
  52. }