[toypics] Fix extraction
authorvobe <vobe@jackal.fr>
Fri, 19 May 2017 18:18:03 +0000 (20:18 +0200)
committerSergey M <dstftw@gmail.com>
Fri, 19 May 2017 18:18:03 +0000 (01:18 +0700)
youtube_dl/extractor/toypics.py

index 938e05076313cb5b3d3284083d2cc7e699241d21..774fa565c3762bcd748e7acb89f1b634057ce541 100644 (file)
@@ -24,15 +24,16 @@ class ToypicsIE(InfoExtractor):
         mobj = re.match(self._VALID_URL, url)
         video_id = mobj.group('id')
         page = self._download_webpage(url, video_id)
-        video_url = self._html_search_regex(
-            r'src:\s+"(http://static[0-9]+\.toypics\.net/flvideo/[^"]+)"', page, 'video URL')
-        title = self._html_search_regex(
-            r'<title>Toypics - ([^<]+)</title>', page, 'title')
+        formats = self._parse_html5_media_entries(url, page, video_id)[0]['formats']
+        title = self._html_search_regex([
+            r'<h1[^>]+class=["\']view-video-title[^>]+>([^<]+)</h',
+            r'<title>([^<]+) - Toypics</title>',
+        ], page, 'title')
         username = self._html_search_regex(
-            r'toypics.net/([^/"]+)" class="user-name">', page, 'username')
+            r'More videos from <strong>([^<]+)</strong>', page, 'username')
         return {
             'id': video_id,
-            'url': video_url,
+            'formats': formats,
             'title': title,
             'uploader': username,
             'age_limit': 18,
@@ -71,7 +72,7 @@ class ToypicsUserIE(InfoExtractor):
                 note='Downloading page %d/%d' % (n, page_count))
             urls.extend(
                 re.findall(
-                    r'<p class="video-entry-title">\s+<a href="(https?://videos.toypics.net/view/[^"]+)">',
+                    r'<div[^>]+class=["\']preview[^>]+>\s*<a[^>]+href="(https?://videos.toypics.net/view/[^"]+)"',
                     lpage))
 
         return {