2014-06-29 15:21:23 +09:00
|
|
|
# -*- coding:utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-03-22 03:31:41 +09:00
|
|
|
from .common import InfoExtractor
|
|
|
|
import re
|
|
|
|
|
2014-03-22 23:15:01 +09:00
|
|
|
|
2014-03-22 03:31:41 +09:00
|
|
|
class ToypicsIE(InfoExtractor):
|
2014-03-22 23:15:01 +09:00
|
|
|
IE_DESC = 'Toypics user profile'
|
2014-06-29 15:21:23 +09:00
|
|
|
_VALID_URL = r'https?://videos\.toypics\.net/view/(?P<id>[0-9]+)/.*'
|
2014-03-22 03:31:41 +09:00
|
|
|
_TEST = {
|
|
|
|
'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/',
|
2014-03-22 23:15:01 +09:00
|
|
|
'md5': '16e806ad6d6f58079d210fe30985e08b',
|
2014-03-22 03:31:41 +09:00
|
|
|
'info_dict': {
|
|
|
|
'id': '514',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Chance-Bulge\'d, 2',
|
2014-03-22 23:15:01 +09:00
|
|
|
'age_limit': 18,
|
|
|
|
'uploader': 'kidsune',
|
2014-03-22 03:31:41 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2014-03-22 23:15:01 +09:00
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
video_id = mobj.group('id')
|
|
|
|
page = self._download_webpage(url, video_id)
|
2014-03-22 03:31:41 +09:00
|
|
|
video_url = self._html_search_regex(
|
|
|
|
r'src:\s+"(http://static[0-9]+\.toypics\.net/flvideo/[^"]+)"', page, 'video URL')
|
|
|
|
title = self._html_search_regex(
|
|
|
|
r'<title>Toypics - ([^<]+)</title>', page, 'title')
|
|
|
|
username = self._html_search_regex(
|
|
|
|
r'toypics.net/([^/"]+)" class="user-name">', page, 'username')
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'url': video_url,
|
|
|
|
'title': title,
|
|
|
|
'uploader': username,
|
2014-03-22 23:15:01 +09:00
|
|
|
'age_limit': 18,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ToypicsUserIE(InfoExtractor):
|
|
|
|
IE_DESC = 'Toypics user profile'
|
2016-03-22 00:36:32 +09:00
|
|
|
_VALID_URL = r'https?://videos\.toypics\.net/(?P<username>[^/?]+)(?:$|[?#])'
|
2014-08-28 07:58:24 +09:00
|
|
|
_TEST = {
|
|
|
|
'url': 'http://videos.toypics.net/Mikey',
|
|
|
|
'info_dict': {
|
|
|
|
'id': 'Mikey',
|
|
|
|
},
|
2014-09-04 21:37:40 +09:00
|
|
|
'playlist_mincount': 19,
|
2014-08-28 07:58:24 +09:00
|
|
|
}
|
2014-03-22 23:15:01 +09:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
username = mobj.group('username')
|
|
|
|
|
|
|
|
profile_page = self._download_webpage(
|
|
|
|
url, username, note='Retrieving profile page')
|
|
|
|
|
|
|
|
video_count = int(self._search_regex(
|
|
|
|
r'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page,
|
|
|
|
'video count'))
|
|
|
|
|
|
|
|
PAGE_SIZE = 8
|
|
|
|
urls = []
|
|
|
|
page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE
|
|
|
|
for n in range(1, page_count + 1):
|
|
|
|
lpage_url = url + '/public/%d' % n
|
|
|
|
lpage = self._download_webpage(
|
|
|
|
lpage_url, username,
|
|
|
|
note='Downloading page %d/%d' % (n, page_count))
|
|
|
|
urls.extend(
|
|
|
|
re.findall(
|
2014-06-29 15:21:23 +09:00
|
|
|
r'<p class="video-entry-title">\s+<a href="(https?://videos.toypics.net/view/[^"]+)">',
|
2014-03-22 23:15:01 +09:00
|
|
|
lpage))
|
|
|
|
|
|
|
|
return {
|
|
|
|
'_type': 'playlist',
|
|
|
|
'id': username,
|
|
|
|
'entries': [{
|
|
|
|
'_type': 'url',
|
2014-03-22 23:17:32 +09:00
|
|
|
'url': eurl,
|
2014-03-22 23:15:01 +09:00
|
|
|
'ie_key': 'Toypics',
|
2014-03-22 23:17:32 +09:00
|
|
|
} for eurl in urls]
|
2014-03-22 03:31:41 +09:00
|
|
|
}
|