[bilibili] extract backup url
authorremitamine <remitamine@gmail.com>
Sat, 17 Oct 2015 17:30:51 +0000 (18:30 +0100)
committerremitamine <remitamine@gmail.com>
Sat, 17 Oct 2015 17:30:51 +0000 (18:30 +0100)
youtube_dl/extractor/bilibili.py

index 8f23a30ab00c7e78635a68a41326b8defb0cec58..85156ce49cca1b99f9e534f48c270f5e34621339 100644 (file)
@@ -58,13 +58,21 @@ class BiliBiliIE(InfoExtractor):
         entries = []
 
         for durl in durls:
+            formats = []
+            backup_url = durl.find('./backup_url')
+            if backup_url is not None:
+                formats.append({'url': backup_url.find('./url').text})
+            size = durl.find('./filesize|./size')
+            formats.append({
+                'url': durl.find('./url').text,
+                'filesize': int_or_none(size.text) if size else None,
+                'ext': 'flv',
+            })
             entries.append({
                 'id': '%s_part%s' % (cid, durl.find('./order').text),
                 'title': title,
-                'url': durl.find('./url').text,
-                'filesize': int_or_none(durl.find('./filesize').text),
-                'ext': 'flv',
                 'duration': int_or_none(durl.find('./length').text) // 1000,
+                'formats': formats,
             })
 
         info = {