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.

82 lines
2.9 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import extract_attributes
  6. class TV2DKIE(InfoExtractor):
  7. _VALID_URL = r'''(?x)
  8. https?://
  9. (?:www\.)?
  10. (?:
  11. tvsyd|
  12. tv2ostjylland|
  13. tvmidtvest|
  14. tv2fyn|
  15. tv2east|
  16. tv2lorry|
  17. tv2nord
  18. )\.dk/
  19. (:[^/]+/)*
  20. (?P<id>[^/?\#&]+)
  21. '''
  22. _TESTS = [{
  23. 'url': 'https://www.tvsyd.dk/nyheder/28-10-2019/1930/1930-28-okt-2019?autoplay=1#player',
  24. 'info_dict': {
  25. 'id': '0_52jmwa0p',
  26. 'ext': 'mp4',
  27. 'title': '19:30 - 28. okt. 2019',
  28. 'timestamp': 1572290248,
  29. 'upload_date': '20191028',
  30. 'uploader_id': 'tvsyd',
  31. 'duration': 1347,
  32. 'view_count': int,
  33. },
  34. 'params': {
  35. 'skip_download': True,
  36. },
  37. 'add_ie': ['Kaltura'],
  38. }, {
  39. 'url': 'https://www.tv2ostjylland.dk/artikel/minister-gaar-ind-i-sag-om-diabetes-teknologi',
  40. 'only_matching': True,
  41. }, {
  42. 'url': 'https://www.tv2ostjylland.dk/nyheder/28-10-2019/22/2200-nyhederne-mandag-d-28-oktober-2019?autoplay=1#player',
  43. 'only_matching': True,
  44. }, {
  45. 'url': 'https://www.tvmidtvest.dk/nyheder/27-10-2019/1930/1930-27-okt-2019',
  46. 'only_matching': True,
  47. }, {
  48. 'url': 'https://www.tv2fyn.dk/artikel/fyn-kan-faa-landets-foerste-fabrik-til-groent-jetbraendstof',
  49. 'only_matching': True,
  50. }, {
  51. 'url': 'https://www.tv2east.dk/artikel/gods-faar-indleveret-tonsvis-af-aebler-100-kilo-aebler-gaar-til-en-aeblebrandy',
  52. 'only_matching': True,
  53. }, {
  54. 'url': 'https://www.tv2lorry.dk/koebenhavn/rasmus-paludan-evakueret-til-egen-demonstration#player',
  55. 'only_matching': True,
  56. }, {
  57. 'url': 'https://www.tv2nord.dk/artikel/dybt-uacceptabelt',
  58. 'only_matching': True,
  59. }]
  60. def _real_extract(self, url):
  61. video_id = self._match_id(url)
  62. webpage = self._download_webpage(url, video_id)
  63. entries = []
  64. for video_el in re.findall(r'(?s)<[^>]+\bdata-entryid\s*=[^>]*>', webpage):
  65. video = extract_attributes(video_el)
  66. kaltura_id = video.get('data-entryid')
  67. if not kaltura_id:
  68. continue
  69. partner_id = video.get('data-partnerid')
  70. if not partner_id:
  71. continue
  72. entries.append(self.url_result(
  73. 'kaltura:%s:%s' % (partner_id, kaltura_id), 'Kaltura',
  74. video_id=kaltura_id))
  75. return self.playlist_result(entries)