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.

95 lines
3.4 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)\.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. def _real_extract(self, url):
  53. video_id = self._match_id(url)
  54. webpage = self._download_webpage(url, video_id)
  55. video_id = self._search_regex(
  56. r'data-video-id="([^"]+)_[^"]+"', webpage, 'video id', fatal=False)
  57. formats = []
  58. mobj = re.search(
  59. r'data-video-iphone-server="(?P<server>[^"]+)"\s+data-video-iphone-path="(?P<path>[^"]+)"',
  60. webpage)
  61. if mobj:
  62. formats.extend(self._extract_m3u8_formats(
  63. '%s/%s' % (mobj.group('server'), mobj.group('path')),
  64. video_id, 'mp4'))
  65. mobj = re.search(r'data-video-src="(?P<src>[^"]+)"', webpage)
  66. if mobj:
  67. formats.extend(self._extract_f4m_formats(
  68. '%s/manifest.f4m' % mobj.group('src'), video_id))
  69. self._sort_formats(formats)
  70. title = self._og_search_title(webpage)
  71. description = self._og_search_description(webpage, default=None)
  72. thumbnail = self._og_search_thumbnail(webpage)
  73. timestamp = float_or_none(self._search_regex(
  74. r'data-video-sitestat-pubdate="(\d+)"', webpage, 'timestamp', fatal=False), 1000)
  75. duration = float_or_none(self._search_regex(
  76. r'data-video-duration="(\d+)"', webpage, 'duration', fatal=False), 1000)
  77. return {
  78. 'id': video_id,
  79. 'title': title,
  80. 'description': description,
  81. 'thumbnail': thumbnail,
  82. 'timestamp': timestamp,
  83. 'duration': duration,
  84. 'formats': formats,
  85. }