Use Tautulli for Plex support
This commit is contained in:
14
README.md
14
README.md
@@ -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?).
|
||||||
|
|||||||
@@ -4,10 +4,18 @@ Pebble.addEventListener("ready", function () {
|
|||||||
|
|
||||||
Pebble.addEventListener("appmessage", function (dict) {
|
Pebble.addEventListener("appmessage", function (dict) {
|
||||||
if (dict.payload["API_HOST"]) {
|
if (dict.payload["API_HOST"]) {
|
||||||
if (dict.payload["API_IS_PLEX"] == 1) {
|
if (dict.payload["API_IS_PLEX"] == 0) {
|
||||||
callAPI(dict.payload["API_HOST"] + "/status/sessions/history/all", true, dict.payload["API_KEY"]);
|
|
||||||
} else {
|
|
||||||
callAPI(dict.payload["API_HOST"] + "/System/ActivityLog/Entries", false, dict.payload["API_KEY"]);
|
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();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
if (xhr.readyState === 4) {
|
if (xhr.readyState === 4) {
|
||||||
console.log(xhr.responseText); // raw JSON string from API
|
console.log(xhr.responseText);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.open("GET", fullURL, true);
|
xhr.open("GET", fullURL, true);
|
||||||
xhr.setRequestHeader("Accept", "application/json");
|
xhr.setRequestHeader("Accept", "application/json");
|
||||||
if (isPlex) {
|
if (!isPlex) {
|
||||||
xhr.setRequestHeader("X-Plex-Token", apiKey);
|
|
||||||
} else {
|
|
||||||
xhr.setRequestHeader("Authorization", 'MediaBrowser Token="' + apiKey + '"');
|
xhr.setRequestHeader("Authorization", 'MediaBrowser Token="' + apiKey + '"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user