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.

141 lines
5.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import itertools
  5. from .common import InfoExtractor
  6. class VierIE(InfoExtractor):
  7. IE_NAME = 'vier'
  8. IE_DESC = 'vier.be and vijf.be'
  9. _VALID_URL = r'https?://(?:www\.)?(?P<site>vier|vijf)\.be/(?:[^/]+/videos/(?P<display_id>[^/]+)(?:/(?P<id>\d+))?|video/v3/embed/(?P<embed_id>\d+))'
  10. _TESTS = [{
  11. 'url': 'http://www.vier.be/planb/videos/het-wordt-warm-de-moestuin/16129',
  12. 'info_dict': {
  13. 'id': '16129',
  14. 'display_id': 'het-wordt-warm-de-moestuin',
  15. 'ext': 'mp4',
  16. 'title': 'Het wordt warm in De Moestuin',
  17. 'description': 'De vele uren werk eisen hun tol. Wim droomt van assistentie...',
  18. },
  19. 'params': {
  20. # m3u8 download
  21. 'skip_download': True,
  22. },
  23. }, {
  24. 'url': 'http://www.vijf.be/temptationisland/videos/zo-grappig-temptation-island-hosts-moeten-kiezen-tussen-onmogelijke-dilemmas/2561614',
  25. 'info_dict': {
  26. 'id': '2561614',
  27. 'display_id': 'zo-grappig-temptation-island-hosts-moeten-kiezen-tussen-onmogelijke-dilemmas',
  28. 'ext': 'mp4',
  29. 'title': 'ZO grappig: Temptation Island hosts moeten kiezen tussen onmogelijke dilemma\'s',
  30. 'description': 'Het spel is simpel: Annelien Coorevits en Rick Brandsteder krijgen telkens 2 dilemma\'s voorgeschoteld en ze MOETEN een keuze maken.',
  31. },
  32. 'params': {
  33. # m3u8 download
  34. 'skip_download': True,
  35. },
  36. }, {
  37. 'url': 'http://www.vier.be/planb/videos/mieren-herders-van-de-bladluizen',
  38. 'only_matching': True,
  39. }, {
  40. 'url': 'http://www.vier.be/video/v3/embed/16129',
  41. 'only_matching': True,
  42. }]
  43. def _real_extract(self, url):
  44. mobj = re.match(self._VALID_URL, url)
  45. embed_id = mobj.group('embed_id')
  46. display_id = mobj.group('display_id') or embed_id
  47. site = mobj.group('site')
  48. webpage = self._download_webpage(url, display_id)
  49. video_id = self._search_regex(
  50. [r'data-nid="(\d+)"', r'"nid"\s*:\s*"(\d+)"'],
  51. webpage, 'video id')
  52. application = self._search_regex(
  53. [r'data-application="([^"]+)"', r'"application"\s*:\s*"([^"]+)"'],
  54. webpage, 'application', default=site + '_vod')
  55. filename = self._search_regex(
  56. [r'data-filename="([^"]+)"', r'"filename"\s*:\s*"([^"]+)"'],
  57. webpage, 'filename')
  58. playlist_url = 'http://vod.streamcloud.be/%s/_definst_/mp4:%s.mp4/playlist.m3u8' % (application, filename)
  59. formats = self._extract_wowza_formats(playlist_url, display_id, skip_protocols=['dash'])
  60. self._sort_formats(formats)
  61. title = self._og_search_title(webpage, default=display_id)
  62. description = self._og_search_description(webpage, default=None)
  63. thumbnail = self._og_search_thumbnail(webpage, default=None)
  64. return {
  65. 'id': video_id,
  66. 'display_id': display_id,
  67. 'title': title,
  68. 'description': description,
  69. 'thumbnail': thumbnail,
  70. 'formats': formats,
  71. }
  72. class VierVideosIE(InfoExtractor):
  73. IE_NAME = 'vier:videos'
  74. _VALID_URL = r'https?://(?:www\.)?(?P<site>vier|vijf)\.be/(?P<program>[^/]+)/videos(?:\?.*\bpage=(?P<page>\d+)|$)'
  75. _TESTS = [{
  76. 'url': 'http://www.vier.be/demoestuin/videos',
  77. 'info_dict': {
  78. 'id': 'demoestuin',
  79. },
  80. 'playlist_mincount': 153,
  81. }, {
  82. 'url': 'http://www.vijf.be/temptationisland/videos',
  83. 'info_dict': {
  84. 'id': 'temptationisland',
  85. },
  86. 'playlist_mincount': 159,
  87. }, {
  88. 'url': 'http://www.vier.be/demoestuin/videos?page=6',
  89. 'info_dict': {
  90. 'id': 'demoestuin-page6',
  91. },
  92. 'playlist_mincount': 20,
  93. }, {
  94. 'url': 'http://www.vier.be/demoestuin/videos?page=7',
  95. 'info_dict': {
  96. 'id': 'demoestuin-page7',
  97. },
  98. 'playlist_mincount': 13,
  99. }]
  100. def _real_extract(self, url):
  101. mobj = re.match(self._VALID_URL, url)
  102. program = mobj.group('program')
  103. site = mobj.group('site')
  104. page_id = mobj.group('page')
  105. if page_id:
  106. page_id = int(page_id)
  107. start_page = page_id
  108. playlist_id = '%s-page%d' % (program, page_id)
  109. else:
  110. start_page = 0
  111. playlist_id = program
  112. entries = []
  113. for current_page_id in itertools.count(start_page):
  114. current_page = self._download_webpage(
  115. 'http://www.%s.be/%s/videos?page=%d' % (site, program, current_page_id),
  116. program,
  117. 'Downloading page %d' % (current_page_id + 1))
  118. page_entries = [
  119. self.url_result('http://www.' + site + '.be' + video_url, 'Vier')
  120. for video_url in re.findall(
  121. r'<h[23]><a href="(/[^/]+/videos/[^/]+(?:/\d+)?)">', current_page)]
  122. entries.extend(page_entries)
  123. if page_id or '>Meer<' not in current_page:
  124. break
  125. return self.playlist_result(entries, playlist_id)