[servingsys] Add support
[youtube-dl] / youtube_dl / YoutubeDL.py
index 3786799da7967ca8522462758ee81318f1e06214..dc8aa788cf3ba8830cfd97e192b2153a4573063d 100644 (file)
@@ -55,7 +55,7 @@ from .utils import (
 )
 from .extractor import get_info_extractor, gen_extractors
 from .downloader import get_suitable_downloader
-from .PostProcessor import FFmpegMergerPP
+from .postprocessor import FFmpegMergerPP
 from .version import __version__
 
 
@@ -151,11 +151,16 @@ class YoutubeDL(object):
     bidi_workaround:   Work around buggy terminals without bidirectional text
                        support, using fridibi
     debug_printtraffic:Print out sent and received HTTP traffic
+    include_ads:       Download ads as well
 
     The following parameters are not used by YoutubeDL itself, they are used by
     the FileDownloader:
     nopart, updatetime, buffersize, ratelimit, min_filesize, max_filesize, test,
     noresizebuffer, retries, continuedl, noprogress, consoletitle
+
+    The following options are used by the post processors:
+    prefer_ffmpeg:     If True, use ffmpeg instead of avconv if both are available,
+                       otherwise prefer avconv.
     """
 
     params = None
@@ -702,7 +707,7 @@ class YoutubeDL(object):
         if req_format in ('-1', 'all'):
             formats_to_download = formats
         else:
-            # We can accept formats requestd in the format: 34/5/best, we pick
+            # We can accept formats requested in the format: 34/5/best, we pick
             # the first that is available, starting from left
             req_formats = req_format.split('/')
             for rf in req_formats:
@@ -712,7 +717,11 @@ class YoutubeDL(object):
                     formats_info = (self.select_format(format_1, formats),
                         self.select_format(format_2, formats))
                     if all(formats_info):
-                        selected_format = {'requested_formats': formats_info}
+                        selected_format = {
+                            'requested_formats': formats_info,
+                            'format': rf,
+                            'ext': formats_info[0]['ext'],
+                        }
                     else:
                         selected_format = None
                 else:
@@ -900,6 +909,14 @@ class YoutubeDL(object):
                     if info_dict.get('requested_formats') is not None:
                         downloaded = []
                         success = True
+                        merger = FFmpegMergerPP(self)
+                        if not merger._get_executable():
+                            postprocessors = []
+                            self.report_warning('You have requested multiple '
+                                'formats but ffmpeg or avconv are not installed.'
+                                ' The formats won\'t be merged')
+                        else:
+                            postprocessors = [merger]
                         for f in info_dict['requested_formats']:
                             new_info = dict(info_dict)
                             new_info.update(f)
@@ -908,7 +925,7 @@ class YoutubeDL(object):
                             downloaded.append(fname)
                             partial_success = dl(fname, new_info)
                             success = success and partial_success
-                        info_dict['__postprocessors'] = [FFmpegMergerPP(self)]
+                        info_dict['__postprocessors'] = postprocessors
                         info_dict['__files_to_merge'] = downloaded
                     else:
                         # Just a single file
@@ -1058,7 +1075,9 @@ class YoutubeDL(object):
                 res += '%4dk ' % fdict['tbr']
             if (fdict.get('vcodec') is not None and
                     fdict.get('vcodec') != 'none'):
-                res += '%-5s@' % fdict['vcodec']
+                res += '%-5s' % fdict['vcodec']
+                if fdict.get('vbr') is not None:
+                    res += '@'
             elif fdict.get('vbr') is not None and fdict.get('abr') is not None:
                 res += 'video@'
             if fdict.get('vbr') is not None: