]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/streamango.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_chr
16 class StreamangoIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?(?:streamango\.com|fruithosts\.net|streamcherry\.com)/(?:f|embed)/(?P<id>[^/?#&]+)'
19 'url': 'https://streamango.com/f/clapasobsptpkdfe/20170315_150006_mp4',
20 'md5': 'e992787515a182f55e38fc97588d802a',
22 'id': 'clapasobsptpkdfe',
24 'title': '20170315_150006.mp4',
28 'url': 'https://streamango.com/embed/foqebrpftarclpob/asdf_asd_2_mp4',
30 'id': 'foqebrpftarclpob',
32 'title': 'foqebrpftarclpob',
35 'skip_download': True,
39 'url': 'https://streamango.com/embed/clapasobsptpkdfe/20170315_150006_mp4',
40 'only_matching': True,
42 'url': 'https://fruithosts.net/f/mreodparcdcmspsm/w1f1_r4lph_2018_brrs_720p_latino_mp4',
43 'only_matching': True,
45 'url': 'https://streamcherry.com/f/clapasobsptpkdfe/',
46 'only_matching': True,
49 def _real_extract(self
, url
):
50 def decrypt_src(encoded
, val
):
51 ALPHABET
= '=/+9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
52 encoded
= re
.sub(r
'[^A-Za-z0-9+/=]', '', encoded
)
56 str_len
= len(encoded
)
59 sm
[j
% 4] = ALPHABET
.index(encoded
[i
])
61 char_code
= ((sm
[0] << 0x2) |
(sm
[1] >> 0x4)) ^ val
62 decoded
+= compat_chr(char_code
)
64 char_code
= ((sm
[1] & 0xf) << 0x4) |
(sm
[2] >> 0x2)
65 decoded
+= compat_chr(char_code
)
67 char_code
= ((sm
[2] & 0x3) << 0x6) | sm
[3]
68 decoded
+= compat_chr(char_code
)
71 video_id
= self
._match
_id
(url
)
73 webpage
= self
._download
_webpage
(url
, video_id
)
75 title
= self
._og
_search
_title
(webpage
, default
=video_id
)
78 for format_
in re
.findall(r
'({[^}]*\bsrc\s*:\s*[^}]*})', webpage
):
79 mobj
= re
.search(r
'(src\s*:\s*[^(]+\(([^)]*)\)[\s,]*)', format_
)
83 format_
= format_
.replace(mobj
.group(0), '')
85 video
= self
._parse
_json
(
86 format_
, video_id
, transform_source
=js_to_json
,
90 r
'([\'"])(?P<src>(?:(?!\1).)+)\1\s*,\s*(?P<val>\d+)',
95 src = decrypt_src(mobj.group('src'), int_or_none(mobj.group('val')))
99 ext = determine_ext(src, default_ext=None)
100 if video.get('type') == 'application/dash+xml' or ext == 'mpd':
101 formats.extend(self._extract_mpd_formats(
102 src, video_id, mpd_id='dash', fatal=False))
107 'width': int_or_none(video.get('width')),
108 'height': int_or_none(video.get('height')),
109 'tbr': int_or_none(video.get('bitrate')),
113 error = self._search_regex(
114 r'<p[^>]+\bclass=["\']lead
[^
>]+>(.+?
)</p
>', webpage,
115 'error
', default=None)
116 if not error and '>Sorry
' in webpage:
117 error = 'Video
%s is not available
' % video_id
119 raise ExtractorError(error, expected=True)
121 self._sort_formats(formats)