mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
mark games played when played through nesbox
This commit is contained in:
parent
ef106f264a
commit
30dd80deae
6 changed files with 53 additions and 58 deletions
50
ApiClient.js
50
ApiClient.js
|
@ -2731,16 +2731,42 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Marks an item as played or unplayed
|
||||
* This should not be used to update playstate following playback.
|
||||
* There are separate playstate check-in methods for that. This should be used for a
|
||||
* separate option to reset playstate.
|
||||
* @param {String} userId
|
||||
* @param {String} itemId
|
||||
* @param {Boolean} wasPlayed
|
||||
*/
|
||||
self.updatePlayedStatus = function (userId, itemId, wasPlayed) {
|
||||
self.getDateParamValue = function (date) {
|
||||
function formatDigit(i) {
|
||||
return i < 10 ? "0" + i : i;
|
||||
}
|
||||
|
||||
var d = date;
|
||||
|
||||
return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds());
|
||||
};
|
||||
|
||||
self.markPlayed = function (userId, itemId, date) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
}
|
||||
|
||||
if (!itemId) {
|
||||
throw new Error("null itemId");
|
||||
}
|
||||
|
||||
var options = {};
|
||||
|
||||
if (date) {
|
||||
options.DatePlayed = self.getDateParamValue(date);
|
||||
}
|
||||
|
||||
var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId, options);
|
||||
|
||||
return self.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
};
|
||||
|
||||
self.markUnplayed = function (userId, itemId) {
|
||||
|
||||
if (!userId) {
|
||||
throw new Error("null userId");
|
||||
|
@ -2752,10 +2778,8 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
|
||||
var url = self.getUrl("Users/" + userId + "/PlayedItems/" + itemId);
|
||||
|
||||
var method = wasPlayed ? "POST" : "DELETE";
|
||||
|
||||
return self.ajax({
|
||||
type: method,
|
||||
type: "DELETE",
|
||||
url: url,
|
||||
dataType: "json"
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue