Use Tautulli for Plex support

This commit is contained in:
2026-04-09 01:14:51 -04:00
parent 4b74403eb2
commit 5dec909a6c
2 changed files with 25 additions and 9 deletions

View File

@@ -4,10 +4,18 @@ Pebble.addEventListener("ready", function () {
Pebble.addEventListener("appmessage", function (dict) {
if (dict.payload["API_HOST"]) {
if (dict.payload["API_IS_PLEX"] == 1) {
callAPI(dict.payload["API_HOST"] + "/status/sessions/history/all", true, dict.payload["API_KEY"]);
} else {
if (dict.payload["API_IS_PLEX"] == 0) {
callAPI(dict.payload["API_HOST"] + "/System/ActivityLog/Entries", false, dict.payload["API_KEY"]);
} else {
// The official history endpoint doesn't seem to return history w/o Plex Pass.
// If someone with Plex Pass wants to give it a shot, I'd be happy to accept a PR adding this as an option.
// Until then, I'm using Tautulli because it's free.
//callAPI(dict.payload["API_HOST"] + "/status/sessions/history/all", true, dict.payload["API_KEY"]);
callAPI(
dict.payload["API_HOST"] + "/api/v2?apikey=" + dict.payload["API_KEY"] + "&cmd=get_history",
true,
NULL,
);
}
}
});
@@ -18,15 +26,13 @@ function callAPI(fullURL, isPlex, apiKey) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
console.log(xhr.responseText); // raw JSON string from API
console.log(xhr.responseText);
}
};
xhr.open("GET", fullURL, true);
xhr.setRequestHeader("Accept", "application/json");
if (isPlex) {
xhr.setRequestHeader("X-Plex-Token", apiKey);
} else {
if (!isPlex) {
xhr.setRequestHeader("Authorization", 'MediaBrowser Token="' + apiKey + '"');
}