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.6 KiB

Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
9 years ago
10 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. import re
  4. from random import random
  5. from math import floor
  6. from .common import InfoExtractor
  7. from ..utils import (
  8. ExtractorError,
  9. remove_end,
  10. sanitized_Request,
  11. )
  12. class IPrimaIE(InfoExtractor):
  13. _WORKING = False
  14. _VALID_URL = r'https?://play\.iprima\.cz/(?:[^/]+/)*(?P<id>[^?#]+)'
  15. _TESTS = [{
  16. 'url': 'http://play.iprima.cz/particka/particka-92',
  17. 'info_dict': {
  18. 'id': '39152',
  19. 'ext': 'flv',
  20. 'title': 'Partička (92)',
  21. 'description': 'md5:74e9617e51bca67c3ecfb2c6f9766f45',
  22. 'thumbnail': 'http://play.iprima.cz/sites/default/files/image_crops/image_620x349/3/491483_particka-92_image_620x349.jpg',
  23. },
  24. 'params': {
  25. 'skip_download': True, # requires rtmpdump
  26. },
  27. }, {
  28. 'url': 'http://play.iprima.cz/particka/tchibo-particka-jarni-moda',
  29. 'info_dict': {
  30. 'id': '9718337',
  31. 'ext': 'flv',
  32. 'title': 'Tchibo Partička - Jarní móda',
  33. 'thumbnail': 're:^http:.*\.jpg$',
  34. },
  35. 'params': {
  36. 'skip_download': True, # requires rtmpdump
  37. },
  38. }, {
  39. 'url': 'http://play.iprima.cz/zpravy-ftv-prima-2752015',
  40. 'only_matching': True,
  41. }]
  42. def _real_extract(self, url):
  43. mobj = re.match(self._VALID_URL, url)
  44. video_id = mobj.group('id')
  45. webpage = self._download_webpage(url, video_id)
  46. if re.search(r'Nemáte oprávnění přistupovat na tuto stránku\.\s*</div>', webpage):
  47. raise ExtractorError(
  48. '%s said: You do not have permission to access this page' % self.IE_NAME, expected=True)
  49. player_url = (
  50. 'http://embed.livebox.cz/iprimaplay/player-embed-v2.js?__tok%s__=%s' %
  51. (floor(random() * 1073741824), floor(random() * 1073741824))
  52. )
  53. req = sanitized_Request(player_url)
  54. req.add_header('Referer', url)
  55. playerpage = self._download_webpage(req, video_id)
  56. base_url = ''.join(re.findall(r"embed\['stream'\] = '(.+?)'.+'(\?auth=)'.+'(.+?)';", playerpage)[1])
  57. zoneGEO = self._html_search_regex(r'"zoneGEO":(.+?),', webpage, 'zoneGEO')
  58. if zoneGEO != '0':
  59. base_url = base_url.replace('token', 'token_' + zoneGEO)
  60. formats = []
  61. for format_id in ['lq', 'hq', 'hd']:
  62. filename = self._html_search_regex(
  63. r'"%s_id":(.+?),' % format_id, webpage, 'filename')
  64. if filename == 'null':
  65. continue
  66. real_id = self._search_regex(
  67. r'Prima-(?:[0-9]{10}|WEB)-([0-9]+)[-_]',
  68. filename, 'real video id')
  69. if format_id == 'lq':
  70. quality = 0
  71. elif format_id == 'hq':
  72. quality = 1
  73. elif format_id == 'hd':
  74. quality = 2
  75. filename = 'hq/' + filename
  76. formats.append({
  77. 'format_id': format_id,
  78. 'url': base_url,
  79. 'quality': quality,
  80. 'play_path': 'mp4:' + filename.replace('"', '')[:-4],
  81. 'rtmp_live': True,
  82. 'ext': 'flv',
  83. })
  84. self._sort_formats(formats)
  85. return {
  86. 'id': real_id,
  87. 'title': remove_end(self._og_search_title(webpage), ' | Prima PLAY'),
  88. 'thumbnail': self._og_search_thumbnail(webpage),
  89. 'formats': formats,
  90. 'description': self._search_regex(
  91. r'<p[^>]+itemprop="description"[^>]*>([^<]+)',
  92. webpage, 'description', default=None),
  93. }