Last active
August 29, 2015 14:02
-
-
Save steven2358/3755dbb7241f4c1dd38c to your computer and use it in GitHub Desktop.
Convert a playlist in text format to a cue file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert a playlist in text format to a cue file | |
# Author: steven2358 | |
# Usage: | |
# 1. Make a playlist file "playlist.txt" using this format: | |
''' | |
Album Artist - Album Name | |
FileName.mp3 | |
MM:SS:mm - Artist1 - Title1 | |
MM:SS:mm - Artist2 - Title2 | |
MM:SS:mm - Artist3 - Title3 | |
''' | |
# 2. Run "cue_sheet_converter playlist" | |
import sys | |
def parse_args(): | |
fname = sys.argv[1] | |
return fname | |
def main(): | |
fname = parse_args() | |
print fname | |
infile = open(fname+'.txt', 'rt') | |
outfile = open(fname+'.cue',"wt") | |
artistTitle = infile.readline() | |
mp3file = infile.readline() | |
[artist,albumTitle] = artistTitle.rsplit(" - ") | |
albumTitle = albumTitle.rstrip() | |
mp3file = mp3file.rstrip() | |
outfile.write("PERFORMER \""+artist+"\"\n") | |
outfile.write("TITLE \""+albumTitle+"\"\n") | |
outfile.write("FILE \""+mp3file+"\" MP3\n") | |
counter = 1; | |
for line in infile: | |
[trIndex,performer,trTitle] = line.rsplit(" - ") | |
trTitle = trTitle.rstrip() | |
track = str(counter).zfill(2) | |
counter += 1 | |
outfile.write(" TRACK "+track+" AUDIO\n") | |
outfile.write(" PERFORMER \""+performer+"\"\n") | |
outfile.write(" TITLE \""+trTitle+"\"\n") | |
outfile.write(" INDEX 01 "+trIndex+"\n") | |
outfile.close() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment