def perform_command(self):
        """
        Perform command and return the appropriate exit code.

        :rtype: int
        """
        if len(self.actual_arguments) < 2:
            return self.print_help()
        source_url = self.actual_arguments[0]
        output_file_path = self.actual_arguments[1]

        download = not self.has_option("--list")
        # largest_audio = True by default or if explicitly given
        if self.has_option("--largest-audio"):
            largest_audio = True
        else:
            largest_audio = not self.has_option("--smallest-audio")
        download_format = self.has_option_with_value("--format")

        try:
            if download:
                self.print_info(u"Downloading audio stream from '%s' ..." % source_url)
                downloader = Downloader(logger=self.logger)
                result = downloader.audio_from_youtube(
                    source_url,
                    download=True,
                    output_file_path=output_file_path,
                    download_format=download_format,
                    largest_audio=largest_audio,
                )
                self.print_info(u"Downloading audio stream from '%s' ... done" % source_url)
                self.print_success(u"Downloaded file '%s'" % result)
            else:
                self.print_info(u"Downloading stream info from '%s' ..." % source_url)
                downloader = Downloader(logger=self.logger)
                result = downloader.audio_from_youtube(
                    source_url,
                    download=False
                )
                self.print_info(u"Downloading stream info from '%s' ... done" % source_url)
                msg = []
                msg.append(u"%s\t%s\t%s\t%s" % ("Format", "Extension", "Bitrate", "Size"))
                for r in result:
                    filesize = gf.human_readable_number(r["filesize"])
                    msg.append(u"%s\t%s\t%s\t%s" % (r["format"], r["ext"], r["abr"], filesize))
                self.print_generic(u"Available audio streams:")
                self.print_generic(u"\n".join(msg))
            return self.NO_ERROR_EXIT_CODE
        except ImportError:
            self.print_no_dependency_error()
        except Exception as exc:
            self.print_error(u"An unexpected error occurred while downloading audio from YouTube:")
            self.print_error(u"%s" % exc)

        return self.ERROR_EXIT_CODE
def perform_command ( self ) : if len ( self . actual_arguments ) < 2 : return self . print_help ( ) source_url = self . actual_arguments [ 0 ] output_file_path = self . actual_arguments [ 1 ] download = not self . has_option ( "--list" ) if self . has_option ( "--largest-audio" ) : largest_audio = True else : largest_audio = not self . has_option ( "--smallest-audio" ) download_format = self . has_option_with_value ( "--format" ) try : if download : self . print_info ( u"Downloading audio stream from '%s' ..." % source_url ) downloader = Downloader ( logger = self . logger ) result = downloader . audio_from_youtube ( source_url , download = True , output_file_path = output_file_path , download_format = download_format , largest_audio = largest_audio , ) self . print_info ( u"Downloading audio stream from '%s' ... done" % source_url ) self . print_success ( u"Downloaded file '%s'" % result ) else : self . print_info ( u"Downloading stream info from '%s' ..." % source_url ) downloader = Downloader ( logger = self . logger ) result = downloader . audio_from_youtube ( source_url , download = False ) self . print_info ( u"Downloading stream info from '%s' ... done" % source_url ) msg = [ ] msg . append ( u"%s\t%s\t%s\t%s" % ( "Format" , "Extension" , "Bitrate" , "Size" ) ) for r in result : filesize = gf . human_readable_number ( r [ "filesize" ] ) msg . append ( u"%s\t%s\t%s\t%s" % ( r [ "format" ] , r [ "ext" ] , r [ "abr" ] , filesize ) ) self . print_generic ( u"Available audio streams:" ) self . print_generic ( u"\n" . join ( msg ) ) return self . NO_ERROR_EXIT_CODE except ImportError : self . print_no_dependency_error ( ) except Exception as exc : self . print_error ( u"An unexpected error occurred while downloading audio from YouTube:" ) self . print_error ( u"%s" % exc ) return self . ERROR_EXIT_CODE
Perform command and return the appropriate exit code.

        :rtype: int