mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-06 21:17:06 +01:00
[toypics] Improve and modernize
This commit is contained in:
parent
77d682da9d
commit
2ca29f1aaf
@ -6,43 +6,48 @@
|
|||||||
|
|
||||||
|
|
||||||
class ToypicsIE(InfoExtractor):
|
class ToypicsIE(InfoExtractor):
|
||||||
IE_DESC = 'Toypics user profile'
|
IE_DESC = 'Toypics video'
|
||||||
_VALID_URL = r'https?://videos\.toypics\.net/view/(?P<id>[0-9]+)/.*'
|
_VALID_URL = r'https?://videos\.toypics\.net/view/(?P<id>[0-9]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/',
|
'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/',
|
||||||
'md5': '16e806ad6d6f58079d210fe30985e08b',
|
'md5': '16e806ad6d6f58079d210fe30985e08b',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '514',
|
'id': '514',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Chance-Bulge\'d, 2',
|
'title': "Chance-Bulge'd, 2",
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'uploader': 'kidsune',
|
'uploader': 'kidsune',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
video_id = self._match_id(url)
|
||||||
video_id = mobj.group('id')
|
|
||||||
page = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
formats = self._parse_html5_media_entries(url, page, video_id)[0]['formats']
|
|
||||||
|
formats = self._parse_html5_media_entries(
|
||||||
|
url, webpage, video_id)[0]['formats']
|
||||||
title = self._html_search_regex([
|
title = self._html_search_regex([
|
||||||
r'<h1[^>]+class=["\']view-video-title[^>]+>([^<]+)</h',
|
r'<h1[^>]+class=["\']view-video-title[^>]+>([^<]+)</h',
|
||||||
r'<title>([^<]+) - Toypics</title>',
|
r'<title>([^<]+) - Toypics</title>',
|
||||||
], page, 'title')
|
], webpage, 'title')
|
||||||
username = self._html_search_regex(
|
|
||||||
r'More videos from <strong>([^<]+)</strong>', page, 'username')
|
uploader = self._html_search_regex(
|
||||||
|
r'More videos from <strong>([^<]+)</strong>', webpage, 'uploader',
|
||||||
|
fatal=False)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'title': title,
|
'title': title,
|
||||||
'uploader': username,
|
'uploader': uploader,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ToypicsUserIE(InfoExtractor):
|
class ToypicsUserIE(InfoExtractor):
|
||||||
IE_DESC = 'Toypics user profile'
|
IE_DESC = 'Toypics user profile'
|
||||||
_VALID_URL = r'https?://videos\.toypics\.net/(?P<username>[^/?]+)(?:$|[?#])'
|
_VALID_URL = r'https?://videos\.toypics\.net/(?!view)(?P<id>[^/?#&]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'http://videos.toypics.net/Mikey',
|
'url': 'http://videos.toypics.net/Mikey',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -52,8 +57,7 @@ class ToypicsUserIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
username = self._match_id(url)
|
||||||
username = mobj.group('username')
|
|
||||||
|
|
||||||
profile_page = self._download_webpage(
|
profile_page = self._download_webpage(
|
||||||
url, username, note='Retrieving profile page')
|
url, username, note='Retrieving profile page')
|
||||||
@ -72,7 +76,7 @@ def _real_extract(self, url):
|
|||||||
note='Downloading page %d/%d' % (n, page_count))
|
note='Downloading page %d/%d' % (n, page_count))
|
||||||
urls.extend(
|
urls.extend(
|
||||||
re.findall(
|
re.findall(
|
||||||
r'<div[^>]+class=["\']preview[^>]+>\s*<a[^>]+href="(https?://videos.toypics.net/view/[^"]+)"',
|
r'<div[^>]+class=["\']preview[^>]+>\s*<a[^>]+href="(https?://videos\.toypics\.net/view/[^"]+)"',
|
||||||
lpage))
|
lpage))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user