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.

112 lines
3.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class DigitekaIE(InfoExtractor):
  7. _VALID_URL = r'''(?x)
  8. https?://(?:www\.)?(?:digiteka\.net|ultimedia\.com)/
  9. (?:
  10. deliver/
  11. (?P<embed_type>
  12. generic|
  13. musique
  14. )
  15. (?:/[^/]+)*/
  16. (?:
  17. src|
  18. article
  19. )|
  20. default/index/video
  21. (?P<site_type>
  22. generic|
  23. music
  24. )
  25. /id
  26. )/(?P<id>[\d+a-z]+)'''
  27. _TESTS = [{
  28. # news
  29. 'url': 'https://www.ultimedia.com/default/index/videogeneric/id/s8uk0r',
  30. 'md5': '276a0e49de58c7e85d32b057837952a2',
  31. 'info_dict': {
  32. 'id': 's8uk0r',
  33. 'ext': 'mp4',
  34. 'title': 'Loi sur la fin de vie: le texte prévoit un renforcement des directives anticipées',
  35. 'thumbnail': r're:^https?://.*\.jpg',
  36. 'duration': 74,
  37. 'upload_date': '20150317',
  38. 'timestamp': 1426604939,
  39. 'uploader_id': '3fszv',
  40. },
  41. }, {
  42. # music
  43. 'url': 'https://www.ultimedia.com/default/index/videomusic/id/xvpfp8',
  44. 'md5': '2ea3513813cf230605c7e2ffe7eca61c',
  45. 'info_dict': {
  46. 'id': 'xvpfp8',
  47. 'ext': 'mp4',
  48. 'title': 'Two - C\'est La Vie (clip)',
  49. 'thumbnail': r're:^https?://.*\.jpg',
  50. 'duration': 233,
  51. 'upload_date': '20150224',
  52. 'timestamp': 1424760500,
  53. 'uploader_id': '3rfzk',
  54. },
  55. }, {
  56. 'url': 'https://www.digiteka.net/deliver/generic/iframe/mdtk/01637594/src/lqm3kl/zone/1/showtitle/1/autoplay/yes',
  57. 'only_matching': True,
  58. }]
  59. @staticmethod
  60. def _extract_url(webpage):
  61. mobj = re.search(
  62. r'<(?:iframe|script)[^>]+src=["\'](?P<url>(?:https?:)?//(?:www\.)?ultimedia\.com/deliver/(?:generic|musique)(?:/[^/]+)*/(?:src|article)/[\d+a-z]+)',
  63. webpage)
  64. if mobj:
  65. return mobj.group('url')
  66. def _real_extract(self, url):
  67. mobj = re.match(self._VALID_URL, url)
  68. video_id = mobj.group('id')
  69. video_type = mobj.group('embed_type') or mobj.group('site_type')
  70. if video_type == 'music':
  71. video_type = 'musique'
  72. deliver_info = self._download_json(
  73. 'http://www.ultimedia.com/deliver/video?video=%s&topic=%s' % (video_id, video_type),
  74. video_id)
  75. yt_id = deliver_info.get('yt_id')
  76. if yt_id:
  77. return self.url_result(yt_id, 'Youtube')
  78. jwconf = deliver_info['jwconf']
  79. formats = []
  80. for source in jwconf['playlist'][0]['sources']:
  81. formats.append({
  82. 'url': source['file'],
  83. 'format_id': source.get('label'),
  84. })
  85. self._sort_formats(formats)
  86. title = deliver_info['title']
  87. thumbnail = jwconf.get('image')
  88. duration = int_or_none(deliver_info.get('duration'))
  89. timestamp = int_or_none(deliver_info.get('release_time'))
  90. uploader_id = deliver_info.get('owner_id')
  91. return {
  92. 'id': video_id,
  93. 'title': title,
  94. 'thumbnail': thumbnail,
  95. 'duration': duration,
  96. 'timestamp': timestamp,
  97. 'uploader_id': uploader_id,
  98. 'formats': formats,
  99. }