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.

52 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class PodomaticIE(InfoExtractor):
  7. IE_NAME = 'podomatic'
  8. _VALID_URL = r'^(?P<proto>https?)://(?P<channel>[^.]+)\.podomatic\.com/entry/(?P<id>[^?]+)'
  9. _TEST = {
  10. "url": "http://scienceteachingtips.podomatic.com/entry/2009-01-02T16_03_35-08_00",
  11. "file": "2009-01-02T16_03_35-08_00.mp3",
  12. "md5": "84bb855fcf3429e6bf72460e1eed782d",
  13. "info_dict": {
  14. "uploader": "Science Teaching Tips",
  15. "uploader_id": "scienceteachingtips",
  16. "title": "64. When the Moon Hits Your Eye",
  17. "duration": 446,
  18. }
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. video_id = mobj.group('id')
  23. channel = mobj.group('channel')
  24. json_url = (('%s://%s.podomatic.com/entry/embed_params/%s' +
  25. '?permalink=true&rtmp=0') %
  26. (mobj.group('proto'), channel, video_id))
  27. data_json = self._download_webpage(
  28. json_url, video_id, note=u'Downloading video info')
  29. data = json.loads(data_json)
  30. video_url = data['downloadLink']
  31. uploader = data['podcast']
  32. title = data['title']
  33. thumbnail = data['imageLocation']
  34. duration = int_or_none(data.get('length'), 1000)
  35. return {
  36. 'id': video_id,
  37. 'url': video_url,
  38. 'title': title,
  39. 'uploader': uploader,
  40. 'uploader_id': channel,
  41. 'thumbnail': thumbnail,
  42. 'duration': duration,
  43. }