Created
February 8, 2019 22:22
-
-
Save EllieTheYeen/fe628e1d4064da81733961548bdb3f8a to your computer and use it in GitHub Desktop.
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
import urllib | |
import os | |
def tourlpath(a): | |
drive, path = os.path.abspath(a).replace('\\', '/').split('/', 1) | |
return 'file:///' + drive + '/' + urllib.quote(path) | |
directory = '.' | |
outfile = open('playlist.xspf', 'w') | |
outfile.write( | |
'<?xml version="1.0" encoding="UTF-8"?>' | |
'<playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">' | |
'<title>Playlist</title>' | |
'<trackList>\n'); | |
for folder, folders, files in os.walk(directory): | |
for file in files: | |
if not file.lower().endswith(('.mp3', '.mp4', '.wma', '.flac', '.ogg')): continue | |
path = tourlpath(os.path.join(folder, file)) | |
outfile.write('<track><location>%s</location></track>\n' % path) | |
outfile.flush() | |
outfile.write( | |
'</trackList>' | |
'<extension application="http://www.videolan.org/vlc/playlist/0">' | |
'<vlc:item tid="0"/>' | |
'</extension>' | |
'</playlist>\n'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment