2 from __future__ import unicode_literals
4 from .common import InfoExtractor
8 class ToypicsIE(InfoExtractor):
9 IE_DESC = 'Toypics user profile'
10 _VALID_URL = r'https?://videos\.toypics\.net/view/(?P<id>[0-9]+)/.*'
12 'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/',
13 'md5': '16e806ad6d6f58079d210fe30985e08b',
17 'title': 'Chance-Bulge\'d, 2',
19 'uploader': 'kidsune',
23 def _real_extract(self, url):
24 mobj = re.match(self._VALID_URL, url)
25 video_id = mobj.group('id')
26 page = self._download_webpage(url, video_id)
27 formats = self._parse_html5_media_entries(url, page, video_id)[0]['formats']
28 title = self._html_search_regex([
29 r'<h1[^>]+class=["\']view-video-title[^>]+>([^<]+)</h',
30 r'<title>([^<]+) - Toypics</title>',
32 username = self._html_search_regex(
33 r'More videos from <strong>([^<]+)</strong>', page, 'username')
43 class ToypicsUserIE(InfoExtractor):
44 IE_DESC = 'Toypics user profile'
45 _VALID_URL = r'https?://videos\.toypics\.net/(?P<username>[^/?]+)(?:$|[?#])'
47 'url': 'http://videos.toypics.net/Mikey',
51 'playlist_mincount': 19,
54 def _real_extract(self, url):
55 mobj = re.match(self._VALID_URL, url)
56 username = mobj.group('username')
58 profile_page = self._download_webpage(
59 url, username, note='Retrieving profile page')
61 video_count = int(self._search_regex(
62 r'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page,
67 page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE
68 for n in range(1, page_count + 1):
69 lpage_url = url + '/public/%d' % n
70 lpage = self._download_webpage(
72 note='Downloading page %d/%d' % (n, page_count))
75 r'<div[^>]+class=["\']preview[^>]+>\s*<a[^>]+href="(https?://videos.toypics.net/view/[^"]+)"',