mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
Add files via upload
This commit is contained in:
BIN
server/web/msx/assets/html5x.html.gz
Normal file
BIN
server/web/msx/assets/html5x.html.gz
Normal file
Binary file not shown.
BIN
server/web/msx/assets/russian.json.gz
Normal file
BIN
server/web/msx/assets/russian.json.gz
Normal file
Binary file not shown.
BIN
server/web/msx/assets/tizen.html.gz
Normal file
BIN
server/web/msx/assets/tizen.html.gz
Normal file
Binary file not shown.
234
server/web/msx/assets/torrents.html
Normal file
234
server/web/msx/assets/torrents.html
Normal file
@@ -0,0 +1,234 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>TorrServer Interaction Plugin</title>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="author" content="damiva" />
|
||||
<script type="text/javascript" src="tvx.js"></script>
|
||||
<script type="text/javascript">
|
||||
/*******************************************/
|
||||
/* TorrServer Interaction Plugin by damiva */
|
||||
/*******************************************/
|
||||
var ADR = window.location.origin, VRS = "", TZN = false;
|
||||
function TAU(n){
|
||||
var x = [
|
||||
["3g2","3gp","aaf","asf","avchd","avi","drc","flv","m2ts","ts","m2v","m4p","m4v","mkv","mng","mov","mp2","mp4","mpe","mpeg","mpg","mpv","mxf","nsv","ogg","ogv","qt","rm","rmvb","roq","svi",".vob","webm","wmv","yuv"],
|
||||
["aac","aiff","ape","au","flac","gsm","it","m3u","m4a","mid","mod","mp3","mpa","pls","ra","s3m","sid","wav","wma","xm"]
|
||||
];
|
||||
var i = n.lastIndexOf(".");
|
||||
if(i >= 0){
|
||||
n = n.substr(i + 1);
|
||||
for(var e = 0; e < x.length; e++) if(x[e].indexOf(n) >= 0) return e;
|
||||
}
|
||||
return -1
|
||||
}
|
||||
function LNG(s){
|
||||
var i = s == 0 ? 0 : Math.floor(Math.log(s) / Math.log(1024));
|
||||
return (s / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
function PRS(t){
|
||||
return "{ico:msx-white:north} " + (t.active_peers || 0) + " ⋅ " + (t.pending_peers || 0) + " / " + (t.total_peers || 0);
|
||||
}
|
||||
function STR(i, c){
|
||||
var v = TVXServices.storage.getBool(i, false);
|
||||
if(c) TVXServices.storage.set(i, v = !v);
|
||||
return v;
|
||||
}
|
||||
function AJX(u, d, o, e){
|
||||
console.log(u);
|
||||
if(typeof d != "object") TVXServices.ajax.get(ADR + u, {success: o, error: e}, {dataType: d ? "json" : "text"});
|
||||
else TVXServices.ajax.post(ADR + u, JSON.stringify(d), {success: o, error: e || TVXInteractionPlugin.error}, {dataType: e ? "json" : "text"});
|
||||
}
|
||||
function OPS(){
|
||||
var k = ["red", "green", "yellow"],
|
||||
r = {caption: "{dic:caption:options|Options}:", template: {enumerate: false, type: "control", layout: "0,0,8,1"}, items: []};
|
||||
r.headline = r.caption;
|
||||
for(var i = 0; i < 3; i++){
|
||||
var a = arguments[i];
|
||||
if(a){
|
||||
a.key = k[i];
|
||||
a.icon = "msx-" + a.key + ":stop";
|
||||
r.items.push(a);
|
||||
r.caption += "{tb}{ico:" + a.icon + "} " + a.label;
|
||||
}
|
||||
}
|
||||
r.items.push(
|
||||
{icon: "msx-blue:menu", label: "{dic:caption:menu|Menu}", action: "[cleanup|menu]"},
|
||||
{icon: "format-size", label: arguments[3] ? "{dic:lfont|Larger font size}" : "{dic:sfont|Smaller font size}", action: "[cleanup|interaction:commit:message:compress|reload:content]"}
|
||||
)
|
||||
if(arguments[4] !== undefined) r.items.push({icon: "translate", label: arguments[4] ? "Switch to English" : "Перевести на русский", action: "[interaction:commit:message:russian|reload]"});
|
||||
return r;
|
||||
}
|
||||
function TDB(d, c, r){return {
|
||||
type: "list", reuse: false, cache: false, restore: false, compress: c, headline: "TorrServer", extension: VRS,
|
||||
template: {
|
||||
imageWidth: 1.3, imageFiller: "height", icon: "msx-glass:bolt", layout: c ? "0,0,8,2" : "0,0,6,2", options: OPS(
|
||||
{label: "{dic:rem|Remove}", action: "[cleanup|interaction:commit:message:rem]", data: "{context:id}"},
|
||||
{label: "{dic:drop|Drop}", action: "[cleanup|interaction:commit:message:drop]", data: "{context:id}"},
|
||||
{label: "{dic:refresh|Refresh}", action: "[cleanup|reload:content]"},
|
||||
c, r
|
||||
)
|
||||
},
|
||||
items: d.map(function(t){return {
|
||||
id: t.hash,
|
||||
headline: t.title,
|
||||
image: t.poster || null,
|
||||
titleFooter: "{ico:msx-white:attach-file} " + LNG(t.torrent_size),
|
||||
stamp: t.stat < 5 ? PRS(t) : null,
|
||||
stampColor: t.stat == 4 ? "msx-red" : t.stat == 3 ? "msx-green" : "msx-yellow",
|
||||
action: "content:request:interaction:" + t.hash + "@" + window.location.href
|
||||
}})
|
||||
}}
|
||||
function TFS(d, c){
|
||||
var fs = [], is = [], sf = TVXServices.storage.getBool("folders", false);
|
||||
d.file_stats.forEach(function(f){
|
||||
var a = TAU(f.path);
|
||||
if(a >= 0){
|
||||
var b = f.path.indexOf("/"),
|
||||
e = f.path.lastIndexOf("/"),
|
||||
p = b < e && e > 0 ? f.path.substr(b + 1, e - b - 1) : ""
|
||||
i = d.hash + "-" + f.id,
|
||||
u = ADR + "/play/" + d.hash + "/" + f.id;
|
||||
if(p && (fs.length == 0 || fs[fs.length - 1].label != p)){
|
||||
fs.push({label: p, action: "[cleanup|focus:" + i + "]"});
|
||||
if(sf) is.push({type: "space", label: "{col:msx-yellow}{ico:folder} " + p});
|
||||
}
|
||||
is.push({
|
||||
id: i,
|
||||
label: f.path.substr(e + 1),
|
||||
extensionLabel: LNG(f.length),
|
||||
folder: p ? ("{ico:msx-yellow:folder} " + p + "{br}") : "",
|
||||
icon: "msx-white-soft:" + (a ? "audiotrack" : "movie"),
|
||||
group: a ? "{dic:label:audio|Audio}" : "{dic:label:video|Video}",
|
||||
action: (a ? "audio:" : "video:") + (a || TZN ? u : ("plugin:" + window.location.origin + "/msx/html5x?url=" + encodeURIComponent(u)))
|
||||
});
|
||||
}
|
||||
});
|
||||
return {
|
||||
type: "list", compress: c, items: is,
|
||||
extension: "{ico:msx-white:attach-file} " + LNG(d.torrent_size), headline: d.title,
|
||||
options: OPS(
|
||||
{label: "{dic:continue|Continue}", action: "[cleanup|interaction:commit:message:continue]", data: d.hash},
|
||||
fs.length > 1 ? {label: "{dic:folder|Select folder}", action: "panel:data", data: {
|
||||
type: "list", compress: true, headline: "{dic:folder|Go to folder}:", items: fs,
|
||||
template: {type: "control", icon: "msx-yellow:folder", layout: "0,0,10,1"},
|
||||
}} : null,
|
||||
fs.length > 0 ? {label: STR("folders") ? "{dic:hfolders|Hide folders}" : "{dic:sfolders|Show folders}", action: "[cleanup|interaction:commit:message:folders|reload:content]"} : null,
|
||||
c
|
||||
),
|
||||
template: {type: "control", layout: c ? "0,0,16,1" : "0,0,12,1", progress: -1, playerLabel: d.title,
|
||||
live: {type: "playback", action: "player:show"}, properties: {
|
||||
"info:text": "{context:folder}{ico:msx-green:play-arrow} {context:label}",
|
||||
"info:image": d.poster || "default",
|
||||
"control:type": "extended",
|
||||
"resume:key": "id",
|
||||
"trigger:complete": "[player:auto:next|resume:cancel]",
|
||||
"trigger:player": "interaction:commit:message:" + d.hash
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function PLG(){
|
||||
var W = new TVXBusyService(), S = "";
|
||||
this.ready = function(){
|
||||
ADR = TVXServices.urlParams.getFullStr("addr", ADR);
|
||||
if(TVXServices.urlParams.has("link")){
|
||||
TVXServices.urlParams.remove("addr");
|
||||
S = TVXServices.urlParams.build(true, "&");
|
||||
}
|
||||
W.start();
|
||||
TVXInteractionPlugin.onValidatedSettings(function(){
|
||||
console.log(TVXSettings);
|
||||
TZN = TVXSettings.PLATFORM == "tizen";
|
||||
AJX("/echo", false, function(v){VRS = v; W.stop()}, function(){W.stop()});
|
||||
});
|
||||
};
|
||||
this.handleEvent = function(d){
|
||||
if(d.event == "video:load"){
|
||||
switch(d.info.type){
|
||||
case "video":
|
||||
TVXInteractionPlugin.executeAction("player:button:content:setup", {
|
||||
icon: "build",
|
||||
action: TZN ? ("content:request:interaction:init@" + window.location.origin + "/msx/tizen") : "panel:request:player:options"
|
||||
});
|
||||
break;
|
||||
case "audio":
|
||||
TVXInteractionPlugin.executeAction("interaction:commit:message:background", true);
|
||||
}
|
||||
TVXInteractionPlugin.executeAction("interaction:commit:message:" + d.info.id.split("-")[0]);
|
||||
}
|
||||
};
|
||||
this.handleRequest = function(i, _, f){W.onReady(function(){
|
||||
var e = function(m){TVXInteractionPlugin.error(m); f();},
|
||||
c = STR("compress"),
|
||||
r = STR("russian");
|
||||
switch(i){
|
||||
case "init":
|
||||
f({
|
||||
name: "TorrServer Plugin",
|
||||
version: "0.0.1",
|
||||
reference: "request:interaction:db@" + window.location.href,
|
||||
dictionary: r ? (window.location.origin + "/msx/russian.json") : null
|
||||
});
|
||||
break;
|
||||
case "sdb": r = undefined;
|
||||
case "db":
|
||||
AJX("/torrents", {action: "list"}, function(d){f(TDB(d, c, r))}, e);
|
||||
break;
|
||||
default:
|
||||
AJX("/stream/?stat&" + (S || ("link=" + i)), true, function(d){f(TFS(d, c, S && S.indexOf("&save_to_db") < 0))}, e);
|
||||
}
|
||||
})};
|
||||
this.handleData = function(d){
|
||||
var r = function(){TVXInteractionPlugin.executeAction("reload:content")}
|
||||
switch(d.message){
|
||||
case "rem":
|
||||
case "drop":
|
||||
AJX("/torrents", {action: d.message, hash: d.data}, r);
|
||||
break;
|
||||
case "compress":
|
||||
case "folders":
|
||||
case "russian":
|
||||
STR(d.message, true);
|
||||
break;
|
||||
case "background":
|
||||
var b = STR(d.message, !d.data);
|
||||
TVXInteractionPlugin.executeAction("player:button:content:setup", {
|
||||
icon: (b ? "hide-" : "") + "image",
|
||||
action: "interaction:commit:message:" + d.message
|
||||
});
|
||||
TVXInteractionPlugin.executeAction("player:background:" + (b
|
||||
? ("https://source.unsplash.com/random/" + TVXSettings.WIDTH + "x" + TVXSettings.HEIGHT + "/?ts=" + TVXDateTools.getTimestamp())
|
||||
: "none"
|
||||
));
|
||||
break;
|
||||
case "continue":
|
||||
AJX(
|
||||
"/viewed",
|
||||
{action: "list", hash: d.data},
|
||||
function(v){
|
||||
var l = 1;
|
||||
v.forEach(function(i){if(i.file_index > l) l = i.file_index});
|
||||
TVXInteractionPlugin.executeAction("focus:" + d.data + "-" + l);
|
||||
},
|
||||
function(){TVXInteractionPlugin.executeAction("focus:" + d.data + "-" + l)}
|
||||
);
|
||||
break;
|
||||
default:
|
||||
if(d.message) AJX("/cache", {action: "get", hash: d.message}, function(v){
|
||||
TVXInteractionPlugin.executeAction("player:label:position:{VALUE}{tb}{tb}" + PRS(v.Torrent));
|
||||
}, function(){});
|
||||
}
|
||||
};
|
||||
}
|
||||
TVXPluginTools.onReady(function() {
|
||||
TVXInteractionPlugin.setupHandler(new PLG());
|
||||
TVXInteractionPlugin.init();
|
||||
});
|
||||
/*******************************************/
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
BIN
server/web/msx/assets/torrents.min.html.gz
Normal file
BIN
server/web/msx/assets/torrents.min.html.gz
Normal file
Binary file not shown.
BIN
server/web/msx/assets/tvx.js.gz
Normal file
BIN
server/web/msx/assets/tvx.js.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user