nowtv.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. qualities,
  8. unified_strdate,
  9. int_or_none,
  10. )
  11. class NowTvIE(InfoExtractor):
  12. """Information Extractor for RTL NOW, RTL2 NOW, RTL NITRO, SUPER RTL NOW, VOX NOW and n-tv NOW"""
  13. _VALID_URL = r'''(?x)
  14. (?:https?://)?
  15. (
  16. (?:www\.)?nowtv\.de
  17. /(rtl|rtl2|rtlnitro||superrtl|ntv|vox)(?P<path>/.*?)/player
  18. )'''
  19. _TESTS = [
  20. {
  21. 'url': 'http://www.nowtv.de/vox/der-hundeprofi/buero-fall-chihuahua-joel/player',
  22. 'info_dict': {
  23. 'id': '128953',
  24. 'ext': 'mp4',
  25. 'title': 'B\u00fcro-Fall \/ Chihuahua \'Joel\'',
  26. 'description': 'md5:ce843b6b5901d9a7f7d04d1bbcdb12de',
  27. 'upload_date': '2015-05-23 19:10:00',
  28. 'duration': '00:51:32',
  29. },
  30. 'params': {
  31. 'skip_download': True,
  32. },
  33. 'skip': 'Only works from Germany',
  34. },
  35. ]
  36. def _real_extract(self, url):
  37. mobj = re.match(self._VALID_URL, url)
  38. info_url = 'https://api.nowtv.de/v3/movies' + mobj.group('path') + '?fields=*,format,files,breakpoints,paymentPaytypes,trailers'
  39. info = self._download_json(info_url, None)
  40. video_id = info['id']
  41. title = info['title']
  42. description = info['articleShort']
  43. duration = info['duration']
  44. upload_date = unified_strdate(info['broadcastStartDate'])
  45. free = info['free']
  46. station = info['format']['station']
  47. thumbnail = info['format']['defaultImage169Logo']
  48. if station == 'rtl':
  49. base_url = 'http://hls.fra.rtlnow.de/hls-vod-enc/'
  50. elif station == 'rtl2':
  51. base_url = 'http://hls.fra.rtl2now.de/hls-vod-enc/'
  52. elif station == 'vox':
  53. base_url = 'http://hls.fra.voxnow.de/hls-vod-enc/'
  54. elif station == 'nitro':
  55. base_url = 'http://hls.fra.rtlnitronow.de/hls-vod-enc/'
  56. elif station == 'ntv':
  57. base_url = 'http://hls.fra.n-tvnow.de/hls-vod-enc/'
  58. elif station == 'superrtl':
  59. base_url = 'http://hls.fra.superrtlnow.de/hls-vod-enc/'
  60. formats = []
  61. for item in info['files']['items']:
  62. if item['type'] != 'video/x-abr':
  63. continue
  64. fmt = {
  65. 'url': base_url + item['path'] + '.m3u8',
  66. 'tbr': int_or_none(item['bitrate']),
  67. 'ext': 'mp4',
  68. 'format_id': int_or_none(item['id']),
  69. }
  70. formats.append(fmt)
  71. self._sort_formats(formats)
  72. return {
  73. 'id': video_id,
  74. 'title': title,
  75. 'description': description,
  76. 'thumbnail': thumbnail,
  77. 'upload_date': upload_date,
  78. 'duration': duration,
  79. 'formats': formats,
  80. }