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.

42 lines
1.5 KiB

11 years ago
  1. import json
  2. import re
  3. from .common import InfoExtractor
  4. class TvpIE(InfoExtractor):
  5. IE_NAME = u'tvp.pl'
  6. _VALID_URL = r'https?://www\.tvp\.pl/.*?wideo/(?P<date>\d+)/(?P<id>\d+)'
  7. _TEST = {
  8. u'url': u'http://www.tvp.pl/warszawa/magazyny/campusnews/wideo/31102013/12878238',
  9. u'md5': u'148408967a6a468953c0a75cbdaf0d7a',
  10. u'file': u'12878238.wmv',
  11. u'info_dict': {
  12. u'title': u'31.10.2013 - Odcinek 2',
  13. u'description': u'31.10.2013 - Odcinek 2',
  14. },
  15. u'skip': u'Download has to use same server IP as extraction. Therefore, a good (load-balancing) DNS resolver will make the download fail.'
  16. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. json_url = 'http://www.tvp.pl/pub/stat/videofileinfo?video_id=%s' % video_id
  22. json_params = self._download_webpage(
  23. json_url, video_id, u"Downloading video metadata")
  24. params = json.loads(json_params)
  25. self.report_extraction(video_id)
  26. video_url = params['video_url']
  27. title = self._og_search_title(webpage, fatal=True)
  28. return {
  29. 'id': video_id,
  30. 'title': title,
  31. 'ext': 'wmv',
  32. 'url': video_url,
  33. 'description': self._og_search_description(webpage),
  34. 'thumbnail': self._og_search_thumbnail(webpage),
  35. }