]>
jfr.im git - yt-dlp.git/blob - youtube_dlc/extractor/thisvid.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
8 class ThisVidIE(InfoExtractor
):
9 _VALID_URL
= r
'https?://(?:www\.)?thisvid\.com/(?P<type>videos|embed)/(?P<id>[A-Za-z0-9-]+/?)'
11 'url': 'https://thisvid.com/videos/french-boy-pantsed/',
12 'md5': '3397979512c682f6b85b3b04989df224',
16 'title': 'French Boy Pantsed',
17 'thumbnail': 'https://media.thisvid.com/contents/videos_screenshots/2400000/2400174/preview.mp4.jpg',
21 'url': 'https://thisvid.com/embed/2400174/',
22 'md5': '3397979512c682f6b85b3b04989df224',
26 'title': 'French Boy Pantsed',
27 'thumbnail': 'https://media.thisvid.com/contents/videos_screenshots/2400000/2400174/preview.mp4.jpg',
32 def _real_extract(self
, url
):
33 main_id
= self
._match
_id
(url
)
34 webpage
= self
._download
_webpage
(url
, main_id
)
36 # URL decryptor was reversed from version 4.0.4, later verified working with 5.2.0 and may change in the future.
37 kvs_version
= self
._html
_search
_regex
(r
'<script [^>]+?src="https://thisvid\.com/player/kt_player\.js\?v=(\d+(\.\d+)+)">', webpage
, 'kvs_version', fatal
=False)
38 if not kvs_version
.startswith("5."):
39 self
.report_warning("Major version change (" + kvs_version
+ ") in player engine--Download may fail.")
41 title
= self
._html
_search
_regex
(r
'<title>(?:Video: )?(.+?)(?: - (?:\w+ porn at )?ThisVid(?:.com| tube))?</title>', webpage
, 'title')
42 # video_id, video_url and license_code from the 'flashvars' JSON object:
43 video_id
= self
._html
_search
_regex
(r
"video_id: '([0-9]+)',", webpage
, 'video_id')
44 video_url
= self
._html
_search
_regex
(r
"video_url: '(function/0/.+?)',", webpage
, 'video_url')
45 license_code
= self
._html
_search
_regex
(r
"license_code: '([0-9$]{16})',", webpage
, 'license_code')
46 thumbnail
= self
._html
_search
_regex
(r
"preview_url: '((?:https?:)?//media.thisvid.com/.+?.jpg)',", webpage
, 'thumbnail', fatal
=False)
47 if thumbnail
.startswith("//"):
48 thumbnail
= "https:" + thumbnail
49 if (re
.match(self
._VALID
_URL
, url
).group('type') == "videos"):
52 display_id
= self
._search
_regex
(r
'<link rel="canonical" href="' + self
._VALID
_URL
+ r
'">', webpage
, 'display_id', fatal
=False),
56 'display_id': display_id
,
58 'url': getrealurl(video_url
, license_code
),
59 'thumbnail': thumbnail
,
64 def getrealurl(video_url
, license_code
):
65 urlparts
= video_url
.split('/')[2:]
66 license
= getlicensetoken(license_code
)
67 newmagic
= urlparts
[5][:32]
69 for o
in range(len(newmagic
) - 1, -1, -1):
71 l
= (o
+ sum([int(n
) for n
in license
[o
:]])) % 32
73 for i
in range(0, len(newmagic
)):
82 urlparts
[5] = newmagic
+ urlparts
[5][32:]
83 return "/".join(urlparts
)
86 def getlicensetoken(license
):
87 modlicense
= license
.replace("$", "").replace("0", "1")
88 center
= int(len(modlicense
) / 2)
89 fronthalf
= int(modlicense
[:center
+ 1])
90 backhalf
= int(modlicense
[center
:])
92 modlicense
= str(4 * abs(fronthalf
- backhalf
))
94 for o
in range(0, center
+ 1):
96 retval
+= str((int(license
[o
+ i
]) + int(modlicense
[o
])) % 10)