]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/xfileshare.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_chr
18 # based on openload_decode from 2bfeee69b976fe049761dd3012e30b637ee05a58
19 def aa_decode(aa_code
):
21 ('7', '((゚ー゚) + (o^_^o))'),
22 ('6', '((o^_^o) +(o^_^o))'),
23 ('5', '((゚ー゚) + (゚Θ゚))'),
24 ('2', '((o^_^o) - (゚Θ゚))'),
32 for aa_char
in aa_code
.split(delim
):
33 for val
, pat
in symbol_table
:
34 aa_char
= aa_char
.replace(pat
, val
)
35 aa_char
= aa_char
.replace('+ ', '')
36 m
= re
.match(r
'^\d+', aa_char
)
38 ret
+= compat_chr(int(m
.group(0), 8))
40 m
= re
.match(r
'^u([\da-f]+)', aa_char
)
42 ret
+= compat_chr(int(m
.group(1), 16))
46 class XFileShareIE(InfoExtractor
):
48 (r
'aparat\.cam', 'Aparat'),
49 (r
'clipwatching\.com', 'ClipWatching'),
50 (r
'gounlimited\.to', 'GoUnlimited'),
51 (r
'govid\.me', 'GoVid'),
52 (r
'holavid\.com', 'HolaVid'),
53 (r
'streamty\.com', 'Streamty'),
54 (r
'thevideobee\.to', 'TheVideoBee'),
55 (r
'uqload\.com', 'Uqload'),
56 (r
'vidbom\.com', 'VidBom'),
57 (r
'vidlo\.us', 'vidlo'),
58 (r
'vidlocker\.xyz', 'VidLocker'),
59 (r
'vidshare\.tv', 'VidShare'),
61 (r
'wolfstream\.tv', 'WolfStream'),
62 (r
'xvideosharing\.com', 'XVideoSharing'),
65 IE_DESC
= 'XFileShare based sites: %s' % ', '.join(list(zip(*_SITES
))[1])
66 _VALID_URL
= (r
'https?://(?:www\.)?(?P<host>%s)/(?:embed-)?(?P<id>[0-9a-zA-Z]+)'
67 % '|'.join(site
for site
in list(zip(*_SITES
))[0]))
69 _FILE_NOT_FOUND_REGEXES
= (
70 r
'>(?:404 - )?File Not Found<',
71 r
'>The file was removed by administrator<',
75 'url': 'http://xvideosharing.com/fq65f94nd2ve',
76 'md5': '4181f63957e8fe90ac836fa58dc3c8a6',
81 'thumbnail': r
're:http://.*\.jpg',
84 'url': 'https://aparat.cam/n4d6dh0wvlpr',
85 'only_matching': True,
87 'url': 'https://wolfstream.tv/nthme29v9u2x',
88 'only_matching': True,
92 def _extract_urls(webpage
):
95 for mobj
in re
.finditer(
96 r
'<iframe\b[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:%s)/embed
-[0-9a
-zA
-Z
]+.*?
)\
1'
97 % '|
'.join(site for site in list(zip(*XFileShareIE._SITES))[0]),
100 def _real_extract(self, url):
101 host, video_id = re.match(self._VALID_URL, url).groups()
103 url = 'https
://%s/' % host + ('embed
-%s.html
' % video_id if host in ('govid
.me
', 'vidlo
.us
') else video_id)
104 webpage = self._download_webpage(url, video_id)
106 if any(re.search(p, webpage) for p in self._FILE_NOT_FOUND_REGEXES):
107 raise ExtractorError('Video
%s does
not exist
' % video_id, expected=True)
109 fields = self._hidden_inputs(webpage)
111 if fields.get('op
') == 'download1
':
112 countdown = int_or_none(self._search_regex(
113 r'<span
id="countdown_str">(?
:[Ww
]ait
)?\s
*<span
id="cxc">(\d
+)</span
>\s
*(?
:seconds?
)?
</span
>',
114 webpage, 'countdown
', default=None))
116 self._sleep(countdown, video_id)
118 webpage = self._download_webpage(
119 url, video_id, 'Downloading video page
',
120 data=urlencode_postdata(fields), headers={
122 'Content
-type': 'application
/x
-www
-form
-urlencoded
',
125 title = (self._search_regex(
126 (r'style
="z-index: [0-9]+;">([^
<]+)</span
>',
127 r'<td nowrap
>([^
<]+)</td
>',
128 r'h4
-fine
[^
>]*>([^
<]+)<',
130 r'<h2
class="video-page-head">([^
<]+)</h2
>',
131 r'<h2 style
="[^"]*color
:#403f3d[^"]*"[^>]*>([^<]+)<', # streamin.to
132 r
'title\s*:\s*"([^"]+)"'), # govid.me
133 webpage
, 'title', default
=None) or self
._og
_search
_title
(
134 webpage
, default
=None) or video_id
).strip()
137 (r
'(eval\(function\(p,a,c,k,e,d\){.+)', decode_packed_codes
),
138 (r
'(゚.+)', aa_decode
)):
139 obf_code
= self
._search
_regex
(regex
, webpage
, 'obfuscated code', default
=None)
141 webpage
= webpage
.replace(obf_code
, func(obf_code
))
145 jwplayer_data
= self
._search
_regex
(
147 r
'jwplayer\("[^"]+"\)\.load\(\[({.+?})\]\);',
148 r
'jwplayer\("[^"]+"\)\.setup\(({.+?})\);',
150 'jwplayer data', default
=None)
152 jwplayer_data
= self
._parse
_json
(
153 jwplayer_data
.replace(r
"\'", "'"), video_id
, js_to_json
)
155 formats
= self
._parse
_jwplayer
_data
(
156 jwplayer_data
, video_id
, False,
157 m3u8_id
='hls', mpd_id
='dash')['formats']
162 r
'(?:file|src)\s*:\s*(["\'])(?P
<url
>http(?
:(?
!\
1).)+\
.(?
:m3u8|mp4|flv
)(?
:(?
!\
1).)*)\
1',
163 r'file_link\s
*=\s
*(["\'])(?P<url>http(?:(?!\1).)+)\1',
164 r'addVariable\((\\?["\'])file\
1\s
*,\s
*(\\?
["\'])(?P<url>http(?:(?!\2).)+)\2\)',
165 r'<embed[^>]+src=(["\'])(?P
<url
>http(?
:(?
!\
1).)+\
.(?
:m3u8|mp4|flv
)(?
:(?
!\
1).)*)\
1'):
166 for mobj in re.finditer(regex, webpage):
167 video_url = mobj.group('url
')
168 if video_url not in urls:
169 urls.append(video_url)
171 sources = self._search_regex(
172 r'sources\s
*:\s
*(\
[(?
!{)[^\
]]+\
])', webpage, 'sources
', default=None)
174 urls.extend(self._parse_json(sources, video_id))
177 for video_url in urls:
178 if determine_ext(video_url) == 'm3u8
':
179 formats.extend(self._extract_m3u8_formats(
180 video_url, video_id, 'mp4
',
181 entry_protocol='m3u8_native
', m3u8_id='hls
',
188 self._sort_formats(formats)
190 thumbnail = self._search_regex(
192 r'<video
[^
>]+poster
="([^"]+)"',
193 r'(?:image|poster)\s*:\s*["\'](http
[^
"\']+)["\'],',
194 ], webpage, 'thumbnail
', default=None)
199 'thumbnail
': thumbnail,