-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjf_playlist_exporter.py
36 lines (28 loc) · 1.05 KB
/
jf_playlist_exporter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import locale
from xml.dom import minidom
# Playlist directory.
g_dir = "/var/lib/jellyfin/data/playlists"
# There are subfolders in the playlist directory.
for filename in os.listdir(g_dir):
g_subdir = os.path.join(g_dir, filename)
print(g_subdir)
# In the subfolders there are xml files
for xml_playlist in os.listdir(g_subdir):
g_fullpath = os.path.join(g_subdir, xml_playlist)
playlist_name = filename + '.m3u8'
f_path = os.path.join(g_dir,playlist_name)
print("Creating playlist")
#print(playlist_name)
# Start to write a file
with open(f_path, 'w') as writer:
writer.write("#EXTM3U")
writer.write("\n")
# Parse for each song in the playlist...
mydoc = minidom.parse(g_fullpath)
items = mydoc.getElementsByTagName('Path')
# add it to the file
for elem in items:
writer.write(elem.firstChild.data.encode('utf8'))
writer.write("\n")
print("Done!")