2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class StreamangoIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?streamango\.com/(?:f|embed)/(?P<id>[^/?#&]+)'
17 'url': 'https://streamango.com/f/clapasobsptpkdfe/20170315_150006_mp4',
18 'md5': 'e992787515a182f55e38fc97588d802a',
20 'id': 'clapasobsptpkdfe',
22 'title': '20170315_150006.mp4',
26 'url': 'https://streamango.com/embed/foqebrpftarclpob/asdf_asd_2_mp4',
28 'id': 'foqebrpftarclpob',
30 'title': 'foqebrpftarclpob',
33 'skip_download': True,
36 'url': 'https://streamango.com/embed/clapasobsptpkdfe/20170315_150006_mp4',
37 'only_matching': True,
40 def _real_extract(self, url):
41 def decrypt_src(str_, val):
42 k = '=/+9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
43 str_ = re.sub(r'[^A-Za-z0-9+/=]', '', str_)
50 sm[j % 4] = k.index(str_[i])
52 charCode = ((sm[0] << 0x2) | (sm[1] >> 0x4)) ^ val
55 charCode = ((sm[1] & 0xf) << 0x4) | (sm[2] >> 0x2)
58 charCode = ((sm[2] & 0x3) << 0x6) | sm[3]
62 video_id = self._match_id(url)
64 webpage = self._download_webpage(url, video_id)
66 title = self._og_search_title(webpage, default=video_id)
69 for format_ in re.findall(r'\(\s*({[^}]*\bsrc\s*:\s*[^}]*})', webpage):
70 mobj = re.search(r'(src\s*:\s*[^(]\(([^)]*)\)[\s,]*)', format_)
73 format_ = format_.replace(mobj.group(0), '')
75 video = self._parse_json(
76 format_, video_id, transform_source=js_to_json, fatal=False)
80 mobj = re.search(r'[\'"](?P<src>[^\'"]+)[\'"]\s*,\s*(?P<val>\d+)', mobj.group(1))
84 src = decrypt_src(mobj.group('src'), int_or_none(mobj.group('val')))
85 ext = determine_ext(src, default_ext=None)
86 if video.get('type') == 'application/dash+xml' or ext == 'mpd':
87 formats.extend(self._extract_mpd_formats(
88 src, video_id, mpd_id='dash', fatal=False))
93 'width': int_or_none(video.get('width')),
94 'height': int_or_none(video.get('height')),
95 'tbr': int_or_none(video.get('bitrate')),
97 self._sort_formats(formats)