]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/toypics.py
2579ba8c67498c91aa117c6853b83f391ccb3ba6
   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         video_url 
= self
._html
_search
_regex
( 
  28             r
'src:\s+"(http://static[0-9]+\.toypics\.net/flvideo/[^"]+)"', page
, 'video URL') 
  29         title 
= self
._html
_search
_regex
( 
  30             r
'<title>Toypics - ([^<]+)</title>', page
, 'title') 
  31         username 
= self
._html
_search
_regex
( 
  32             r
'toypics.net/([^/"]+)" class="user-name">', page
, 'username') 
  42 class ToypicsUserIE(InfoExtractor
): 
  43     IE_DESC 
= 'Toypics user profile' 
  44     _VALID_URL 
= r
'https?://videos\.toypics\.net/(?P<username>[^/?]+)(?:$|[?#])' 
  46         'url': 'http://videos.toypics.net/Mikey', 
  50         'playlist_mincount': 19, 
  53     def _real_extract(self
, url
): 
  54         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  55         username 
= mobj
.group('username') 
  57         profile_page 
= self
._download
_webpage
( 
  58             url
, username
, note
='Retrieving profile page') 
  60         video_count 
= int(self
._search
_regex
( 
  61             r
'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page
, 
  66         page_count 
= (video_count 
+ PAGE_SIZE 
+ 1) // PAGE_SIZE
 
  67         for n 
in range(1, page_count 
+ 1): 
  68             lpage_url 
= url 
+ '/public/%d' % n
 
  69             lpage 
= self
._download
_webpage
( 
  71                 note
='Downloading page %d/%d' % (n
, page_count
)) 
  74                     r
'<p class="video-entry-title">\s+<a href="(https?://videos.toypics.net/view/[^"]+)">',