logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

dbtv.py (1955B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. class DBTVIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?dagbladet\.no/video/(?:(?:embed|(?P<display_id>[^/]+))/)?(?P<id>[0-9A-Za-z_-]{11}|[a-zA-Z0-9]{8})'
  7. _TESTS = [{
  8. 'url': 'https://www.dagbladet.no/video/PynxJnNWChE/',
  9. 'md5': 'b8f850ba1860adbda668d367f9b77699',
  10. 'info_dict': {
  11. 'id': 'PynxJnNWChE',
  12. 'ext': 'mp4',
  13. 'title': 'Skulle teste ut fornøyelsespark, men kollegaen var bare opptatt av bikinikroppen',
  14. 'description': 'md5:49cc8370e7d66e8a2ef15c3b4631fd3f',
  15. 'thumbnail': r're:https?://.*\.jpg',
  16. 'upload_date': '20160916',
  17. 'duration': 69,
  18. 'uploader_id': 'UCk5pvsyZJoYJBd7_oFPTlRQ',
  19. 'uploader': 'Dagbladet',
  20. },
  21. 'add_ie': ['Youtube']
  22. }, {
  23. 'url': 'https://www.dagbladet.no/video/embed/xlGmyIeN9Jo/?autoplay=false',
  24. 'only_matching': True,
  25. }, {
  26. 'url': 'https://www.dagbladet.no/video/truer-iran-bor-passe-dere/PalfB2Cw',
  27. 'only_matching': True,
  28. }]
  29. @staticmethod
  30. def _extract_urls(webpage):
  31. return [url for _, url in re.findall(
  32. r'<iframe[^>]+src=(["\'])((?:https?:)?//(?:www\.)?dagbladet\.no/video/embed/(?:[0-9A-Za-z_-]{11}|[a-zA-Z0-9]{8}).*?)\1',
  33. webpage)]
  34. def _real_extract(self, url):
  35. display_id, video_id = re.match(self._VALID_URL, url).groups()
  36. info = {
  37. '_type': 'url_transparent',
  38. 'id': video_id,
  39. 'display_id': display_id,
  40. }
  41. if len(video_id) == 11:
  42. info.update({
  43. 'url': video_id,
  44. 'ie_key': 'Youtube',
  45. })
  46. else:
  47. info.update({
  48. 'url': 'jwplatform:' + video_id,
  49. 'ie_key': 'JWPlatform',
  50. })
  51. return info