#NEWLINE# def main( ) : #NEWLINE# #INDENT# if ( len ( sys . argv ) < 3 ) : #NEWLINE# #INDENT# exit ( 'Usage: {0} <url> <quality>' . format ( sys . argv [ 0 ] ) ) #NEWLINE# #UNINDENT# gi . require_version ( 'Gst' , '1.0' ) #NEWLINE# gobject . threads_init ( ) #NEWLINE# gst . init ( None ) #NEWLINE# url = sys . argv [ 1 ] #NEWLINE# quality = sys . argv [ 2 ] #NEWLINE# livestreamer = Livestreamer ( ) #NEWLINE# livestreamer . set_loglevel ( 'info' ) #NEWLINE# livestreamer . set_logoutput ( sys . stdout ) #NEWLINE# try : #NEWLINE# #INDENT# streams = livestreamer . streams ( url ) #NEWLINE# #UNINDENT# except NoPluginError : #NEWLINE# #INDENT# exit ( "Livestreamer is unable to handle the URL '{0}'" . format ( url ) ) #NEWLINE# #UNINDENT# except PluginError as err : #NEWLINE# #INDENT# exit ( 'Plugin error: {0}' . format ( err ) ) #NEWLINE# #UNINDENT# if ( not streams ) : #NEWLINE# #INDENT# exit ( "No streams found on URL '{0}'" . format ( url ) ) #NEWLINE# #UNINDENT# if ( quality not in streams ) : #NEWLINE# #INDENT# exit ( "Unable to find '{0}' stream on URL '{1}'" . format ( quality , url ) ) #NEWLINE# #UNINDENT# stream = streams [ quality ] #NEWLINE# player = LivestreamerPlayer ( ) #NEWLINE# player . play ( stream )