mirror of
https://github.com/jellyfin/jellyfin-chromecast.git
synced 2024-11-24 06:29:56 +00:00
auto-queue episodes
This commit is contained in:
parent
a83c86bbab
commit
b8d94c41bd
@ -193,8 +193,7 @@
|
||||
|
||||
if (data.command == 'PlayLast' || data.command == 'PlayNext') {
|
||||
|
||||
tagItems(data.options.items, data);
|
||||
queue(data.options.items, data.command);
|
||||
translateItems(data, data.options, data.options.items, data.command);
|
||||
}
|
||||
else if (data.command == 'Shuffle') {
|
||||
shuffle(data, data.options, data.options.items[0]);
|
||||
@ -291,7 +290,7 @@
|
||||
}
|
||||
else {
|
||||
|
||||
translateItems(data, data.options, data.options.items);
|
||||
translateItems(data, data.options, data.options.items, 'play');
|
||||
}
|
||||
|
||||
if (reportProgress) {
|
||||
@ -431,8 +430,8 @@
|
||||
|
||||
setTextTrack($scope, streamInfo.subtitleStreamUrl);
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
$scope.isChangingStream = false;
|
||||
|
||||
}, 1000);
|
||||
@ -463,16 +462,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
function translateItems(data, options, items) {
|
||||
function translateItems(data, options, items, method) {
|
||||
|
||||
var callback = function (result) {
|
||||
|
||||
options.items = result.Items;
|
||||
tagItems(options.items, data);
|
||||
playFromOptions(data.options);
|
||||
|
||||
if (method == 'PlayNext' || method == 'PlayLast') {
|
||||
queue(options.items, method);
|
||||
} else {
|
||||
playFromOptions(data.options);
|
||||
}
|
||||
};
|
||||
|
||||
translateRequestedItems(data.serverAddress, data.accessToken, data.userId, items).then(callback);
|
||||
var smartTranslate = method != 'PlayNext' && method != 'PlayLast';
|
||||
translateRequestedItems(data.serverAddress, data.accessToken, data.userId, items, smartTranslate).then(callback);
|
||||
}
|
||||
|
||||
function instantMix(data, options, item) {
|
||||
@ -496,7 +501,11 @@
|
||||
}
|
||||
|
||||
function queue(items, method) {
|
||||
window.playlist.push(items);
|
||||
|
||||
for (var i = 0, length = items.length; i < length; i++) {
|
||||
|
||||
window.playlist.push(items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function playFromOptions(options) {
|
||||
@ -564,7 +573,7 @@
|
||||
if (newIndex < playlist.length) {
|
||||
window.currentPlaylistIndex = newIndex;
|
||||
|
||||
var item = playlist[window.currentPlaylistIndex];
|
||||
var item = playlist[newIndex];
|
||||
|
||||
playItem(item, options || {}, stopPlayer);
|
||||
return true;
|
||||
|
58
helpers.js
58
helpers.js
@ -672,6 +672,24 @@ function getItemsForPlayback(serverAddress, accessToken, userId, query) {
|
||||
});
|
||||
}
|
||||
|
||||
function getEpisodesForPlayback(serverAddress, accessToken, userId, seriesId, query) {
|
||||
|
||||
query.UserId = userId;
|
||||
query.Fields = requiredItemFields;
|
||||
query.ExcludeLocationTypes = "Virtual";
|
||||
|
||||
var url = getUrl(serverAddress, "Shows/" + seriesId + "/Episodes");
|
||||
|
||||
return fetchhelper.ajax({
|
||||
|
||||
url: url,
|
||||
headers: getSecurityHeaders(accessToken, userId),
|
||||
query: query,
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
|
||||
function getIntros(serverAddress, accessToken, userId, firstItem) {
|
||||
|
||||
var url = getUrl(serverAddress, 'Users/' + userId + '/Items/' + firstItem.Id + '/Intros');
|
||||
@ -684,7 +702,7 @@ function getIntros(serverAddress, accessToken, userId, firstItem) {
|
||||
});
|
||||
}
|
||||
|
||||
function translateRequestedItems(serverAddress, accessToken, userId, items) {
|
||||
function translateRequestedItems(serverAddress, accessToken, userId, items, smart) {
|
||||
|
||||
var firstItem = items[0];
|
||||
|
||||
@ -724,11 +742,43 @@ function translateRequestedItems(serverAddress, accessToken, userId, items) {
|
||||
MediaTypes: "Audio,Video"
|
||||
});
|
||||
}
|
||||
else if (smart && firstItem.Type == "Episode" && items.length == 1) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
return getItemsForPlayback(serverAddress, accessToken, userId, {
|
||||
|
||||
Ids: firstItem.Id
|
||||
|
||||
resolve({ Items: items });
|
||||
});
|
||||
}).then(function (result) {
|
||||
|
||||
var episode = result.Items[0];
|
||||
|
||||
return getEpisodesForPlayback(serverAddress, accessToken, userId, episode.SeriesId, {
|
||||
IsVirtualUnaired: false,
|
||||
IsMissing: false,
|
||||
UserId: userId
|
||||
|
||||
}).then(function (episodesResult) {
|
||||
|
||||
var foundItem = false;
|
||||
episodesResult.Items = episodesResult.Items.filter(function (e) {
|
||||
|
||||
if (foundItem) {
|
||||
return true;
|
||||
}
|
||||
if (e.Id == episode.Id) {
|
||||
foundItem = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
episodesResult.TotalRecordCount = episodesResult.Items.length;
|
||||
return episodesResult;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve({ Items: items });
|
||||
}
|
||||
|
||||
function getMiscInfoHtml(item, datetime) {
|
||||
|
Loading…
Reference in New Issue
Block a user