-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- tivix works with ffmpeg HLS to MPEGTS conversion - torlook in two languages (Russian & English)
- Loading branch information
Showing
15 changed files
with
445 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
url := "http://tv.tivix.co/" | ||
srv := import("server") | ||
txt := import("text") | ||
jsn := import("json") | ||
stg := import("settings") | ||
cat := stg.cat | ||
fav := cat == "*" | ||
cat = cat == "*" ? "" : cat | ||
vid := "video:resolve:" + srv.base_url + "video.tengo?str=" + string(stg.str) + "&cid=" | ||
|
||
// get the page: | ||
r := srv.request(url + cat) | ||
panic(is_error(r) ? r : r.status != 200 ? r.status : undefined) | ||
|
||
// parse categories: | ||
c := [{label: "Избранные", action: "execute:fetch:" + srv.base_url + "set.tengo?id={ID}&cat=*", enable: !fav}] | ||
for m in txt.re_find("(?s)class=\"menuuuuuu\">(.+?)</div>", r.body, 3) { | ||
for i in txt.re_find("(?s).+?href=\"/(.*?)\"(.+?)>(.+?)<", m[1].text, -1) { | ||
cc := {label: i[3].text, action: "execute:fetch:" + srv.base_url + "set.tengo?id={ID}&cat="+ i[1].text} | ||
if !fav && len(i[2].text) > 3 { | ||
cc.enable = false | ||
cat = (i[1].text == "" ? "" : "{col:msx-white}") + i[3].text | ||
} | ||
c = append(c, cc) | ||
} | ||
} | ||
|
||
// parse channels: | ||
if fav { | ||
cat = "{col:msx-yellow}Избранные" | ||
if r = srv.file("favs.json"); r { | ||
panic(is_error(r) ? r : undefined) | ||
r = jsn.decode(r) | ||
panic(is_error(r) ? r : !is_array(r) ? "Wrong format of file favs.json" : undefined) | ||
for i := 0; i < len(r); i++ { | ||
r[i].playerLabel = r[i].headline | ||
r[i].action = vid + r[i].id | ||
} | ||
} else { r = [] } | ||
} else if r = txt.re_find("(?s)class=\"all_tv\".+?<a.+?href=\".+?//.+?/(.+?).html\".+?title=\"(.+?)\".+?src=\"/(.+?)\"", r.body, -1); r { | ||
for i := 0; i < len(r); i++ { | ||
r[i] = {id: r[i][1].text, headline: r[i][2].text, playerLabel: r[i][2].text, image: url + r[i][3].text, action: vid + r[i][1].text} | ||
} | ||
} else { r = [] } | ||
|
||
// msx answer: | ||
props := srv.settings.player(true, true) | ||
props["trigger:load"] = "execute:service:fetch:" + srv.base_url + "programme.tengo?cid={context:id}" | ||
props["progress:type"] = "time:hh:mm" | ||
props["label:extension"] = " {ico:msx-white:access-time} {now:time:hh:mm}" | ||
props["control:reuse"] = "restart" | ||
props["tizen:display:mode"] = "PLAYER_DISPLAY_MODE_FULL_SCREEN" | ||
opt := fav ? "Убрать из избранных" : "Добавить в избранные" | ||
r = jsn.encode({ | ||
type: "list", headline: "Tivix", background: "http://tv.tivix.co/templates/Default/dleimages/bgggg.jpg", | ||
compress: true, items: r, | ||
extension: "{ico:filter-list} " + cat + "{tb}{ico:msx-white-soft:access-time} {txt:msx-white:now:time:hh:mm}", | ||
header: {items: [ | ||
{ | ||
type: "control", icon: "filter-list", label: "Категория:", extensionLabel: cat, layout: "2,0,6,1", action: "panel:data", | ||
data: {type: "list", items: c, headline: "Категории", template: {type: "button", layout: "0,0,4,1"}} | ||
},{ | ||
type: "control", icon: "stream", label: "Видео:", extensionLabel: stg.hls[stg.str], layout: "8,0,6,1", | ||
action: "panel:" + srv.base_url + "set.tengo?id={ID}" | ||
} | ||
]}, | ||
template: { | ||
layout: "0,0,8,2", truncation: "titleHeader|titleFooter", | ||
imageWidth: 1, imageFiller: "smart", | ||
progress: -1, progressColor: "msx-white", titleHeader: "", titleFooter: "", | ||
live: {type: "setup", action: "execute:service:fetch:" + srv.base_url + "programme.tengo?cid={context:id}&now=true"}, | ||
properties: props, options: { | ||
headline: "{dic:caption:options|options}:", | ||
caption: "{dic:caption:options|options}:{tb}{ico:msx-green:stop} " + opt + "{tb}{ico:msx-yellow:stop} {dic:Up|Up}", | ||
template: {type: "control", layout: "0,0,8,1"}, | ||
items:[ | ||
{key: "green", icon: "msx-green:stop", label: opt, action: "execute:fetch:" + srv.base_url + "set.tengo?cid={context:id}" + (fav ? "" : "&ttl={context:headline}&img={context:image}")}, | ||
{key: "yellow", icon: "msx-yellow:stop", label: "{dic:Up|Up}", action: "[cleanup|focus:index:0]"}, | ||
{type: "space"}, {icon: "menu", label: "{dic:caption:menu|Menu}", action: "menu"} | ||
] | ||
}} | ||
}) | ||
panic(is_error(r) ? "Encoding playlist error: " + string(r) : undefined) | ||
srv.write(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Label":"Tivix", | ||
"Icon": "live-tv", | ||
"URL": "{BASE_URL}?id={ID}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
srv := import("server") | ||
jsn := import("json") | ||
tms := import("times") | ||
txt := import("text") | ||
now := tms.now() | ||
cid := srv.read("cid") | ||
epg := [] | ||
nrs := {now: [now, "..."], nxt: [tms.add(now, tms.hour), "..."], cur: -1} | ||
// get and prepare programme: | ||
if cid != "" { | ||
if epg = srv.request("https://s.programma.space/channels/tivix/program/" + txt.split_n(cid, "-", 2)[0] + "/today/"); is_error(epg) { | ||
srv.log_err(epg) | ||
} else if epg.status != 200 { | ||
//srv.log_err("Programma returned:", epg.status) | ||
} else if epg = jsn.decode(epg.body); is_error(epg) { | ||
srv.log_err(epg) | ||
} else if is_array(epg) { | ||
a := false | ||
for i := 0; i < len(epg); i++ { | ||
epg[i].start_at = tms.to_local(tms.parse(tms.format_rfc3339, txt.replace(epg[i].start_at, " ", "T", 1) + "+00:00")) | ||
if !a { | ||
if a = tms.after(epg[i].start_at, now); a { | ||
nrs.nxt = [epg[i].start_at, epg[i].name] | ||
if i > 0 { | ||
epg[i-1] = "{col:msx-yellow}" + epg[i-1] + "{col:msx-white}" | ||
nrs.cur = i - 1 | ||
} | ||
} else { | ||
nrs.now = [epg[i].start_at, epg[i].name] | ||
} | ||
} | ||
epg[i] = tms.time_format(epg[i].start_at, "15:04") + "{tb}" + epg[i].name | ||
} | ||
} | ||
} | ||
// prepare the answer: | ||
if fn := srv.read("now"); !is_array(epg) || len(epg) < 1 { | ||
epg = fn ? {titleHeader: "Программа недоступна!"} : undefined | ||
cid = fn ? ("update:content:" + cid) : "player:label:duration:{ico:sensors}" | ||
} else if fn { | ||
epg = {live: { | ||
type: "schedule", from: tms.time_unix(nrs.now[0]) * 1000, to: tms.time_unix(nrs.nxt[0]) * 1000, | ||
titleHeader: "{ico:add}{col:msx-white}{progress:time:hh:mm} " + nrs.now[1], | ||
titleFooter: "{ico:remove}{countdown:time:hh:mm} " + nrs.nxt[1], | ||
over: {action: "execute:service:fetch:" + srv.base_url + "programme.tengo?now=true&cid=" + cid} | ||
}} | ||
cid = "update:content:" + cid | ||
} else { | ||
if nrs.cur < 0 { | ||
epg = append(["{col:msx-yellow}...{col:msx-white}"], epg...) | ||
} else if l := len(epg) - 10; l > 0 && nrs.cur > 0 { | ||
epg = epg[nrs.cur < l ? nrs.cur : l:] | ||
} | ||
tuf := tms.time_unix(nrs.now[0]) | ||
tut := tms.time_unix(nrs.nxt[0]) | ||
epg = {actions: [ | ||
{action: "trigger:player:execute:service:fetch:" + srv.base_url + "progress.tengo?b=" + tuf + "&e=" + tut + "&cid=" + cid}, | ||
{action: "player:info:text:" + txt.join(epg, "{br}")}, | ||
{action: "player:label:position:{VALUE}{tb}{col:msx-white}" + nrs.now[1]}, | ||
{action: "player:label:duration:{VALUE}"}, | ||
{action: "player:video:position:" + string(tms.time_unix(now) - tuf)}, | ||
{action: "player:video:duration:" + string(tut - tuf)} | ||
]} | ||
cid = "data" | ||
} | ||
// answer: | ||
srv.write(jsn.encode({response: {status: 200, data: {action: cid, data: epg}}})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
s := import("server") | ||
t := import("times") | ||
b := s.read("b") | ||
e := s.read("e") | ||
panic(b == "" || e == "" ? 400 : undefined) | ||
b = int(b) | ||
e = int(e) | ||
n := t.time_unix(t.now()) | ||
a := "player:video:position:" + string(n - b) | ||
if n > e { | ||
a = "execute:service:fetch:" + s.base_url + "programme.tengo?cid=" + s.read("cid") | ||
} | ||
s.write("{\"response\":{\"status\":200,\"data\":{\"action\":\"" + a + "\"}}}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
srv := import("server") | ||
jsn := import("json") | ||
stg := import("settings") | ||
rtn := {response: {status: 200, data: {action: "reload:content"}}} | ||
if r := srv.read("str"); r { | ||
stg.set(int(r, 0)) | ||
rtn.response.data.action = "[back|reload:content]" | ||
} else if r = srv.read("cat"); is_string(r) { | ||
stg.set(r) | ||
rtn.response.data.action = "[back|reload:content]" | ||
} else if c := srv.read("cid"); c { | ||
ch := false | ||
if r = srv.file(stg.fav); r { | ||
panic(is_error(r) ? r : undefined) | ||
r = jsn.decode(r) | ||
} | ||
r = is_array(r) ? r : [] | ||
l := len(r) | ||
for i := 0; i < l; i++ { | ||
if r[i].id == c { | ||
splice(r, i, 1) | ||
i = l | ||
ch = true | ||
} | ||
} | ||
if t := srv.read("ttl"); t { | ||
r = append(r, {id: c, headline: t, image: srv.read("img")}) | ||
ch = true | ||
rtn.response.data.action = "success:" + t + " добавлен в {col:msx-yellow}избранные" | ||
} | ||
if ch { | ||
r = jsn.encode(r) | ||
panic(is_error(r) ? r : undefined) | ||
srv.file(stg.fav, r) | ||
} | ||
} else { | ||
rtn = {type: "list", headline: "Видео:", extension: "Tivix", template: {enumerate: false, type: "button", layout: "0,0,8,1"}, items: []} | ||
for i, n in stg.hls { | ||
rtn.items = append(rtn.items, {label: n, action: "execute:fetch:" + srv.base_url + "set.tengo?id={ID}&str=" + string(i)}) | ||
} | ||
} | ||
srv.write(jsn.encode(rtn)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
s := import("server") | ||
i := s.read("id") || "*" | ||
p := s.memory() || {} | ||
if !is_map(p[i]) { p[i] = {cat: "", str: 0} } | ||
h := ["прямой HLS", "проксировать HLS"] | ||
if s.settings.ffmpeg() { h = append(h, "конвертировать в MPEGTS") } | ||
export { | ||
fav: "favs.json", | ||
cat: p[i].cat, | ||
str: p[i].str, | ||
hls: h, | ||
set: func(arg) { | ||
r := false | ||
if r = is_string(arg); r { | ||
p[i].cat = arg | ||
} else if r = is_int(arg); r { | ||
p[i].str = arg > 0 && arg < len(h) ? arg : 0 | ||
} | ||
if r { s.memory(p) } | ||
return r | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
srv := import("server") | ||
txt := import("text") | ||
cid := srv.read("cid") | ||
panic(cid ? undefined : 400) | ||
url := "http://tv.tivix.co/" | ||
|
||
b := srv.request(url + cid + ".html") | ||
panic(is_error(b) ? b : b.status != 200 ? b.status : undefined) | ||
|
||
b = txt.re_find("(?s)firstIpProtect.+?'(.+?)'.+?secondIpProtect.+?'(.+?)'.+?portProtect.+?'(.+?)'.+?new Playerjs.+?file.*?:.*?\"(.+?)\"", b.body, 1)[0][1:] | ||
|
||
b[3] = txt.trim_prefix(b[3].text, "#2") | ||
for i := txt.last_index(b[3], "//"); i > -1; i = txt.last_index(b[3], "//"){ | ||
b [3]= b[3][:i] + b[3][i+50:] | ||
} | ||
b[3] = import("base64").decode(b[3]) | ||
|
||
b = txt.replace(txt.replace(txt.replace(b[3], "{v3}", b[2].text, 1), "{v2}", b[1].text, 1), "{v1}", b[0].text, 1) | ||
|
||
if s := int(srv.read("str"), 0); s == 2 { | ||
b = srv.settings.ffmpeg(b, ["-referer", url], ["-c", "copy"]) | ||
panic(b == "" ? "ffmpeg is not set" : undefined) | ||
} else if s == 1 { | ||
b = "http://" + srv.host + "/proxy.m3u8?header=Referer%3A" + srv.encode_uri(url) + "&link=" + srv.encode_uri(b) | ||
} else { | ||
r := srv.request(b, {header: {Referer: url}}) | ||
panic(is_error(r) ? r : r.status == 200 ? undefined : r.status) | ||
} | ||
srv.write("{\"response\":{\"status\":200,\"data\":{\"url\":\"", srv.settings.player(b), "\"}}}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
srv := import("server") | ||
txt := import("text") | ||
jsn := import("json") | ||
url := "https://torlook.info/" | ||
stg := srv.memory() | ||
stg = is_array(stg) && len(stg) == 4 ? stg : ["seeders", false, false, false] | ||
its := [] | ||
panic(srv.method != "POST" ? 400 : undefined) | ||
fnd := jsn.decode(srv.read()) | ||
panic(is_error(fnd) ? fnd : !is_map(fnd) || !is_string(fnd.data) ? 400 : undefined) | ||
fnd = fnd.data | ||
r := srv.request( | ||
url + "?cinema=on&s=" + srv.encode_uri(fnd) + "&sort=" + stg[0] + (stg[1] ? "&forced=on" : ""), | ||
{header: {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"}} | ||
) | ||
panic(is_error(r) ? r : r.status != 200 ? r.status : undefined) | ||
if r = txt.re_find("(?s)webResult.+?item.+?<a.+?>(.+?)</a>.+?<img.+?src=\"/(.+?)\".+?<a.+?>(.+?)<.+?class=\"size\">(.+?)<.+?class=\"date\">(.+?)<.+?class=\"arrow-up\".+?>(.+?)<.+?data-src=\"(.+?)\"", r.body, -1); is_array(r) { | ||
for i in r { its = append(its, { | ||
headline: txt.re_replace("<.+?>", i[1].text, ""), | ||
titleFooter: i[3].text + "{tb}{ico:msx-white:attach-file}" + txt.replace(i[4].text, " ", " ", 1) + | ||
"{tb}{ico:msx-white:calendar-today} " + i[5].text + "{tb}{ico:msx-white:arrow-upward} " + i[6].text, | ||
data: url + srv.encode_uri(i[7].text, true) | ||
})} | ||
} else { | ||
its = append(its, {label: "{dic:message:playlist_empty|Empty}", icon: "msx-yellow:warning", extensionIcon: "msx-white:refresh", action: "reload:content"}) | ||
} | ||
|
||
srv.write(jsn.encode({response: {status: 200, data: {action: "content:data", data:{ | ||
type: "list", headline: "Torlook", extension: "{ico:search}{col:msx-white}" + fnd, cache: false, compress: true, items: its, flag: "FIND", | ||
template: {type: "control", layout: "0,0," + (stg[2] ? "8" : "16") + ",2", action: "execute:" + srv.base_url + "magnet.tengo?"}, | ||
header: {items:[ | ||
{type: "control", icon: "arrow-back-ios", label: "TOP-50", action: "close:FIND", layout: "0,0,3,1"}, | ||
{ | ||
type: "control", icon: "search", extensionIcon: "keyboard", layout: "3,0,10,1", | ||
id: "search", label: fnd, action: "execute:http://" + srv.host + "/msx/input", | ||
data: {action: "[cleanup|close:FIND|execute:" + srv.base_url + "find.tengo]", headline: "Torlook:", value: fnd} | ||
},{ | ||
type: "button", icon: "tune", iconSize: "small", layout: "13,0,3,1", | ||
action: "execute:info:dictionary:" + srv.base_url + "set.tengo?find=" + srv.encode_uri(fnd), data: undefined | ||
} | ||
]} | ||
}}}})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
srv := import("server") | ||
jsn := import("json") | ||
|
||
panic(srv.method != "POST" ? 400 : undefined) | ||
u := srv.read() | ||
u = jsn.decode(u) | ||
panic(is_error(u) ? u : undefined) | ||
u = u.data || "" | ||
panic(u == "" ? 400 : undefined) | ||
|
||
u = srv.request(u, {header: {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"}}) | ||
panic(is_error(u) ? u : u.status == 200 ? undefined : u.status) | ||
u = import("text").re_find("(?s)\"<a.+?href='(.+?)'", u.body, 1)[0][1].text | ||
|
||
srv.write("{\"response\":{\"status\":200,\"data\":{\"action\":\"content:http://" + srv.host + "/msx/torr?id={ID}&link=" + srv.encode_uri(u) + "\"}}}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
srv := import("server") | ||
txt := import("text") | ||
org := srv.memory() | ||
org = is_array(org) && len(org) == 4 ? org[3] : false | ||
its := [] | ||
act := "content:" + srv.base_url + "find.tengo?find=" | ||
|
||
r := srv.request("https://torlook.info/movietop", {header: {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36"}}) | ||
panic(is_error(r) ? r : r.status != 200 ? r.status : undefined) | ||
|
||
if r = txt.re_find("(?s)webResult.+?item.+?<p>(.+?)</p>.+?torstat.+?<span.+?>(.+?)<", r.body, -1); is_array(r) { | ||
for i in r { | ||
b := i[2].text | ||
i = txt.re_find("href=\"/(.+?)\">(.+?)<", i[1].text, 2) | ||
i = i[len(i) > 1 && org ? 1 : 0] | ||
its = append(its, {label: i[2].text, extensionLabel: b, data: srv.decode_uri(i[1].text)}) | ||
} | ||
} else { | ||
its = append(its, {label: "{dic:message:playlist_empty|Empty}", icon: "msx-yellow:warning", extensionIcon: "msx-white:refresh", action: "reload:content"}) | ||
} | ||
|
||
srv.write(import("json").encode({ | ||
type: "list", headline: "Torlook", extension: "TOP-50 (kinopoisk)", cache: false, compress: true, items: its, | ||
ready: {action: "execute:info:dictionary:" + srv.base_url + "trans.tengo"}, | ||
template: {type: "control", icon: "search", layout: "0,0,16,1", action: "execute:" + srv.base_url + "find.tengo"}, | ||
header: {items:[ | ||
{ | ||
type: "control", icon: "title", layout: "0,0,3,1", action: "execute:" + srv.base_url + "set.tengo", data: 3, | ||
label: org ? "{txt:msx-white-soft:Рус} {ico:toggle-on} Origin" : "Рус {ico:toggle-off} {txt:msx-white-soft:Origin}" | ||
},{ | ||
type: "control", icon: "search", extensionIcon: "keyboard", layout: "3,0,10,1", | ||
id: "search", label: "Torrents search", action: "execute:http://" + srv.host + "/msx/input", | ||
data: {action: "[cleanup|execute:" + srv.base_url + "find.tengo]", headline: "Torlook:"} | ||
},{ | ||
type: "button", icon: "tune", iconSize: "small", layout: "13,0,3,1", | ||
action: "execute:info:dictionary:" + srv.base_url + "set.tengo", data: undefined | ||
} | ||
]} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"Label": "Torlook", | ||
"Image": "{BASE_URL}tor.svg", | ||
"Torrent": true | ||
} |
Oops, something went wrong.