summaryrefslogtreecommitdiff
path: root/smil.lua
blob: 030e19b1ca9a71a8096daac30728cb94dc53dc76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local utils = require 'mp.utils'
local msg = require 'mp.msg'
local options = require 'mp.options'

mp.add_hook("on_load" or "on_load_fail", 50, function ()
    local url = mp.get_property("stream-open-filename", "")

    if not (string.match(url, '^http') == nil) then
        msg.warn("Attempting to fetch SMIL")
        msg.error(url)

        res = utils.subprocess({
            args = {"curl", "-s", url}
        })
        body = res["stdout"]
        smilurl = string.match(body, '<SmilURL name="default">(.*)</SmilURL>')

        if not (smilurl == nil) then
	    msg.warn("Found smilurl, playing")
	    msg.warn(smilurl)
            mp.set_property("stream-open-filename", smilurl)
        end
    end
end)