M
M
Maxim Vlasov2019-02-18 14:07:17
macOS
Maxim Vlasov, 2019-02-18 14:07:17

VLC player. How to copy track name to clipboard (lua)?

Hello.
There is a VLC player on MAC OS. But the ability to copy the name of the track of an online radio station is not implemented.
There is a LUA script for writing this information to a file.

-- now_playing / radio
function now_playing_radio()
    local item=vlc.item or vlc.input.item()
        io.output(vlc.config.userdatadir() .. "/np_radio.txt")
            if item:metas()["now_playing"] then
            io.write(item:metas()["now_playing"])
    else
        io.write(item:name())
        end
    io.close()
end

But I need it in the poppy clipboard, I tried this and that, but it didn’t help:
The first option:
-- now_playing / radio ClipBoard
function set_clipboard()
    local item=vlc.item or vlc.input.item()
        io.popen('cbcopy','w')
            if item:metas()["now_playing"] then
            io.write(item:metas()["now_playing"])
    else
            io.write(item:name())
        end
    io.close()
end

Second option:
-- now_playing / radio ClipBoard
function set_clipboard()
    local item=vlc.item or vlc.input.item()
        if item:metas()["now_playing"] then
        io.popen('pbcopy','w'):write(item:metas()["now_playing"])
    else
        io.popen('pbcopy','w'):write(item:name())
        end
    close()
end

Any thoughts?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question