]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | import re | |
3 | ||
4 | ||
5 | class ToypicsIE(InfoExtractor): | |
6 | _WORKING = False | |
7 | IE_DESC = 'Toypics video' | |
8 | _VALID_URL = r'https?://videos\.toypics\.net/view/(?P<id>[0-9]+)' | |
9 | _TEST = { | |
10 | 'url': 'http://videos.toypics.net/view/514/chancebulged,-2-1/', | |
11 | 'md5': '16e806ad6d6f58079d210fe30985e08b', | |
12 | 'info_dict': { | |
13 | 'id': '514', | |
14 | 'ext': 'mp4', | |
15 | 'title': "Chance-Bulge'd, 2", | |
16 | 'age_limit': 18, | |
17 | 'uploader': 'kidsune', | |
18 | } | |
19 | } | |
20 | ||
21 | def _real_extract(self, url): | |
22 | video_id = self._match_id(url) | |
23 | ||
24 | webpage = self._download_webpage(url, video_id) | |
25 | ||
26 | formats = self._parse_html5_media_entries( | |
27 | url, webpage, video_id)[0]['formats'] | |
28 | title = self._html_search_regex([ | |
29 | r'<h1[^>]+class=["\']view-video-title[^>]+>([^<]+)</h', | |
30 | r'<title>([^<]+) - Toypics</title>', | |
31 | ], webpage, 'title') | |
32 | ||
33 | uploader = self._html_search_regex( | |
34 | r'More videos from <strong>([^<]+)</strong>', webpage, 'uploader', | |
35 | fatal=False) | |
36 | ||
37 | return { | |
38 | 'id': video_id, | |
39 | 'formats': formats, | |
40 | 'title': title, | |
41 | 'uploader': uploader, | |
42 | 'age_limit': 18, | |
43 | } | |
44 | ||
45 | ||
46 | class ToypicsUserIE(InfoExtractor): | |
47 | _WORKING = False | |
48 | IE_DESC = 'Toypics user profile' | |
49 | _VALID_URL = r'https?://videos\.toypics\.net/(?!view)(?P<id>[^/?#&]+)' | |
50 | _TEST = { | |
51 | 'url': 'http://videos.toypics.net/Mikey', | |
52 | 'info_dict': { | |
53 | 'id': 'Mikey', | |
54 | }, | |
55 | 'playlist_mincount': 19, | |
56 | } | |
57 | ||
58 | def _real_extract(self, url): | |
59 | username = self._match_id(url) | |
60 | ||
61 | profile_page = self._download_webpage( | |
62 | url, username, note='Retrieving profile page') | |
63 | ||
64 | video_count = int(self._search_regex( | |
65 | r'public/">Public Videos \(([0-9]+)\)</a></li>', profile_page, | |
66 | 'video count')) | |
67 | ||
68 | PAGE_SIZE = 8 | |
69 | urls = [] | |
70 | page_count = (video_count + PAGE_SIZE + 1) // PAGE_SIZE | |
71 | for n in range(1, page_count + 1): | |
72 | lpage_url = url + '/public/%d' % n | |
73 | lpage = self._download_webpage( | |
74 | lpage_url, username, | |
75 | note='Downloading page %d/%d' % (n, page_count)) | |
76 | urls.extend( | |
77 | re.findall( | |
78 | r'<div[^>]+class=["\']preview[^>]+>\s*<a[^>]+href="(https?://videos\.toypics\.net/view/[^"]+)"', | |
79 | lpage)) | |
80 | ||
81 | return { | |
82 | '_type': 'playlist', | |
83 | 'id': username, | |
84 | 'entries': [{ | |
85 | '_type': 'url', | |
86 | 'url': eurl, | |
87 | 'ie_key': 'Toypics', | |
88 | } for eurl in urls] | |
89 | } |