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.

49 lines
1.6 KiB

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