savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.39k stars 128 forks source link

Using annotate in a request with add_protocol(temporary=true) fails to delete the temporary file #217

Closed daniel-j closed 6 years ago

daniel-j commented 9 years ago

My protocol definition:

def youtube_protocol(arg,delay)
    print("Loading YouTube request #{arg}")
    r = get_process_lines("node scripts/youtube "^quote(arg))
    print(r)
    r
end
add_protocol("youtube", temporary=true, youtube_protocol)

Example response from scripts/youtube:

annotate:title="Fallout 3 Three Dog Remix - Goin' Down In Post-Apocalyptia",artist="BBnanner",url="https://www.youtube.com/watch?v=EW_LneIjgGg",art="https://i.ytimg.com/vi/EW_LneIjgGg/hqdefault.jpg":/tmp/filename

Decoder accepts it, plays the songs but fails to delete the file

[decoder:3] Method "FFMPEG" accepted "/tmp/filename".
[request:3] Prepared "/tmp/filename" (RID 5).

... song plays ...

[request:3] Finished with "/tmp/filename".
[request:2] Unlink failed: "No such file or directory in unlink(annotate:title=\"Fallout 3 Three Dog 
Remix - Goin' Down In Post-Apocalyptia\",artist=\"BBnanner\",url=\"https://www.youtube.com/watch?v=EW_LneIjgGg\",art=\"ht
tps://i.ytimg.com/vi/EW_LneIjgGg/hqdefault.jpg\":/tmp/filename)"

Yes, it tries to delete what originally was requested (annotate + url) and not filename.

Source of the error (Unix.unlink): https://github.com/savonet/liquidsoap/blob/master/src/request.ml#L266

daniel-j commented 9 years ago

Temporary solution:

def track_ended(time, m)
    if m["temporary"] == "true" and m["filename"] != "" then
        system("rm "^quote(m["filename"]))
    end
end
source = on_end(delay=0., track_ended, source)

Note: you may have to add temporary=true to your annotate!

toots commented 6 years ago

Hi,

This part of the code was extensively worked on in 1.3.0. I'm gonna close this issue here, please reopen or submit a new one if you still have issues with recent versions.

vardrop commented 10 months ago

Still happening in 2.2.1

2023/11/05 13:25:06 [decoder.ffmpeg:3] Decoded content-type for "/tmp/liq-process78b34a.webm": {audio=pcm(stereo)}
2023/11/05 13:25:06 [decoder.taglib:2] Error while decoding file tags: Taglib.File.Invalid_file
2023/11/05 13:28:37 [decoder:2] Decoding "/tmp/liq-processcc673b.webm" ended: Ffmpeg_decoder.End_of_file.
2023/11/05 13:28:38 [s:3] Prepared "/tmp/liq-process78b34a.webm" (RID 3).
2023/11/05 13:28:38 [cross:3] Analysis: -10.492024dB / -21.447270dB (2.97s / 2.99s)
2023/11/05 13:28:38 [crossfade:3] Simple transition: crossed, fade-in, fade-out.
2023/11/05 13:28:38 [source.8:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [audio.add.2:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [fade_in.4:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [fade_in.3:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_track.8:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_metadata.4:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_track.7:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [cross_after.2:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [buffer.4:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [fade_out.4:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [fade_out.3:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_end.2:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_track.6:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_metadata.3:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [on_track.5:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [cross_before.2:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [buffer.3:3] Content type is {audio=pcm(stereo)}.
2023/11/05 13:28:38 [request:2] Unlink failed: "Unix.Unix_error(Unix.ENOENT, \"unlink\", \"annotate:comment=\\\"\\240\\159\\142\\182 Now Playing @ \\\\n\\\\t  Original Url: https://www.youtube.com/watch?v=DPoW19TUfg8\\\":youtube-dl:https://www.youtube.com/watch?v=DPoW19TUfg8\")"