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.

74 lines
2.6 KiB

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