def testGenerateFilenames_commonPathWithSpaces(self): songs = self.convert_filelist([r"root/zouk rapido/song1.mp3", "root/zouk lento/song1.mp3"]) renamed_filenames = [renamed_filename for renamed_filename, _ in generate_filenames(songs)] self.assertEqual(["1 - zouk rapido_song1.mp3", "2 - zouk lento_song1.mp3"], renamed_filenames) songs = self.convert_filelist([r"zouk rapido/song1.mp3", "zouk lento/song1.mp3"]) renamed_filenames = [renamed_filename for renamed_filename, _ in generate_filenames(songs)] self.assertEqual(["1 - zouk rapido_song1.mp3", "2 - zouk lento_song1.mp3"], renamed_filenames)
def testGenerateFilenames(self): self.assertEqual([], generate_filenames([])) songs = self.convert_filelist(["song1.mp3", "dir1/song2.mp3", "dir2/song2.mp3"]) self.assertEqual([("1 - song1.mp3", "song1.mp3"), ("2 - dir1_song2.mp3", "dir1/song2.mp3"), ("3 - dir2_song2.mp3", "dir2/song2.mp3")], generate_filenames(songs)) renamed_filenames = [renamed_filename for renamed_filename, _ in generate_filenames(songs)] self.assertEqual(["1 - song1.mp3", "2 - dir1_song2.mp3", "3 - dir2_song2.mp3"], sorted(renamed_filenames))
def main(): filename = "playlist.txt" if len(sys.argv) > 1: filename = sys.argv[1] if not os.path.exists(filename): if platform.system() == "Windows": with open("playlist.txt", 'w') as f: playlist_sample = \ r"""Zouk=c:\musicas\zouk\ Forro=c:\musicas\forro\ SambaLento=c:\musicas\Sambas\samba lento SambaRapido=c:\musicas\Sambas\samba rapido 3 Zouk 2 Forro""" f.write(playlist_sample) f.close() subprocess.check_call("notepad playlist.txt", shell=True) filename = "playlist.txt" else: print("File %s does not exist" % filename) return print("Reading songs from %s " % filename) songs = fetch_songs(filename) out_files = generate_filenames(songs) copy_songs(out_files, 'output') set_ID3(['output' + os.sep + filename for filename, _ in out_files])
def main(): filename = "playlist.txt" if len(sys.argv) > 1: filename = sys.argv[1] if not os.path.exists(filename): if platform.system() == "Windows": with open("playlist.txt", 'w') as f: playlist_sample = \ r"""Zouk=c:\musicas\zouk\ Forro=c:\musicas\forro\ SambaLento=c:\musicas\Sambas\samba lento SambaRapido=c:\musicas\Sambas\samba rapido 3 Zouk 2 Forro""" f.write(playlist_sample) f.close() subprocess.check_call("notepad playlist.txt", shell = True) filename = "playlist.txt" else: print("File %s does not exist" % filename) return print("Reading songs from %s " % filename) songs = fetch_songs(filename) out_files = generate_filenames(songs) copy_songs(out_files, 'output') set_ID3(['output' + os.sep + filename for filename, _ in out_files])
def testGenerateFilenames(self): self.assertEqual([], generate_filenames([])) songs = self.convert_filelist( ["song1.mp3", "dir1/song2.mp3", "dir2/song2.mp3"]) self.assertEqual([("1 - song1.mp3", "song1.mp3"), ("2 - dir1_song2.mp3", "dir1/song2.mp3"), ("3 - dir2_song2.mp3", "dir2/song2.mp3")], generate_filenames(songs)) renamed_filenames = [ renamed_filename for renamed_filename, _ in generate_filenames(songs) ] self.assertEqual( ["1 - song1.mp3", "2 - dir1_song2.mp3", "3 - dir2_song2.mp3"], sorted(renamed_filenames))
def testGenerateFilenames_commonPathWithSpaces(self): songs = self.convert_filelist( [r"root/zouk rapido/song1.mp3", "root/zouk lento/song1.mp3"]) renamed_filenames = [ renamed_filename for renamed_filename, _ in generate_filenames(songs) ] self.assertEqual( ["1 - zouk rapido_song1.mp3", "2 - zouk lento_song1.mp3"], renamed_filenames) songs = self.convert_filelist( [r"zouk rapido/song1.mp3", "zouk lento/song1.mp3"]) renamed_filenames = [ renamed_filename for renamed_filename, _ in generate_filenames(songs) ] self.assertEqual( ["1 - zouk rapido_song1.mp3", "2 - zouk lento_song1.mp3"], renamed_filenames)
def testGenerateFilenames_commonPath(self): songs = self.convert_filelist([ "root/common_path/dir1/song1.mp3", "root/common_path/song2.mp3", "root/common_path/dir2/song2.mp3" ]) renamed_filenames = [ renamed_filename for renamed_filename, _ in generate_filenames(songs) ] self.assertEqual( ["1 - dir1_song1.mp3", "2 - song2.mp3", "3 - dir2_song2.mp3"], renamed_filenames)
def testGenerateFilenames_commonPath(self): songs = self.convert_filelist(["root/common_path/dir1/song1.mp3", "root/common_path/song2.mp3", "root/common_path/dir2/song2.mp3"]) renamed_filenames = [renamed_filename for renamed_filename, _ in generate_filenames(songs)] self.assertEqual(["1 - dir1_song1.mp3", "2 - song2.mp3", "3 - dir2_song2.mp3"], renamed_filenames)
def testGenerateFilenames_addPaddingZeroes(self): songs = generate_filenames(["song1.mp3"] * 100) self.assertEqual(("001 - song1.mp3", "song1.mp3"), songs[0]) self.assertEqual(("002 - song1.mp3", "song1.mp3"), songs[1]) self.assertEqual(("100 - song1.mp3", "song1.mp3"), songs[99])