Script to amend item URL in playlist

Discuss your Lua playlist, album art and interface scripts.
Philip S
New Cone
New Cone
Posts: 2
Joined: 18 Jun 2024 10:26

Script to amend item URL in playlist

Postby Philip S » 18 Jun 2024 11:23

BLUF: is there a way to automatically take entries from the enqueued playlist and modify them before trying to open them?

Context:
  • VLC's M3U parser treats paths without a URL scheme as a relative URL, while every other media player treats them as un-encoded native path names, which means that in VLC any # or % is not URL-encoded when converting the entry into the absolute file URL needed by the VLC playlist. (A relative file URL cannot have a scheme, so there is no way to have a compatible relative playlist with those characters in filenames.)
  • The parsing in VLC is intentional, and won't be changed in the in-tree module
  • If possible, I'd like to achieve compatibility without having to maintain a fork of the parser
  • The simplest fix appears to be checking if the URL is a file URL and, if that file doesn't exist, testing whether URL-encoding any # or apparently-stray % in the URL produces a file that does exist
My first thought was to use the playlist plugin API, which gives you a URL and replaces it in the VLC playlist with some list of entries you have produced from it, but the probe() function isn't called until after the file's existence has been checked, which means I can't use it to "correct" the "playlist"'s own URL.

Is there any hook that can be used either to catch the result from the core parser so I can re-write it there or the URL of the file that's about to be opened? Failing that, is there any way to automatically iterate over the whole playlist? I presume an extension can do that, but the documentation for Lua extensions is "TODO".

Return to “Scripting VLC in lua”

Who is online

Users browsing this forum: No registered users and 3 guests