summaryrefslogtreecommitdiff
path: root/.local/share/libquvi-scripts/lua/website/ulmentv.lua
blob: 43dfdb6785dce8690b45ea9c3c9f0a0372824273 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- Identify the script.
function ident(self)
    package.path = self.script_dir .. '/?.lua'
    local C      = require 'quvi/const'
    local r      = {}
    r.domain     = "ulmen%.tv"
    r.formats    = "default"
    r.categories = C.proto_rtmp
    local U      = require 'quvi/util'
    r.handles    = U.handles(self.page_url, {r.domain}, {"/.+/%d+/.+$"})
    return r
end

-- Query available formats.
function query_formats(self)
    self.formats = "default"

    return self
end

-- Parse media URL.
function parse(self)
    self.host_id  = "ulmentv"

    local c = quvi.fetch(self.page_url, {fetch_type='config'})
    if c:match('<error>') then
        local s = c:match('<message>(.-)[\n<]')
        error( (not s) and "no match: error message" or s )
    end

    self.title = c:match('<meta content="([^"]*)" property="og:title"')
        or error("no match: media title")

    self.thumbnail_url = c:match('<meta content="([^"]*)" property="og:image"')
        or error("no match: thumbnail")

    self.id = c:match('<a href="#" data%-url="([^"]*)"')
        or error("no match: request data url")

    -- alternative: http://178.23.127.5:1935/vod/%id/playlist.m3u8
    self.url = { "rtmp://178.23.127.5:1935/vod/" .. string.gsub(self.id, " ", "%%20") }

    return self
end

-- vim: set ts=4 sw=4 tw=72 expandtab: