1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge branch 'master' into stylelint-vendor-prefix

This commit is contained in:
Bill Thornton 2023-01-05 12:22:57 -05:00 committed by GitHub
commit f84e45dc96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 1459 additions and 1372 deletions

View file

@ -28,7 +28,7 @@ import template from './accessSchedule.template.html';
function populateHours(context) {
let html = '';
for (let i = 0; i < 24; i++) {
for (let i = 0; i < 24; i += 0.5) {
html += `<option value="${i}">${getDisplayTime(i)}</option>`;
}

View file

@ -141,6 +141,14 @@ import toast from './toast/toast';
});
}
if (item.Type === 'Season' || item.Type == 'Series') {
commands.push({
name: globalize.translate('DownloadAll'),
id: 'downloadall',
icon: 'file_download'
});
}
if (item.CanDelete && options.deleteItem !== false) {
if (item.Type === 'Playlist' || item.Type === 'BoxSet') {
commands.push({
@ -316,6 +324,7 @@ import toast from './toast/toast';
const apiClient = ServerConnections.getApiClient(serverId);
return new Promise(function (resolve, reject) {
// eslint-disable-next-line sonarjs/max-switch-cases
switch (id) {
case 'addtocollection':
import('./collectionEditor/collectionEditor').then(({default: CollectionEditor}) => {
@ -347,6 +356,48 @@ import toast from './toast/toast';
getResolveFunction(getResolveFunction(resolve, id), id)();
});
break;
case 'downloadall': {
const downloadEpisodes = episodes => {
import('../scripts/fileDownloader').then((fileDownloader) => {
const downloads = episodes.map(episode => {
const downloadHref = apiClient.getItemDownloadUrl(episode.Id);
return {
url: downloadHref,
itemId: episode.Id,
serverId: serverId,
title: episode.Name,
filename: episode.Path.replace(/^.*[\\/]/, '')
};
});
fileDownloader.download(downloads);
});
};
const downloadSeasons = seasons => {
Promise.all(seasons.map(seasonItem => {
return apiClient.getEpisodes(seasonItem.SeriesId, {
seasonId: seasonItem.Id,
userId: options.user.Id,
Fields: 'CanDownload,Path'
});
}
)).then(seasonData => {
downloadEpisodes(seasonData.map(season => season.Items).flat());
});
};
if (item.Type === 'Season') {
downloadSeasons([item]);
} else if (item.Type === 'Series') {
apiClient.getSeasons(item.Id, {
userId: options.user.Id,
Fields: 'ItemCounts'
}).then(seasons => downloadSeasons(seasons.Items));
}
getResolveFunction(getResolveFunction(resolve, id), id)();
break;
}
case 'copy-stream': {
const downloadHref = apiClient.getItemDownloadUrl(itemId);
copy(downloadHref).then(() => {

View file

@ -1887,9 +1887,12 @@ class PlaybackManager {
}
if (options.items) {
return translateItemsForPlayback(options.items, options).then(function (items) {
return playWithIntros(items, options);
});
return translateItemsForPlayback(options.items, options)
.then((items) => getAdditionalParts(items))
.then(function (allItems) {
const flattened = allItems.flatMap(i => i);
return playWithIntros(flattened, options);
});
} else {
if (!options.serverId) {
throw new Error('serverId required!');
@ -1898,9 +1901,12 @@ class PlaybackManager {
return getItemsForPlayback(options.serverId, {
Ids: options.ids.join(',')
}).then(function (result) {
return translateItemsForPlayback(result.Items, options).then(function (items) {
return playWithIntros(items, options);
});
return translateItemsForPlayback(result.Items, options)
.then((items) => getAdditionalParts(items))
.then(function (allItems) {
const flattened = allItems.flatMap(i => i);
return playWithIntros(flattened, options);
});
});
}
};
@ -2039,6 +2045,23 @@ class PlaybackManager {
return player.play(options);
}
const getAdditionalParts = async (items) => {
const getOneAdditionalPart = async function (item) {
let retVal = [item];
if (item.Type === 'Movie') {
const client = ServerConnections.getApiClient(item.ServerId);
const user = await client.getCurrentUser();
const additionalParts = await client.getAdditionalVideoParts(user.Id, item.Id);
if (additionalParts.Items.length) {
retVal = [item, ...additionalParts.Items];
}
}
return retVal;
};
return Promise.all(items.flatMap(async (item) => getOneAdditionalPart(item)));
};
function playWithIntros(items, options) {
let playStartIndex = options.startIndex || 0;
let firstItem = items[playStartIndex];