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.

41 lines
1.3 KiB

  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. }
  16. def _real_extract(self, url):
  17. mobj = re.match(self._VALID_URL, url)
  18. video_id = mobj.group('id')
  19. webpage = self._download_webpage(url, video_id)
  20. json_url = 'http://www.tvp.pl/pub/stat/videofileinfo?video_id=%s' % video_id
  21. json_params = self._download_webpage(
  22. json_url, video_id, u"Downloading video metadata")
  23. params = json.loads(json_params)
  24. self.report_extraction(video_id)
  25. video_url = params['video_url']
  26. title = self._og_search_title(webpage, fatal=True)
  27. return {
  28. 'id': video_id,
  29. 'title': title,
  30. 'ext': 'wmv',
  31. 'url': video_url,
  32. 'description': self._og_search_description(webpage),
  33. 'thumbnail': self._og_search_thumbnail(webpage),
  34. }