]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/toypics.py
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
'http://videos\.toypics\.net/(?P<username>[^/?]+)(?:$|[?#])'
46 def _real_extract(self
, url
):
47 mobj
= re
.match(self
._VALID
_URL
, url
)
48 username
= mobj
.group('username')
50 profile_page
= self
._download
_webpage
(
51 url
, username
, note
='Retrieving profile page')
53 video_count
= int(self
._search
_regex
(
54 r
'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page
,
59 page_count
= (video_count
+ PAGE_SIZE
+ 1) // PAGE_SIZE
60 for n
in range(1, page_count
+ 1):
61 lpage_url
= url
+ '/public/%d' % n
62 lpage
= self
._download
_webpage
(
64 note
='Downloading page %d/%d' % (n
, page_count
))
67 r
'<p class="video-entry-title">\s+<a href="(https?://videos.toypics.net/view/[^"]+)">',