1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
7 compat_urllib_parse_unquote
,
15 class BeegIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?beeg\.com/(?P<id>\d+)'
18 'url': 'http://beeg.com/5416503',
19 'md5': 'a1a1b1a8bc70a89e49ccfd113aed0820',
23 'title': 'Sultry Striptease',
24 'description': 'md5:d22219c09da287c14bed3d6c37ce4bc2',
25 'timestamp': 1391813355,
26 'upload_date': '20140207',
33 def _real_extract(self
, url
):
34 video_id
= self
._match
_id
(url
)
36 webpage
= self
._download
_webpage
(url
, video_id
)
38 cpl_url
= self
._search
_regex
(
39 r
'<script[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//static\
.beeg\
.com
/cpl
/\d
+\
.js
.*?
)\
1',
40 webpage, 'cpl
', default=None, group='url
')
42 beeg_version, beeg_salt = [None] * 2
45 cpl = self._download_webpage(
46 self._proto_relative_url(cpl_url), video_id,
47 'Downloading cpl JS
', fatal=False)
49 beeg_version = int_or_none(self._search_regex(
50 r'beeg_version\s
*=\s
*([^
\b]+)', cpl,
51 'beeg version
', default=None)) or self._search_regex(
52 r'/(\d
+)\
.js
', cpl_url, 'beeg version
', default=None)
53 beeg_salt = self._search_regex(
54 r'beeg_salt\s
*=\s
*(["\'])(?P<beeg_salt>.+?)\1', cpl, 'beeg salt',
55 default=None, group='beeg_salt')
57 beeg_version = beeg_version or '2000'
58 beeg_salt = beeg_salt or 'pmweAkq8lAYKdfWcFCUj0yoVgoPlinamH5UE1CB3H'
60 video = self._download_json(
61 'https://api.beeg.com/api/v6/%s/video/%s' % (beeg_version, video_id),
78 # Reverse engineered from http://static.beeg.com/cpl/1738.js
80 e = compat_urllib_parse_unquote(key)
82 compat_chr(compat_ord(e[n]) - compat_ord(a[n % len(a)]) % 21)
83 for n in range(len(e))])
84 return ''.join(split(o, 3)[::-1])
86 def decrypt_url(encrypted_url):
87 encrypted_url = self._proto_relative_url(
88 encrypted_url.replace('{DATA_MARKERS}', ''), 'https:')
89 key = self._search_regex(
90 r'/key=(.*?)%2Cend=', encrypted_url, 'key', default=None)
93 return encrypted_url.replace(key, decrypt_key(key))
96 for format_id, video_url in video.items():
99 height = self._search_regex(
100 r'^(\d+)[pP]$', format_id, 'height', default=None)
104 'url': decrypt_url(video_url),
105 'format_id': format_id,
106 'height': int(height),
108 self._sort_formats(formats)
110 title = video['title']
111 video_id = video.get('id') or video_id
112 display_id = video.get('code')
113 description = video.get('desc')
115 timestamp = parse_iso8601(video.get('date'), ' ')
116 duration = int_or_none(video.get('duration'))
118 tags = [tag.strip() for tag in video['tags'].split(',')] if video.get('tags') else None
122 'display_id': display_id,
124 'description': description,
125 'timestamp': timestamp,
126 'duration': duration,
129 'age_limit': self._rta_search(webpage),