Commit 4bf5d9a

xxwhirlpool  ·  2026-04-12 19:56:04 -0400 EDT
parent 73a5ff1
add `plex_playlist_m3u.py`
3 files changed,  +43, -0
+1, -0
......@@ -36,6 +36,7 @@ config/.local/bin/quote
3636 config/.local/bin/quoterandom
3737 config/.local/bin/discord_timest
3838 scripts/Scripts/plex/playlists/*
39+scripts/Scripts/plex/playlists_m3u/*
3940 scripts/Scripts/plex/posters/*
4041 config/.config/mpd.conf
4142 config/.config/rmpc/config.ron
+12, -0
......@@ -27,3 +27,15 @@ plex_playlist.py [TOKEN]
2727 ```bash
2828 plex_playlist_cover.py [TOKEN]
2929 ```
30+
31+## plex_playlist_m3u.py
32+
33+- exports to `~/Scripts/plex/playlists_m3u`
34+- each filename is the name of the playlist + `.m3u`
35+- song file paths are absolute paths from the server they're hosted on
36+
37+### usage
38+
39+```bash
40+plex_playlist_m3u.py [TOKEN]
41+```
+30, -0
......@@ -0,0 +1,30 @@
1+#!/usr/bin/env -S uv run --script
2+# /// script
3+# requires-python = ">=3.14"
4+# dependencies = [
5+# "plexapi>=4.18.1",
6+# ]
7+# ///
8+
9+# USAGE: plex_playlist_m3u.py [TOKEN]
10+#
11+# download all playlists as M3U files
12+
13+from plexapi.server import PlexServer
14+import sys
15+
16+SERVER_URL = "http://192.168.1.219:32400"
17+TOKEN = sys.argv[1]
18+
19+plex = PlexServer(SERVER_URL, TOKEN)
20+
21+for plist in plex.playlists(playlistType="audio"):
22+ list_title = plist.title
23+ list_items = plist.items()
24+ m3u = open("playlists_m3u/" + list_title + ".m3u", "w")
25+ m3u.write("#EXTM3U\n")
26+ for i in list_items:
27+ loc = i.locations
28+ for l in loc:
29+ m3u.write(l + "\n")
30+ m3u.close()