Show different help text for each platform (Jellyfin vs Plex)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
var Clay = require('@rebble/clay');
|
||||
var clayConfig = require('./config');
|
||||
var clay = new Clay(clayConfig);
|
||||
var customClay = require('./customClay');
|
||||
new Clay(clayConfig, customClay);
|
||||
|
||||
Pebble.addEventListener("ready", function () {
|
||||
Pebble.sendAppMessage({ PKJS_READY: 1 });
|
||||
@@ -10,24 +11,34 @@ Pebble.addEventListener("appmessage", function (dict) {
|
||||
if (dict.payload["PKJS_SLEEP_TIMESTAMP"]) {
|
||||
var sleepTimestamp = dict.payload["PKJS_SLEEP_TIMESTAMP"];
|
||||
var cfg = JSON.parse(localStorage.getItem('clay-settings'));
|
||||
// TODO report last episode as "Configure app settings!" if CLAY_API_HOST or CLAY_API_KEY is empty
|
||||
// TODO report last episode as "Configure app settings!" if CLAY_API_HOST, CLAY_API_KEY, or CLAY_USER is empty
|
||||
// TODO use API to dynamically determine user (prompt on watch)
|
||||
if (cfg.CLAY_API_IS_JELLYFIN == true) {
|
||||
callAPI(cfg.CLAY_API_HOST + "/System/ActivityLog/Entries", cfg.CLAY_API_KEY, true, sleepTimestamp);
|
||||
callAPI(cfg.CLAY_API_HOST + "/System/ActivityLog/Entries", cfg.CLAY_API_KEY, true, cfg.CLAY_USER, sleepTimestamp);
|
||||
} 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(cfg.CLAY_API_HOST + "/status/sessions/history/all", cfg.CLAY_API_KEY, false, dict.payload["API_KEY"], sleepTimestamp);
|
||||
callAPI(cfg.CLAY_API_HOST + "/api/v2?apikey=" + cfg.CLAY_API_KEY + "&cmd=get_history", null, false, sleepTimestamp);
|
||||
//callAPI(cfg.CLAY_API_HOST + "/status/sessions/history/all", cfg.CLAY_API_KEY, false, cfg.CLAY_USER, sleepTimestamp);
|
||||
callAPI(cfg.CLAY_API_HOST + "/api/v2?apikey=" + cfg.CLAY_API_KEY + "&cmd=get_history", null, false, cfg.CLAY_USER, sleepTimestamp);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function callAPI(fullURL, apiKey, isJellyfin, sleepTimestamp) {
|
||||
function callAPI(fullURL, apiKey, isJellyfin, trackedUser, sleepTimestamp) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
console.log(xhr.responseText);
|
||||
var resp = JSON.parse(xhr.responseText);
|
||||
console.log(resp);
|
||||
if (resp && Array.isArray(resp.Items)) {
|
||||
resp.Items.forEach(function (item, index) {
|
||||
console.log(
|
||||
"[" + index + "] Name: " + item.Name + " | Date: " + item.Date
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user