#NEWLINE# def play_music( self , lib , opts , args ) : #NEWLINE# #INDENT# 'Execute query, create temporary playlist and execute player\n        command passing that playlist, at request insert optional arguments.\n        ' #NEWLINE# command_str = config [ 'play' ] [ 'command' ] . get ( ) #NEWLINE# if ( not command_str ) : #NEWLINE# #INDENT# command_str = util . open_anything ( ) #NEWLINE# #UNINDENT# use_folders = config [ 'play' ] [ 'use_folders' ] . get ( bool ) #NEWLINE# relative_to = config [ 'play' ] [ 'relative_to' ] . get ( ) #NEWLINE# raw = config [ 'play' ] [ 'raw' ] . get ( bool ) #NEWLINE# warning_threshold = config [ 'play' ] [ 'warning_threshold' ] . get ( int ) #NEWLINE# if ( warning_threshold == ( - 2 ) ) : #NEWLINE# #INDENT# warning_threshold = config [ 'play' ] [ 'warning_treshold' ] . get ( int ) #NEWLINE# #UNINDENT# if relative_to : #NEWLINE# #INDENT# relative_to = util . normpath ( relative_to ) #NEWLINE# #UNINDENT# if opts . args : #NEWLINE# #INDENT# if ( ARGS_MARKER in command_str ) : #NEWLINE# #INDENT# command_str = command_str . replace ( ARGS_MARKER , opts . args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# command_str = '{} {}' . format ( command_str , opts . args ) #NEWLINE# #UNINDENT# #UNINDENT# if opts . album : #NEWLINE# #INDENT# selection = lib . albums ( ui . decargs ( args ) ) #NEWLINE# paths = [ ] #NEWLINE# sort = lib . get_default_album_sort ( ) #NEWLINE# for album in selection : #NEWLINE# #INDENT# if use_folders : #NEWLINE# #INDENT# paths . append ( album . item_dir ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# paths . extend ( ( item . path for item in sort . sort ( album . items ( ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# item_type = 'album' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# selection = lib . items ( ui . decargs ( args ) ) #NEWLINE# paths = [ item . path for item in selection ] #NEWLINE# if relative_to : #NEWLINE# #INDENT# paths = [ relpath ( path , relative_to ) for path in paths ] #NEWLINE# #UNINDENT# item_type = 'track' #NEWLINE# #UNINDENT# item_type += ( 's' if ( len ( selection ) > 1 ) else '' ) #NEWLINE# if ( not selection ) : #NEWLINE# #INDENT# ui . print_ ( ui . colorize ( 'text_warning' , 'No {0} to play.' . format ( item_type ) ) ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( warning_threshold and ( len ( selection ) > warning_threshold ) ) : #NEWLINE# #INDENT# ui . print_ ( ui . colorize ( 'text_warning' , 'You are about to queue {0} {1}.' . format ( len ( selection ) , item_type ) ) ) #NEWLINE# if ( ui . input_options ( ( 'Continue' , 'Abort' ) ) == 'a' ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# ui . print_ ( 'Playing {0} {1}.' . format ( len ( selection ) , item_type ) ) #NEWLINE# if raw : #NEWLINE# #INDENT# open_args = paths #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# open_args = [ self . _create_tmp_playlist ( paths ) ] #NEWLINE# #UNINDENT# self . _log . debug ( 'executing command: {} {}' , command_str , b' ' . join ( opts ) ) #NEWLINE# try : #NEWLINE# #INDENT# util . interactive_open ( open_args , command_str ) #NEWLINE# #UNINDENT# except OSError as exc : #NEWLINE# #INDENT# raise ui . UserError ( 'Could not play the query: {0}' . format ( exc ) )