1 from .common import InfoExtractor
5 class ToypicsIE(InfoExtractor):
6 _VALID_URL = r'(?:http://)?videos\.toypics\.net/.*'
8 'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/',
9 #'md5': '8a8b546956bbd0e769dbe28f6e80abb3', == $head -c10K 12929646011616163504.mp4 |md5sum //no idea why it fails
13 'title': 'Chance-Bulge\'d, 2',
19 def _real_extract(self, url):
20 mobj = re.match(r'(http://)?videos\.toypics\.net/(?P<username>[^/?]+)$', url)
22 return self.extract_one(url)
23 return [self.extract_one(u) for u in self.process_paginated(url,
24 r'public/">Public Videos \((?P<videos_count>[0-9]+)\)</a></li>',
25 r'<p class="video-entry-title">\n\s*<a href="(http://videos.toypics.net/view/[^"]+)">'
28 def process_paginated(self, profile_url, re_total, re_video_page):
29 profile_page = self._download_webpage(profile_url, 'profile' , 'getting profile page: '+profile_url)
30 videos_count = self._html_search_regex(re_total, profile_page, 'videos count')
32 for n in xrange(1,int(ceil(float(videos_count)/self.PAGINATED)) +1):
33 lpage_url = profile_url +'/public/%d'%n
34 lpage = self._download_webpage(lpage_url, 'page %d'%n)
35 lst.extend(re.findall(re_video_page, lpage))
38 def extract_one(self,url):
39 mobj = re.match(r'(http://)?videos\.toypics\.net/view/(?P<videoid>[0-9]+)/.*', url)
40 video_id = mobj.group('videoid')
41 page = self._download_webpage(url, video_id, 'getting page: '+url)
42 video_url = self._html_search_regex(
43 r'src:\s+"(http://static[0-9]+\.toypics\.net/flvideo/[^"]+)"', page, 'video URL')
44 title = self._html_search_regex(
45 r'<title>Toypics - ([^<]+)</title>', page, 'title')
46 username = self._html_search_regex(
47 r'toypics.net/([^/"]+)" class="user-name">', page, 'username')
51 'ext': video_url[-3:],