[animeondemand] Extract teaser when no full episode available (#8923)
authorSergey M․ <dstftw@gmail.com>
Mon, 21 Mar 2016 17:35:50 +0000 (23:35 +0600)
committerSergey M․ <dstftw@gmail.com>
Mon, 21 Mar 2016 17:35:50 +0000 (23:35 +0600)
youtube_dl/extractor/animeondemand.py

index 81a8430354ea2be9c87292f1ad62c0e95fa51f1b..a4769773859fc63879a97f094f4a9b1e11a1bcd0 100644 (file)
@@ -225,16 +225,18 @@ class AnimeOnDemandIE(InfoExtractor):
                 })
                 entries.append(f)
 
-            m = re.search(
-                r'data-dialog-header=(["\'])(?P<title>.+?)\1[^>]+href=(["\'])(?P<href>.+?)\3[^>]*>Teaser<',
-                episode_html)
-            if m:
-                f = common_info.copy()
-                f.update({
-                    'id': '%s-teaser' % f['id'],
-                    'title': m.group('title'),
-                    'url': compat_urlparse.urljoin(url, m.group('href')),
-                })
-                entries.append(f)
+            # Extract teaser only when full episode is not available
+            if not formats:
+                m = re.search(
+                    r'data-dialog-header=(["\'])(?P<title>.+?)\1[^>]+href=(["\'])(?P<href>.+?)\3[^>]*>Teaser<',
+                    episode_html)
+                if m:
+                    f = common_info.copy()
+                    f.update({
+                        'id': '%s-teaser' % f['id'],
+                        'title': m.group('title'),
+                        'url': compat_urlparse.urljoin(url, m.group('href')),
+                    })
+                    entries.append(f)
 
         return self.playlist_result(entries, anime_id, anime_title, anime_description)