[beeg] Extract all formats
authorSergey M․ <dstftw@gmail.com>
Tue, 2 Sep 2014 13:54:00 +0000 (20:54 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 2 Sep 2014 13:54:00 +0000 (20:54 +0700)
youtube_dl/extractor/beeg.py

index d7301fe18ccf7f2324e3cb233ac93102ed076ba6..314e37f8bea9d44bc5ffe1545b17d02cc7d13fe2 100644 (file)
@@ -27,8 +27,16 @@ class BeegIE(InfoExtractor):
 
         webpage = self._download_webpage(url, video_id)
 
-        video_url = self._html_search_regex(
-            r"'480p'\s*:\s*'([^']+)'", webpage, 'video URL')
+        quality_arr = self._search_regex(
+            r'(?s)var\s+qualityArr\s*=\s*{\s*(.+?)\s*}', webpage, 'quality formats')
+
+        formats = [{
+            'url': fmt[1],
+            'format_id': fmt[0],
+            'height': int(fmt[0][:-1]),
+        } for fmt in re.findall(r"'([^']+)'\s*:\s*'([^']+)'", quality_arr)]
+
+        self._sort_formats(formats)
 
         title = self._html_search_regex(
             r'<title>([^<]+)\s*-\s*beeg\.?</title>', webpage, 'title')
@@ -48,10 +56,10 @@ class BeegIE(InfoExtractor):
 
         return {
             'id': video_id,
-            'url': video_url,
             'title': title,
             'description': description,
             'thumbnail': thumbnail,
             'categories': categories,
+            'formats': formats,
             'age_limit': 18,
         }