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.

104 lines
3.8 KiB

10 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import float_or_none
  6. class VRTIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:deredactie|sporza|cobra(?:\.canvas)?)\.be/cm/(?:[^/]+/)+(?P<id>[^/]+)/*'
  8. _TESTS = [
  9. # deredactie.be
  10. {
  11. 'url': 'http://deredactie.be/cm/vrtnieuws/videozone/programmas/journaal/EP_141025_JOL',
  12. 'md5': '4cebde1eb60a53782d4f3992cbd46ec8',
  13. 'info_dict': {
  14. 'id': '2129880',
  15. 'ext': 'flv',
  16. 'title': 'Het journaal L - 25/10/14',
  17. 'description': None,
  18. 'timestamp': 1414271750.949,
  19. 'upload_date': '20141025',
  20. 'duration': 929,
  21. }
  22. },
  23. # sporza.be
  24. {
  25. 'url': 'http://sporza.be/cm/sporza/videozone/programmas/extratime/EP_141020_Extra_time',
  26. 'md5': '11f53088da9bf8e7cfc42456697953ff',
  27. 'info_dict': {
  28. 'id': '2124639',
  29. 'ext': 'flv',
  30. 'title': 'Bekijk Extra Time van 20 oktober',
  31. 'description': 'md5:83ac5415a4f1816c6a93f8138aef2426',
  32. 'timestamp': 1413835980.560,
  33. 'upload_date': '20141020',
  34. 'duration': 3238,
  35. }
  36. },
  37. # cobra.be
  38. {
  39. 'url': 'http://cobra.be/cm/cobra/videozone/rubriek/film-videozone/141022-mv-ellis-cafecorsari',
  40. 'md5': '78a2b060a5083c4f055449a72477409d',
  41. 'info_dict': {
  42. 'id': '2126050',
  43. 'ext': 'flv',
  44. 'title': 'Bret Easton Ellis in Café Corsari',
  45. 'description': 'md5:f699986e823f32fd6036c1855a724ee9',
  46. 'timestamp': 1413967500.494,
  47. 'upload_date': '20141022',
  48. 'duration': 661,
  49. }
  50. },
  51. {
  52. 'url': 'http://cobra.canvas.be/cm/cobra/videozone/rubriek/film-videozone/1.2377055',
  53. 'only_matching': True,
  54. }
  55. ]
  56. def _real_extract(self, url):
  57. video_id = self._match_id(url)
  58. webpage = self._download_webpage(url, video_id)
  59. video_id = self._search_regex(
  60. r'data-video-id="([^"]+)_[^"]+"', webpage, 'video id', fatal=False)
  61. formats = []
  62. mobj = re.search(
  63. r'data-video-iphone-server="(?P<server>[^"]+)"\s+data-video-iphone-path="(?P<path>[^"]+)"',
  64. webpage)
  65. if mobj:
  66. formats.extend(self._extract_m3u8_formats(
  67. '%s/%s' % (mobj.group('server'), mobj.group('path')),
  68. video_id, 'mp4', m3u8_id='hls', fatal=False))
  69. mobj = re.search(r'data-video-src="(?P<src>[^"]+)"', webpage)
  70. if mobj:
  71. formats.extend(self._extract_f4m_formats(
  72. '%s/manifest.f4m' % mobj.group('src'),
  73. video_id, f4m_id='hds', fatal=False))
  74. if not formats and 'data-video-geoblocking="true"' in webpage:
  75. self.raise_geo_restricted('This video is only available in Belgium')
  76. self._sort_formats(formats)
  77. title = self._og_search_title(webpage)
  78. description = self._og_search_description(webpage, default=None)
  79. thumbnail = self._og_search_thumbnail(webpage)
  80. timestamp = float_or_none(self._search_regex(
  81. r'data-video-sitestat-pubdate="(\d+)"', webpage, 'timestamp', fatal=False), 1000)
  82. duration = float_or_none(self._search_regex(
  83. r'data-video-duration="(\d+)"', webpage, 'duration', fatal=False), 1000)
  84. return {
  85. 'id': video_id,
  86. 'title': title,
  87. 'description': description,
  88. 'thumbnail': thumbnail,
  89. 'timestamp': timestamp,
  90. 'duration': duration,
  91. 'formats': formats,
  92. }