mirror of
https://github.com/SEPPDROID/JellyCAT.git
synced 2025-10-22 16:04:20 +00:00
added more config options + reverse proxy for secure jellyfin servers (tryout) && connecting to JF server :)
This commit is contained in:
@@ -23,7 +23,7 @@ function setServerAddress() {
|
||||
showTextEntryPage(
|
||||
"emailAddress",
|
||||
"Set Jellyfin Server Address",
|
||||
"Enter the address of the Jellyfin server:",
|
||||
"Enter the address of the Jellyfin server: \n\nExample: \nhttps://demo.jellyfin.org/stable \nhttp://192.168.11.11:8096",
|
||||
function(value) {
|
||||
// Save server address to localStorage
|
||||
atv.localStorage['jellyfin_server_address'] = value;
|
||||
@@ -32,7 +32,7 @@ function setServerAddress() {
|
||||
function() {
|
||||
fetchDataAndRender();
|
||||
},
|
||||
atv.localStorage['jellyfin_server_address'] || ""
|
||||
atv.localStorage['jellyfin_server_address'] || "http://"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ function setServerAddress() {
|
||||
function setUsername() {
|
||||
showTextEntryPage(
|
||||
"emailAddress",
|
||||
"Set Username",
|
||||
"Enter your username:",
|
||||
"Set Jellyfin Username",
|
||||
"Enter your Jellyfin username:",
|
||||
function(value) {
|
||||
// Save username to localStorage
|
||||
atv.localStorage['jellyfin_username'] = value;
|
||||
@@ -58,8 +58,8 @@ function setUsername() {
|
||||
function setPassword() {
|
||||
showTextEntryPage(
|
||||
"password",
|
||||
"Set Password",
|
||||
"Enter your password:",
|
||||
"Set Jellyfin Password",
|
||||
"Enter your Jellyfin password:",
|
||||
function(value) {
|
||||
// Save password to localStorage
|
||||
atv.localStorage['jellyfin_password'] = value;
|
||||
@@ -74,7 +74,6 @@ function setPassword() {
|
||||
}
|
||||
|
||||
// Let's try finding and changing the values
|
||||
|
||||
function fetchDataAndRender() {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
@@ -90,3 +89,108 @@ function fetchDataAndRender() {
|
||||
xhttp.open("GET", 'https://' + atv.jcathost.SigHost + '/xml/server-settings.xml', true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
function getJellyfinInfo() {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
var serverAddress = atv.localStorage['jellyfin_server_address'];
|
||||
|
||||
if (!serverAddress) {
|
||||
showServerErrorScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!serverAddress || !/(http|https):\/\//.test(serverAddress)) {
|
||||
showServerErrorScreen();
|
||||
return;
|
||||
}
|
||||
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (this.readyState == 4) {
|
||||
if (this.status == 200) {
|
||||
var response = JSON.parse(this.responseText);
|
||||
if (response && response.ProductName === "Jellyfin Server") {
|
||||
displayJellyfinInfo(response);
|
||||
} else {
|
||||
showServerErrorScreen();
|
||||
}
|
||||
} else {
|
||||
showServerErrorScreen();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhttp.open("GET", serverAddress + "/system/info/public", true);
|
||||
xhttp.send();
|
||||
}
|
||||
|
||||
function displayJellyfinInfo(info) {
|
||||
var serverName = info.ServerName;
|
||||
var version = info.Version;
|
||||
var productName = info.ProductName;
|
||||
var operatingSystem = info.OperatingSystem;
|
||||
var id = info.Id;
|
||||
var serverAddress = atv.localStorage['jellyfin_server_address'];
|
||||
|
||||
var xmlstr = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<atv>' +
|
||||
'<head>' +
|
||||
'<script src="http://jcathost.dns/js/jcm.js"/>' +
|
||||
'<script src="http://jcathost.dns/js/jellyfin-setup.js"/>' +
|
||||
'</head>' +
|
||||
' <body>' +
|
||||
' <optionDialog id="com.jellycat.server-response-dialog">' +
|
||||
' <header>' +
|
||||
' <simpleHeader accessibilityLabel="Dialog with Options">' +
|
||||
' <title>Jellyfin Server Response:</title>' +
|
||||
' </simpleHeader>' +
|
||||
' </header>' +
|
||||
' <description>JellyCAT has successfully established a connection with the Jellyfin Server and received the following response:\n\n' + productName + ' (' + serverAddress + ')' +
|
||||
'\n\nServer Name: ' + serverName + '\nVersion: ' + version +'\nOS: ' + operatingSystem + '\nid: ' + id +'\n\nTo begin viewing content, simply click on "Login" to log in to this server and receive your authentication key!</description>' +
|
||||
' <menu>' +
|
||||
' <initialSelection>' +
|
||||
' <row>0</row>' +
|
||||
' </initialSelection>' +
|
||||
' <sections>' +
|
||||
' <menuSection>' +
|
||||
' <items>' +
|
||||
' <oneLineMenuItem id="list_0" accessibilityLabel="Option 1" onSelect="authenticateJellyfin()">' +
|
||||
' <label>Login (authenticate)</label>' +
|
||||
' </oneLineMenuItem>' +
|
||||
' <oneLineMenuItem id="list_1" accessibilityLabel="Option 2" onSelect="atv.unloadPage();">' +
|
||||
' <label>Go back</label>' +
|
||||
' </oneLineMenuItem>' +
|
||||
' </items>' +
|
||||
' </menuSection>' +
|
||||
' </sections>' +
|
||||
' </menu>' +
|
||||
' </optionDialog>' +
|
||||
' </body>' +
|
||||
'</atv>';
|
||||
xmlDoc = atv.parseXML(xmlstr);
|
||||
atv.loadXML(xmlDoc);
|
||||
|
||||
console.log("Valid Jellyfin server: " + serverName + " " + version)
|
||||
}
|
||||
|
||||
function showServerErrorScreen(){
|
||||
var xmlstr = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||
'<atv>' +
|
||||
' <body>' +
|
||||
' <dialog id="com.jellycat.jellyfin-connect-error-dialog">' +
|
||||
' <title>Error contacting Jellyfin Server:</title>' +
|
||||
' <description>\nJellyCAT was unable to establish a connection with the Jellyfin Server you provided,' +
|
||||
' or we received an invalid response. Please verify that all information is correct and try again.\n' +
|
||||
'Note that the majority of security certificates are not supported, requiring manual addition to the ATV Profile if you intend to utilize HTTPS.\n\n\n' +
|
||||
'Please let us know if you believe this is an error\n\nPress MENU to go back</description>' +
|
||||
' </dialog>' +
|
||||
' </body>' +
|
||||
'</atv>';
|
||||
xmlDoc = atv.parseXML(xmlstr);
|
||||
atv.loadXML(xmlDoc);
|
||||
|
||||
console.log("Jellyfin Server Connection Issue")
|
||||
}
|
||||
|
||||
function authenticateJellyfin(){
|
||||
console.log("yapppa!")
|
||||
}
|
Reference in New Issue
Block a user