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

@@ -1,3 +1,13 @@
# One-More-Episode
# 1 More Episode?
"#^%$! I fell asleep and woke up watching a different season! What was the last episode I saw?!" - You, probably
Track what episode (Jellyfin) you fell asleep to from your Pebble smartwatch!
Well now your Pebble smartwatch can tell you! This app uses your Pebble Health
data to match the time you fell asleep with your Jellyfin/Plex watch history.
You can even track what you fell asleep to each night on your timeline!
Simply provide your Jellyfin/Plex ([Tautulli](https://tautulli.com/)) API key+URL
in settings and let your Pebble keep track!
>[!WARNING]
>Jellyfin is strongly encouraged! Plex support requires installing [Tautulli](https://tautulli.com/)
>since the official API doesn't seem to want to return watch history (unless you have Plex Pass?).

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 + '"');
}