Re: [Banshee-List] Banshee 1.2.0 - importing m3u playlist(s)



Kevin Digi wrote:
hi

Thanks for the advice. It will be a hell of a job because I do have a lot of playlists/songs. It would maybe a nice feature in the future being able to convert windows-like paths?


Try using this Python script to convert your playlists. I don't have a Windows partition but it works for me on a couple of test files. Be sure to keep backup copies of the playlists. The usage is

    python win2unix.py /path/to/infile /mnt/windows/c

where /mnt/windows/ c is the mount point of the Windows partition



jon


# Convert Windows path to Unix
# Usage: python win2unix.py /path/to/infile /mnt/windows/c
# where /mnt/windows/ c is the mount point of the Windows partition


import sys, string


def win2unix(m3ufile, mountpoint):
    winroot = "C:"
    winsep = "\\"
    unixsep = "/"
    curr = "init"
    
    infile = open(m3ufile, "r")
    tmpfile = infile.read()
    infile.close()
    
    tmpfile = string.replace(tmpfile, winroot, mountpoint)
    tmpfile = string.replace(tmpfile, winsep, unixsep)
    
    outfile = open(m3ufile, "w")
    outfile.write(tmpfile)
    outfile.close()
    
if __name__ == '__main__':
    win2unix(sys.argv[1], sys.argv[2])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]