Created
November 28, 2018 21:48
-
-
Save marios8543/ecf01003b126b9a46c3131a3be2b698d to your computer and use it in GitHub Desktop.
A python tool to convert ASF playlists to M3U playlists. Also performs path decoding...
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 xml.etree.ElementTree as et | |
from urllib.parse import unquote | |
import tkinter as tk | |
from tkinter import filedialog,messagebox | |
outstr = "#EXTM3U\n" | |
infile = filedialog.askopenfile(filetypes=(("ASF Playlists","*.asf"),)) | |
f = et.parse(infile).getroot() | |
count = 0 | |
for i in f.findall("entry"): | |
length = 0 | |
link = unquote(i.find("ref").get("href")) | |
try: | |
title = i.find("title").text | |
except Exception: | |
title = "" | |
try: | |
artist = i.find("author").text | |
except Exception: | |
artist = "" | |
outstr+="#EXTINF:{},{}{}\n{}\n".format(length,artist+" - " if artist else "",title,link) | |
count+=1 | |
with filedialog.asksaveasfile(filetypes=(("M3U Playlists","*.m3u"),)) as ofile: | |
ofile.write(outstr) | |
ofile.close() | |
messagebox.showinfo("Done", "Processed {} songs".format(count)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment