diff --git a/app/js/jellyfin-setup.js b/app/js/jellyfin-setup.js
index 0095ad1..3d72694 100644
--- a/app/js/jellyfin-setup.js
+++ b/app/js/jellyfin-setup.js
@@ -192,5 +192,121 @@ function showServerErrorScreen(){
}
function authenticateJellyfin(){
- console.log("yapppa!")
+ var serverAddress = atv.localStorage['jellyfin_server_address'];
+ var username = atv.localStorage['jellyfin_username'];
+ var password = atv.localStorage['jellyfin_password'];
+
+ var xhttp = new XMLHttpRequest();
+ var url = serverAddress + '/Users/AuthenticateByName';
+
+ xhttp.onreadystatechange = function() {
+ if (this.readyState === 4) {
+ if (this.status === 200) {
+ var responseJson = JSON.parse(this.responseText);
+ // console.log("Authentication successful. Response:", responseJson);
+ // Extracting ServerId and AccessToken
+ var serverId = responseJson.ServerId;
+ var accessToken = responseJson.AccessToken;
+ // Storing ServerId and AccessToken in atv storage
+ atv.localStorage['jellyfin_serverid'] = serverId;
+ atv.localStorage['jellyfin_authtoken'] = accessToken;
+ atv.localStorage['jellyfin_loggedin'] = '1';
+ showAuthSuccessScreen();
+ } else {
+ console.error("Error occurred during authentication. Status:", this.status);
+ console.error("Response:", this.responseText);
+ showAuthErrorScreen();
+ }
+ }
+ };
+
+ xhttp.onerror = function() {
+ console.error("An error occurred during the request.");
+ showAuthErrorScreen();
+ };
+
+ xhttp.open("POST", url, true);
+ xhttp.setRequestHeader("Content-Type", "application/json");
+
+ // Constructing the Authorization header
+ var token = "";
+ var client = "JellyCAT Apple TV";
+ var version = atv.jcathost.Version;
+ var deviceId = atv.device.udid;
+ var device = atv.device.displayName;
+
+ var authHeaderValue = 'MediaBrowser Token="' + encodeURIComponent(token) + '", ' +
+ 'Client="' + encodeURIComponent(client) + '", ' +
+ 'Version="' + encodeURIComponent(version) + '", ' +
+ 'DeviceId="' + encodeURIComponent(deviceId) + '", ' +
+ 'Device="' + encodeURIComponent(device) + '"';
+
+ xhttp.setRequestHeader("Authorization", authHeaderValue);
+
+ var requestBody = JSON.stringify({
+ "Username": username,
+ "Pw": password
+ });
+
+ xhttp.send(requestBody);
+}
+
+function showAuthErrorScreen(){
+ var xmlstr = '' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ xmlDoc = atv.parseXML(xmlstr);
+ atv.loadXML(xmlDoc);
+}
+
+function showAuthSuccessScreen(){
+ var xmlstr =
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ '' +
+ 'Success:' +
+ '' +
+ '' +
+ 'Yay! You\'ve logged in successfully. Feel free to exit settings and dive in!' +
+ '' +
+ '' +
+ '' +
+ '';
+ xmlDoc = atv.parseXML(xmlstr);
+ atv.loadXML(xmlDoc);
+}
+
+function goHome(){
+ atvutils.loadURL("https://" + atv.jcathost.SigHost + "/xml/home.xml");
}
\ No newline at end of file
diff --git a/app/js/search.js b/app/js/search.js
new file mode 100644
index 0000000..242b0b5
--- /dev/null
+++ b/app/js/search.js
@@ -0,0 +1,52 @@
+// /\_/|
+// { ' ' } JellyCAT
+// \____\
+
+function checkLogin() {
+ if (atv.localStorage['jellyfin_loggedin'] === '1') {
+ renderSearchScreen();
+ } else {
+ console.log("No authenticated user.");
+ renderLoginRequestScreen();
+ }
+}
+
+function renderSearchScreen() {
+ xmlstr = '' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' Search' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ xmlDoc = atv.parseXML(xmlstr);
+ atv.loadAndSwapXML(xmlDoc);
+}
+
+function renderLoginRequestScreen() {
+ xmlstr = '' +
+ '' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ ' ' +
+ '';
+ xmlDoc = atv.parseXML(xmlstr);
+ atv.loadAndSwapXML(xmlDoc);
+}
diff --git a/app/js/searchfuncs.js b/app/js/searchfuncs.js
new file mode 100644
index 0000000..da98c6c
--- /dev/null
+++ b/app/js/searchfuncs.js
@@ -0,0 +1,6 @@
+// /\_/|
+// { ' ' } JellyCAT
+// \____\
+
+// the goal here is to grab the input and generate results, but that's going to be hard if we don't want to use the
+// GOlang server...
\ No newline at end of file
diff --git a/app/js/storagetest.js b/app/js/storagetest.js
index 9359bb5..29cb404 100644
--- a/app/js/storagetest.js
+++ b/app/js/storagetest.js
@@ -3,6 +3,7 @@
// \____\
function printSessionStorage() {
+ console.log("======== Printing ATV Session storage ===========")
var keys = ['test', 'exampleKey'];
@@ -17,8 +18,9 @@ function printSessionStorage() {
}
function printLocalStorage() {
+ console.log("======== Printing ATV Local storage ===========")
- var keys = ['test', 'jellyfin_server_address', 'jellyfin_username', 'jellyfin_password', 'jellyfin_auth'];
+ var keys = ['test', 'jellyfin_server_address', 'jellyfin_username', 'jellyfin_password', 'jellyfin_serverid', 'jellyfin_authtoken', 'jellyfin_loggedin'];
keys.forEach(function(key) {
var value = atv.localStorage.getItem(key);
@@ -42,4 +44,7 @@ function setTestLocalStorageItem() {
console.log('Test item set in localStorage.');
}
-
+function setFakeLogout() {
+ console.log("Setting fake Jellyfin logout Key")
+ atv.localStorage['jellyfin_loggedin'] = '0';
+}
\ No newline at end of file
diff --git a/app/xml/dvt/devtools.xml b/app/xml/dvt/devtools.xml
index 4721b91..5f8400a 100644
--- a/app/xml/dvt/devtools.xml
+++ b/app/xml/dvt/devtools.xml
@@ -38,7 +38,7 @@
-
+
diff --git a/app/xml/dvt/storagetest.xml b/app/xml/dvt/storagetest.xml
index 6a28c89..512a01a 100644
--- a/app/xml/dvt/storagetest.xml
+++ b/app/xml/dvt/storagetest.xml
@@ -11,16 +11,19 @@
-
+
-
+
+
+
+
-
+
-
+
diff --git a/app/xml/help.xml b/app/xml/help.xml
index e9f4a03..0e8aeff 100644
--- a/app/xml/help.xml
+++ b/app/xml/help.xml
@@ -3,7 +3,10 @@
\ No newline at end of file
diff --git a/app/xml/home.xml b/app/xml/home.xml
index 9dc8c86..c5aa292 100644
--- a/app/xml/home.xml
+++ b/app/xml/home.xml
@@ -8,25 +8,29 @@
Home
-
+ http://jcathost.dns/xml/homescreen.xml
Favorites
-
+ http://jcathost.dns/xml/favoritesscreen.xml
Movies
-
+ http://jcathost.dns/xml/movies.xml
TV-Shows
-
+ http://jcathost.dns/xml/shows.xml
- Search
-
+ Music
+ http://jcathost.dns/xml/music.xml
+ Search
+ http://jcathost.dns/xml/search.xml
+
+
Settings
http://jcathost.dns/xml/settings.xml
diff --git a/app/xml/search.xml b/app/xml/search.xml
new file mode 100644
index 0000000..38cf354
--- /dev/null
+++ b/app/xml/search.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/xml/settings.xml b/app/xml/settings.xml
index c20828d..1b518ec 100644
--- a/app/xml/settings.xml
+++ b/app/xml/settings.xml
@@ -2,7 +2,6 @@
-
diff --git a/main.go b/main.go
index 648a6b3..01b377b 100644
--- a/main.go
+++ b/main.go
@@ -26,7 +26,7 @@ func main() {
// Default information store
JellyCAT = JcatDefaults{
- Version: "0.1.3revA",
+ Version: "0.1.3revB",
Name: "JellyCAT Serving stHack",
HostName: config.CertName,
HostIP: config.HijackIP,