mirror of
https://github.com/SEPPDROID/JellyCAT.git
synced 2025-10-22 16:04:20 +00:00
authentication and some experimenting
This commit is contained in:
@@ -192,5 +192,121 @@ function showServerErrorScreen(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function authenticateJellyfin(){
|
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 = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||||
|
'<atv>' +
|
||||||
|
' <body>' +
|
||||||
|
' <dialog id="com.jellycat.jellyfin-connect-error-dialog">' +
|
||||||
|
' <title>Error Authenticating Jellyfin Server:</title>' +
|
||||||
|
' <description>\n' +
|
||||||
|
'We could not authenticate the user you provided. Please check the username or password. Error logged.\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);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showAuthSuccessScreen(){
|
||||||
|
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.jellyfin-connect-success-dialog">' +
|
||||||
|
'<header>' +
|
||||||
|
'<simpleHeader accessibilityLabel="Dialog with Options">' +
|
||||||
|
'<title>Success:</title>' +
|
||||||
|
'</simpleHeader>' +
|
||||||
|
'</header>' +
|
||||||
|
'<description>Yay! You\'ve logged in successfully. Feel free to exit settings and dive in!</description>' +
|
||||||
|
'<menu>' +
|
||||||
|
'<initialSelection>' +
|
||||||
|
'<row>0</row>' +
|
||||||
|
'</initialSelection>' +
|
||||||
|
'<sections>' +
|
||||||
|
'<menuSection>' +
|
||||||
|
'<items>' +
|
||||||
|
'<oneLineMenuItem id="list_0" accessibilityLabel="Option 1" onSelect="goHome();">' +
|
||||||
|
'<label>Start</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);
|
||||||
|
}
|
||||||
|
|
||||||
|
function goHome(){
|
||||||
|
atvutils.loadURL("https://" + atv.jcathost.SigHost + "/xml/home.xml");
|
||||||
}
|
}
|
52
app/js/search.js
Normal file
52
app/js/search.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// /\_/|
|
||||||
|
// { ' ' } JellyCAT
|
||||||
|
// \____\
|
||||||
|
|
||||||
|
function checkLogin() {
|
||||||
|
if (atv.localStorage['jellyfin_loggedin'] === '1') {
|
||||||
|
renderSearchScreen();
|
||||||
|
} else {
|
||||||
|
console.log("No authenticated user.");
|
||||||
|
renderLoginRequestScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSearchScreen() {
|
||||||
|
xmlstr = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||||
|
'<atv>' +
|
||||||
|
' <head>' +
|
||||||
|
' <script src="http://jcathost.dns/js/jcm.js"/>' +
|
||||||
|
' <script src="http://jcathost.dns/js/searchfuncs.js"/>' +
|
||||||
|
' </head>' +
|
||||||
|
' <body>' +
|
||||||
|
' <search id="com.jellycat.search">' +
|
||||||
|
' <header>' +
|
||||||
|
' <simpleHeader accessibilityLabel="Search">' +
|
||||||
|
' <title>Search</title>' +
|
||||||
|
' </simpleHeader>' +
|
||||||
|
' </header>' +
|
||||||
|
' <baseURL></baseURL>' +
|
||||||
|
' </search>' +
|
||||||
|
' </body>' +
|
||||||
|
'</atv>';
|
||||||
|
xmlDoc = atv.parseXML(xmlstr);
|
||||||
|
atv.loadAndSwapXML(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLoginRequestScreen() {
|
||||||
|
xmlstr = '<?xml version="1.0" encoding="UTF-8"?>' +
|
||||||
|
'<atv>' +
|
||||||
|
' <head>' +
|
||||||
|
' <script src="http://jcathost.dns/js/jcm.js"/>' +
|
||||||
|
' <script src="http://jcathost.dns/js/search.js"/>' +
|
||||||
|
' </head>' +
|
||||||
|
' <body>' +
|
||||||
|
' <dialog id="com.jellycat.pleaselogin-dialog">' +
|
||||||
|
' <title>Not Connected</title>' +
|
||||||
|
' <description>Please go to the settings tab and add a Jellyfin Server.</description>' +
|
||||||
|
' </dialog>' +
|
||||||
|
' </body>' +
|
||||||
|
'</atv>';
|
||||||
|
xmlDoc = atv.parseXML(xmlstr);
|
||||||
|
atv.loadAndSwapXML(xmlDoc);
|
||||||
|
}
|
6
app/js/searchfuncs.js
Normal file
6
app/js/searchfuncs.js
Normal file
@@ -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...
|
@@ -3,6 +3,7 @@
|
|||||||
// \____\
|
// \____\
|
||||||
|
|
||||||
function printSessionStorage() {
|
function printSessionStorage() {
|
||||||
|
console.log("======== Printing ATV Session storage ===========")
|
||||||
|
|
||||||
var keys = ['test', 'exampleKey'];
|
var keys = ['test', 'exampleKey'];
|
||||||
|
|
||||||
@@ -17,8 +18,9 @@ function printSessionStorage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function printLocalStorage() {
|
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) {
|
keys.forEach(function(key) {
|
||||||
var value = atv.localStorage.getItem(key);
|
var value = atv.localStorage.getItem(key);
|
||||||
@@ -42,4 +44,7 @@ function setTestLocalStorageItem() {
|
|||||||
console.log('Test item set in localStorage.');
|
console.log('Test item set in localStorage.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setFakeLogout() {
|
||||||
|
console.log("Setting fake Jellyfin logout Key")
|
||||||
|
atv.localStorage['jellyfin_loggedin'] = '0';
|
||||||
|
}
|
@@ -38,7 +38,7 @@
|
|||||||
<oneLineMenuItem id="list_5" accessibilityLabel="Option 6" onSelect="console.log('UDID: ' + atv.device.udid);">
|
<oneLineMenuItem id="list_5" accessibilityLabel="Option 6" onSelect="console.log('UDID: ' + atv.device.udid);">
|
||||||
<label>Print device UDID (log)</label>
|
<label>Print device UDID (log)</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
<oneLineMenuItem id="list_6" accessibilityLabel="Option 7" onSelect="console.log('UDID: ' + atv.device.displayName);">
|
<oneLineMenuItem id="list_6" accessibilityLabel="Option 7" onSelect="console.log('DN: ' + atv.device.displayName);">
|
||||||
<label>Print device DisplayName (log)</label>
|
<label>Print device DisplayName (log)</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
<oneLineMenuItem id="list_7" accessibilityLabel="Option 8" onSelect="console.log('Unloading page'); atv.unloadPage();">
|
<oneLineMenuItem id="list_7" accessibilityLabel="Option 8" onSelect="console.log('Unloading page'); atv.unloadPage();">
|
||||||
|
@@ -11,16 +11,19 @@
|
|||||||
<oneLineMenuItem id="list_0" accessibilityLabel="Set test session storage key" onSelect="setTestSessionStorageItem();">
|
<oneLineMenuItem id="list_0" accessibilityLabel="Set test session storage key" onSelect="setTestSessionStorageItem();">
|
||||||
<label>Set ATV APP session storage key (test)</label>
|
<label>Set ATV APP session storage key (test)</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
<oneLineMenuItem id="list_0" accessibilityLabel="Set test local storage key" onSelect="setTestLocalStorageItem();">
|
<oneLineMenuItem id="list_1" accessibilityLabel="Set test local storage key" onSelect="setTestLocalStorageItem();">
|
||||||
<label>Set ATV APP local storage key (test)</label>
|
<label>Set ATV APP local storage key (test)</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
<oneLineMenuItem id="list_1" accessibilityLabel="Print session storage (log)" onSelect="printSessionStorage();">
|
<oneLineMenuItem id="list_2" accessibilityLabel="Set fake logout local storage key" onSelect="setFakeLogout();">
|
||||||
|
<label>Set Fake Jellyfin Logged Out key</label>
|
||||||
|
</oneLineMenuItem>
|
||||||
|
<oneLineMenuItem id="list_3" accessibilityLabel="Print session storage (log)" onSelect="printSessionStorage();">
|
||||||
<label>Print ATV App session storage (log)</label>
|
<label>Print ATV App session storage (log)</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
<oneLineMenuItem id="list_2" accessibilityLabel="Print ATV storage (log)" onSelect="printLocalStorage();">
|
<oneLineMenuItem id="list_4" accessibilityLabel="Print ATV storage (log)" onSelect="printLocalStorage();">
|
||||||
<label>Print ATV App local storage (log)</label>
|
<label>Print ATV App local storage (log)</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
<oneLineMenuItem id="list_3" accessibilityLabel="Clear ATV Storage and exit" onSelect="console.log('CLEARING ALL APP STORAGE AND EXITING APP'); atv.localStorage.clear(); atv.sessionStorage.clear(); atv.exitApp();">
|
<oneLineMenuItem id="list_5" accessibilityLabel="Clear ATV Storage and exit" onSelect="console.log('CLEARING ALL APP STORAGE AND EXITING APP'); atv.localStorage.clear(); atv.sessionStorage.clear(); atv.exitApp();">
|
||||||
<label>Clear ATV App Storage and exit App</label>
|
<label>Clear ATV App Storage and exit App</label>
|
||||||
</oneLineMenuItem>
|
</oneLineMenuItem>
|
||||||
</items>
|
</items>
|
||||||
|
@@ -3,7 +3,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<dialog id="com.jellycat.help-page">
|
<dialog id="com.jellycat.help-page">
|
||||||
<title>Help</title>
|
<title>Help</title>
|
||||||
<description>For assistance, please visit the JellyCAT documentation at https://github.com/SEPPDROID/JellyCAT/. If you encounter any issues, kindly raise them on the GitHub repository at https://github.com/SEPPDROID/JellyCAT/issues.</description>
|
<description>For assistance, please visit the JellyCAT documentation at https://github.com/SEPPDROID/JellyCAT/. If you encounter any issues, kindly raise them on the GitHub repository at https://github.com/SEPPDROID/JellyCAT/issues.
|
||||||
|
|
||||||
|
|
||||||
|
Press MENU to go back</description>
|
||||||
</dialog>
|
</dialog>
|
||||||
</body>
|
</body>
|
||||||
</atv>
|
</atv>
|
@@ -8,25 +8,29 @@
|
|||||||
<navigation currentIndex="0">
|
<navigation currentIndex="0">
|
||||||
<navigationItem id="nav1">
|
<navigationItem id="nav1">
|
||||||
<title>Home</title>
|
<title>Home</title>
|
||||||
<url></url>
|
<url>http://jcathost.dns/xml/homescreen.xml</url>
|
||||||
</navigationItem>
|
</navigationItem>
|
||||||
<navigationItem id="nav2">
|
<navigationItem id="nav2">
|
||||||
<title>Favorites</title>
|
<title>Favorites</title>
|
||||||
<url></url>
|
<url>http://jcathost.dns/xml/favoritesscreen.xml</url>
|
||||||
</navigationItem>
|
</navigationItem>
|
||||||
<navigationItem id="nav3">
|
<navigationItem id="nav3">
|
||||||
<title>Movies</title>
|
<title>Movies</title>
|
||||||
<url></url>
|
<url>http://jcathost.dns/xml/movies.xml</url>
|
||||||
</navigationItem>
|
</navigationItem>
|
||||||
<navigationItem id="nav4">
|
<navigationItem id="nav4">
|
||||||
<title>TV-Shows</title>
|
<title>TV-Shows</title>
|
||||||
<url></url>
|
<url>http://jcathost.dns/xml/shows.xml</url>
|
||||||
</navigationItem>
|
</navigationItem>
|
||||||
<navigationItem id="nav5">
|
<navigationItem id="nav5">
|
||||||
<title>Search</title>
|
<title>Music</title>
|
||||||
<url></url>
|
<url>http://jcathost.dns/xml/music.xml</url>
|
||||||
</navigationItem>
|
</navigationItem>
|
||||||
<navigationItem id="nav6">
|
<navigationItem id="nav6">
|
||||||
|
<title>Search</title>
|
||||||
|
<url>http://jcathost.dns/xml/search.xml</url>
|
||||||
|
</navigationItem>
|
||||||
|
<navigationItem id="nav7">
|
||||||
<title>Settings</title>
|
<title>Settings</title>
|
||||||
<url>http://jcathost.dns/xml/settings.xml</url>
|
<url>http://jcathost.dns/xml/settings.xml</url>
|
||||||
</navigationItem>
|
</navigationItem>
|
||||||
|
16
app/xml/search.xml
Normal file
16
app/xml/search.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<atv>
|
||||||
|
<head>
|
||||||
|
<script src="http://jcathost.dns/js/jcm.js"/>
|
||||||
|
<script src="http://jcathost.dns/js/search.js"/>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<optionList id="fakeUpdater" autoSelectSingleItem="true">
|
||||||
|
<items>
|
||||||
|
<oneLineMenuItem id="0" onSelect="checkLogin();">
|
||||||
|
<label></label>
|
||||||
|
</oneLineMenuItem>
|
||||||
|
</items>
|
||||||
|
</optionList>
|
||||||
|
</body>
|
||||||
|
</atv>
|
@@ -2,7 +2,6 @@
|
|||||||
<atv>
|
<atv>
|
||||||
<head>
|
<head>
|
||||||
<script src="http://jcathost.dns/js/jcm.js"/>
|
<script src="http://jcathost.dns/js/jcm.js"/>
|
||||||
<script src="http://jcathost.dns/js/about.js"/>
|
|
||||||
<script src="http://jcathost.dns/js/settingloader.js"/>
|
<script src="http://jcathost.dns/js/settingloader.js"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
2
main.go
2
main.go
@@ -26,7 +26,7 @@ func main() {
|
|||||||
|
|
||||||
// Default information store
|
// Default information store
|
||||||
JellyCAT = JcatDefaults{
|
JellyCAT = JcatDefaults{
|
||||||
Version: "0.1.3revA",
|
Version: "0.1.3revB",
|
||||||
Name: "JellyCAT Serving stHack",
|
Name: "JellyCAT Serving stHack",
|
||||||
HostName: config.CertName,
|
HostName: config.CertName,
|
||||||
HostIP: config.HijackIP,
|
HostIP: config.HijackIP,
|
||||||
|
Reference in New Issue
Block a user