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 | |
| 36 | 36 | config/.local/bin/quoterandom | |
| 37 | 37 | config/.local/bin/discord_timest | |
| 38 | 38 | scripts/Scripts/plex/playlists/* | |
| 39 | + | scripts/Scripts/plex/playlists_m3u/* | |
| 39 | 40 | scripts/Scripts/plex/posters/* | |
| 40 | 41 | config/.config/mpd.conf | |
| 41 | 42 | config/.config/rmpc/config.ron |
+12,
-0
| ... | ... | @@ -27,3 +27,15 @@ plex_playlist.py [TOKEN] | |
| 27 | 27 | ```bash | |
| 28 | 28 | plex_playlist_cover.py [TOKEN] | |
| 29 | 29 | ``` | |
| 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 | + | ``` |
| ... | ... | @@ -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() |