def cue_split(albumpath):
 count = 0
 cue_count = 0
 cue_dirs = []
 for (root, dirs, files) in os.walk(albumpath):
  for _file in files:
   extension = os.path.splitext(_file)[1].lower()[1:]
   if (extension in headphones.MEDIA_FORMATS):
    count += 1
   elif (extension == 'cue'):
    cue_count += 1
    if (root not in cue_dirs):
     cue_dirs.append(root)
 if (cue_count and (cue_count >= count) and cue_dirs):
  from headphones import logger, cuesplit
  logger.info('Attempting to split audio files by cue')
  cwd = os.getcwd()
  for cue_dir in cue_dirs:
   try:
    cuesplit.split(cue_dir)
   except Exception as e:
    os.chdir(cwd)
    logger.warn(('Cue not split: ' + str(e)))
    return False
  os.chdir(cwd)
  return True
 return False

def cue_split ( albumpath ) : count = 0 cue_count = 0 cue_dirs = [ ] for ( root , dirs , files ) in os . walk ( albumpath ) : for _file in files : extension = os . path . splitext ( _file ) [ 1 ] . lower ( ) [ 1 : ] if ( extension in headphones . MEDIA_FORMATS ) : count += 1 elif ( extension == 'cue' ) : cue_count += 1 if ( root not in cue_dirs ) : cue_dirs . append ( root ) if ( cue_count and ( cue_count >= count ) and cue_dirs ) : from headphones import logger , cuesplit logger . info ( 'Attempting to split audio files by cue' ) cwd = os . getcwd ( ) for cue_dir in cue_dirs : try : cuesplit . split ( cue_dir ) except Exception as e : os . chdir ( cwd ) logger . warn ( ( 'Cue not split: ' + str ( e ) ) ) return False os . chdir ( cwd ) return True return False
attempts to check and split audio files by a cue for the given directory .