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.

71 lines
2.6 KiB

  1. # coding: utf-8
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. unified_strdate,
  7. )
  8. class TouTvIE(InfoExtractor):
  9. IE_NAME = u'tou.tv'
  10. _VALID_URL = r'https?://www\.tou\.tv/(?P<id>[a-zA-Z0-9_-]+(?:/(?P<episode>S[0-9]+E[0-9]+)))'
  11. _TEST = {
  12. u'url': u'http://www.tou.tv/30-vies/S04E41',
  13. u'file': u'30-vies_S04E41.mp4',
  14. u'info_dict': {
  15. u'title': u'30 vies Saison 4 / Épisode 41',
  16. u'description': u'md5:da363002db82ccbe4dafeb9cab039b09',
  17. u'age_limit': 8,
  18. u'uploader': u'Groupe des Nouveaux Médias',
  19. u'duration': 1296,
  20. u'upload_date': u'20131118',
  21. u'thumbnail': u'http://static.tou.tv/medias/images/2013-11-18_19_00_00_30VIES_0341_01_L.jpeg',
  22. },
  23. u'params': {
  24. u'skip_download': True, # Requires rtmpdump
  25. },
  26. u'skip': 'Only available in Canada'
  27. }
  28. def _real_extract(self, url):
  29. mobj = re.match(self._VALID_URL, url)
  30. video_id = mobj.group('id')
  31. webpage = self._download_webpage(url, video_id)
  32. mediaId = self._search_regex(
  33. r'"idMedia":\s*"([^"]+)"', webpage, u'media ID')
  34. streams_url = u'http://release.theplatform.com/content.select?pid=' + mediaId
  35. streams_doc = self._download_xml(
  36. streams_url, video_id, note=u'Downloading stream list')
  37. video_url = next(n.text
  38. for n in streams_doc.findall('.//choice/url')
  39. if u'//ad.doubleclick' not in n.text)
  40. if video_url.endswith('/Unavailable.flv'):
  41. raise ExtractorError(
  42. u'Access to this video is blocked from outside of Canada',
  43. expected=True)
  44. duration_str = self._html_search_meta(
  45. 'video:duration', webpage, u'duration')
  46. duration = int(duration_str) if duration_str else None
  47. upload_date_str = self._html_search_meta(
  48. 'video:release_date', webpage, u'upload date')
  49. upload_date = unified_strdate(upload_date_str) if upload_date_str else None
  50. return {
  51. 'id': video_id,
  52. 'title': self._og_search_title(webpage),
  53. 'url': video_url,
  54. 'description': self._og_search_description(webpage),
  55. 'uploader': self._dc_search_uploader(webpage),
  56. 'thumbnail': self._og_search_thumbnail(webpage),
  57. 'age_limit': self._media_rating_search(webpage),
  58. 'duration': duration,
  59. 'upload_date': upload_date,
  60. 'ext': 'mp4',
  61. }