That's a good call, I'd forgot that in the spec. Here's an updated file
protocol definition that should work:

def file_protocol(~rlog,~maxtime,arg) =
  path = list.nth(default="", string.split(separator=":",arg), 1)
  segments = string.split(separator="/",path)

  segments =
    if list.length(segments) > 3 and
       list.nth(default="foo",segments,0) == "" and
       list.nth(default="foo",segments,1) == ""
    then
      list.tl(list.tl(segments))
    else
      segments
    end

  [url.decode(string.concat(separator="/",segments))]
end

add_protocol(static=true, temporary=false, "file", file_protocol,
             doc="File protocol. Only local files are supported",
             syntax="file:///path/to/file")

Le lun. 18 mai 2020 à 13:05, Thomas J. Webb <tho...@thomaswebb.net> a
écrit :

> I'm on 4.0.8. I don't know what you mean by adding file: at the
> beginning. They are file uris so they already have file:// at the
> beginning. It does look from the code at the bottom of this file
>
> https://github.com/savonet/liquidsoap/blob/77b6406f094b0732b41832ebaa5e2d33ab7218e4/libs/protocols.liq
> that it's doing just what I thought and treating it like it's just a
> regular path (not url decoding). And just to clarify, url decode would
> mean converting %20 to space.
>
> On Sun, May 17, 2020 at 6:13 PM Romain Beauxis <romain.beau...@gmail.com>
> wrote:
> >
> > Hi Thomas,
> >
> > That's an annoying issue indeed.
> >
> > What version of liquidsoap are you using? If your version is recent
> enough, you might be able to add a `file:` protocol that would take care of
> this for you.
> >
> > Matter of fact, I've also added it to our latest `master` branch.. You
> should be able to just add it to your script:
> >
> > def file_protocol(~rlog,~maxtime,arg) =
> >   path = list.nth(default="", string.split(separator=":",arg), 1)
> >   segments = string.split(separator="/",path)
> >
> >   segments =
> >     if list.length(segments) > 3 and
> >        list.nth(default="foo",segments,0) == "" and
> >        list.nth(default="foo",segments,1) == ""
> >     then
> >       list.tl(list.tl(segments))
> >     else
> >       segments
> >     end
> >
> >   path = string.concat(separator="/",segments)
> >
> >   # We support the buggy form: file://path/to/file"
> >   if file.exists("/#{path}") then
> >     ["/#{path}"]
> >   else
> >     [path]
> >   end
> > end
> >
> > add_protocol(static=true, temporary=false, "file", file_protocol,
> >              doc="File protocol. Only local files are supported",
> >              syntax="file:///path/to/file")
> >
> >
> > Le sam. 16 mai 2020 à 12:59, Thomas J. Webb <tho...@thomaswebb.net> a
> écrit :
> >>
> >> I just started using liquidsoap and it's awesome and solving a lot of
> >> problems for me. One minor issue I did have though is for when I tried
> >> playing a playlist I exported from audacious, it gets confused by
> >> files containing spaces. Audacious uses file:// uris instead of file
> >> paths and the uris are valid. It looks like when liquidsoap encounters
> >> a file uri, simply chops off the file:// part, then treats it like a
> >> regular file path instead of url decoding first:
> >>
> >> file:///mp3/PIRATESHIPS.mp3 <- works fine
> >>
> >> file:///mp3/taste%20in%20men.mp3 <- gives me "Nonexistent file or
> >> ill-formed URI ..."
> >>
> >> I encounter code doing this a lot and I've probably even written code
> >> that did this but unfortunately this heuristic causes problems.
> >>
> >>
> >> _______________________________________________
> >> Savonet-users mailing list
> >> Savonet-users@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/savonet-users
> >
> > _______________________________________________
> > Savonet-users mailing list
> > Savonet-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/savonet-users
>
> --
> Thomas J. Webb
> +1 760-912-1856 (US Cell)
> handfetisch (Skype)
>
>
> _______________________________________________
> Savonet-users mailing list
> Savonet-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/savonet-users
>
_______________________________________________
Savonet-users mailing list
Savonet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to