mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
Add DownloadAll for season and series
This commit is contained in:
parent
f06b9d5ed3
commit
9bef06f466
@ -141,6 +141,14 @@ import toast from './toast/toast';
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.Type === 'Season' || item.Type == 'Series') {
|
||||||
|
commands.push({
|
||||||
|
name: 'Download All',
|
||||||
|
id: 'downloadall',
|
||||||
|
icon: 'file_download'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (item.CanDelete && options.deleteItem !== false) {
|
if (item.CanDelete && options.deleteItem !== false) {
|
||||||
if (item.Type === 'Playlist' || item.Type === 'BoxSet') {
|
if (item.Type === 'Playlist' || item.Type === 'BoxSet') {
|
||||||
commands.push({
|
commands.push({
|
||||||
@ -347,6 +355,48 @@ import toast from './toast/toast';
|
|||||||
getResolveFunction(getResolveFunction(resolve, id), id)();
|
getResolveFunction(getResolveFunction(resolve, id), id)();
|
||||||
});
|
});
|
||||||
break;
|
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(seasons => {
|
||||||
|
downloadEpisodes([].concat.apply([], seasons.map(season => season.Items)));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
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': {
|
case 'copy-stream': {
|
||||||
const downloadHref = apiClient.getItemDownloadUrl(itemId);
|
const downloadHref = apiClient.getItemDownloadUrl(itemId);
|
||||||
copy(downloadHref).then(() => {
|
copy(downloadHref).then(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user