def _do_query(lib, query, album, also_items=True):
 if album:
  albums = list(lib.albums(query))
  items = []
  if also_items:
   for al in albums:
    items += al.items()
 else:
  albums = []
  items = list(lib.items(query))
 if (album and (not albums)):
  raise ui.UserError('No matching albums found.')
 elif ((not album) and (not items)):
  raise ui.UserError('No matching items found.')
 return (items, albums)

def _do_query ( lib , query , album , also_items = True ) : if album : albums = list ( lib . albums ( query ) ) items = [ ] if also_items : for al in albums : items += al . items ( ) else : albums = [ ] items = list ( lib . items ( query ) ) if ( album and ( not albums ) ) : raise ui . UserError ( 'No matching albums found.' ) elif ( ( not album ) and ( not items ) ) : raise ui . UserError ( 'No matching items found.' ) return ( items , albums )
perform http request using mpsyt user agent header .