def check_exists(music_file, raw_song, islist=True): """Check if the input song already exists in the given folder.""" songs = os.listdir(args.folder) for song in songs: if song.endswith('.temp'): os.remove(os.path.join(args.folder, song)) continue # check if any song with similar name is already present in the given folder file_name = misc.sanitize_title(music_file) if song.startswith(file_name): # check if the already downloaded song has correct metadata already_tagged = metadata.compare(os.path.join(args.folder, song), generate_metadata(raw_song)) # if not, remove it and download again without prompt if misc.is_spotify(raw_song) and not already_tagged: os.remove(os.path.join(args.folder, song)) return False # do not prompt and skip the current song # if already downloaded when using list if islist: return True # if downloading only single song, prompt to re-download else: prompt = input( 'Song with same name has already been downloaded. ' 'Re-download? (y/n): ').lower() if prompt == 'y': os.remove(os.path.join(args.folder, song)) return False else: return True return False
def check_exists(music_file, raw_song, islist): files = os.listdir("Music") for file in files: if file.endswith(".temp"): os.remove("Music/" + file) continue # check if any file with similar name is already present in Music/ dfile = misc.fix_decoding(file) umfile = misc.fix_decoding(misc.generate_filename(music_file)) if dfile.startswith(umfile): # check if the already downloaded song has correct metadata already_tagged = metadata.compare(file, generate_metadata(raw_song)) # if not, remove it and download again without prompt if misc.is_spotify(raw_song) and not already_tagged: os.remove("Music/" + file) return False # do not prompt and skip the current song if already downloaded when using list if islist: return True # if downloading only single song, prompt to re-download else: prompt = misc.user_input('Song with same name has already been downloaded. Re-download? (y/n): ').lower() if prompt == "y": os.remove("Music/" + file) return False else: return True
def check_exists(music_file, raw_song, meta_tags, folder): """ Check if the input song already exists in the given folder. """ log.debug('Cleaning any temp files and checking ' 'if "{}" already exists'.format(music_file)) songs = os.listdir(folder) for song in songs: if song.endswith('.temp'): os.remove(os.path.join(folder, song)) continue # check if any song with same name is already present in the given folder if os.path.splitext(song)[0] == music_file: log.debug('Found an already existing song: "{}"'.format(song)) if internals.is_spotify(raw_song): # check if the already downloaded song has correct metadata # if not, remove it and download again without prompt already_tagged = metadata.compare(os.path.join(folder, song), meta_tags) log.debug( 'Checking if it is already tagged correctly? {}'.format( already_tagged)) if not already_tagged: os.remove(os.path.join(folder, song)) return False log.debug('Skipping "{}"'.format(song)) return True return False
def check_exists(music_file, raw_song, meta_tags): """ Check if the input song already exists in the given folder. """ log.debug('Cleaning any temp files and checking ' 'if "{}" already exists'.format(music_file)) songs = os.listdir(args.folder) for song in songs: if song.endswith('.temp'): os.remove(os.path.join(args.folder, song)) continue # check if any song with similar name is already present in the given folder file_name = internals.sanitize_title(music_file) if song.startswith(file_name): log.debug('Found an already existing song: "{}"'.format(song)) if internals.is_spotify(raw_song): # check if the already downloaded song has correct metadata # if not, remove it and download again without prompt already_tagged = metadata.compare( os.path.join(args.folder, song), meta_tags) log.debug('Checking if it is already tagged correctly? {}', already_tagged) if not already_tagged: os.remove(os.path.join(args.folder, song)) return False log.warning('"{}" already exists'.format(song)) if args.overwrite == 'prompt': log.info('"{}" has already been downloaded. ' 'Re-download? (y/N): '.format(song)) prompt = input('> ') if prompt.lower() == 'y': os.remove(os.path.join(args.folder, song)) return False else: return True elif args.overwrite == 'force': os.remove(os.path.join(args.folder, song)) log.info('Overwriting "{}"'.format(song)) return False elif args.overwrite == 'skip': log.info('Skipping "{}"'.format(song)) return True return False