On Fri, Dec 11, 2015 at 06:22:22PM -0700, Mike Brown wrote:
> In the meantime, I would still be excited to know if there is a way to get 
> access to the filename or the full path from the playlist, so I don't have to 
> resort to annotations.

Figured it out.

If you run 'liquidsoap -r untaggedfile.mp3' you will see the undocumented 
metadata added by liquidsoap. This includes initial_uri and filename.

I don't know where these come from, but it seems that when the playlist is a 
list of file paths, initial_uri and filename values are the same, i.e. 
"filename" includes the whole path.

You can do some string manipulation to parse this path in an attempt to get 
discrete artist & title values, or you can whittle it down to just the base 
filename to set as title, omitting the artist. Here's the general idea:

def set_song(m) =
  a = m["artist"]
  t = m["title"]
  if a == "" and t == "" then
    # get the everything after the last slash or backslash in the filename
    t = list.nth(list.rev(string.split(separator='(/|\\)',m["filename"])),0)
    # remove the extension
    t = list.nth(string.split(separator='\.',t),0)
    # before first space-dash-space is artist, after is title
    parts = string.split(separator=" - ",t)
    if list.length(parts) > 1 then
      a = list.nth(parts,0)
      t = string.concat(separator=" - ",list.tl(parts))
      [("artist","#{a}"),("title","#{t}")]
    else
      [("artist","#{a}"),("title","#{t}")]
    end
  else
    [("artist","#{a}"),("title","#{t}")]
  end
end
s = map_metadata(strip=true,set_song,s)


While researching this, I discovered that if you want string.split() to have a 
lone backslash as the separator regex, separator='\\' will not parse. 
Strangely, separator='\\.' does work, but of course it picks up the next 
character after the backslash. I tried between one and four backslashes and 
combos with \029, all to no avail. Finally I hit on a workaround: 
separator='(\\)'. Bizarre!

------------------------------------------------------------------------------
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to