- mobj = re.match(self._VALID_URL, url)
- video_id = mobj.group('id')
+ video_id = self._match_id(url)
+
+ video = self._download_json(
+ 'http://beeg.com/api/v3/video/%s' % video_id, video_id)
+
+ def decrypt_key(key):
+ # Reverse engineered from http://static.beeg.com/cpl/1067.js
+ a = '8RPUUCS35ZWp3ADnKcSmpH71ZusrROo'
+ e = compat_urllib_parse_unquote(key)
+ return ''.join([
+ compat_chr(compat_ord(e[n]) - compat_ord(a[n % len(a)]) % 25)
+ for n in range(len(e))])
+
+ def decrypt_url(encrypted_url):
+ encrypted_url = self._proto_relative_url(
+ encrypted_url.replace('{DATA_MARKERS}', ''), 'http:')
+ key = self._search_regex(
+ r'/key=(.*?)%2Cend=', encrypted_url, 'key', default=None)
+ if not key:
+ return encrypted_url
+ return encrypted_url.replace(key, decrypt_key(key))