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

update components

This commit is contained in:
Luke Pulverenti 2017-01-22 22:54:51 -05:00
parent b72503e2d2
commit 1730740055
76 changed files with 16132 additions and 55 deletions

View file

@ -221,7 +221,9 @@
libraryItem.CanDelete = false;
libraryItem.CanDownload = false;
libraryItem.SupportsSync = false;
libraryItem.People = [];
libraryItem.UserData = [];
libraryItem.SpecialFeatureCount = null;
return localassetmanager.createLocalItem(libraryItem, serverInfo, jobItem).then(function (localItem) {
@ -230,18 +232,94 @@
localItem.SyncStatus = 'queued';
return downloadMedia(apiClient, jobItem, localItem, options).then(function () {
return downloadParentItems(apiClient, jobItem, localItem, serverInfo, options).then(function () {
return getImages(apiClient, jobItem, localItem).then(function () {
return downloadMedia(apiClient, jobItem, localItem, options).then(function () {
return getSubtitles(apiClient, jobItem, localItem);
return getImages(apiClient, jobItem, localItem).then(function () {
return getSubtitles(apiClient, jobItem, localItem);
});
});
});
});
});
}
function downloadParentItems(apiClient, jobItem, localItem, serverInfo, options) {
var p = Promise.resolve();
var libraryItem = localItem.Item;
var itemType = (libraryItem.Type || '').toLowerCase();
var logoImageTag = (libraryItem.ImageTags || {}).Logo;
switch (itemType) {
case 'episode':
if (libraryItem.SeriesId && libraryItem.SeriesId) {
p = p.then(function () {
return downloadItem(apiClient, libraryItem, libraryItem.SeriesId, serverInfo).then(function (seriesItem) {
libraryItem.SeriesLogoImageTag = (seriesItem.Item.ImageTags || {}).Logo;
return Promise.resolve();
});
});
}
if (libraryItem.SeasonId && libraryItem.SeasonId) {
p = p.then(function () {
return downloadItem(apiClient, libraryItem, libraryItem.SeasonId, serverInfo).then(function (seasonItem) {
libraryItem.SeasonPrimaryImageTag = (seasonItem.Item.ImageTags || {}).Primary;
return Promise.resolve();
});
});
}
break;
case 'audio':
case 'photo':
if (libraryItem.AlbumId && libraryItem.AlbumId) {
p = p.then(function () {
return downloadItem(apiClient, libraryItem, libraryItem.AlbumId, serverInfo);
});
}
break;
case 'video':
case 'movie':
case 'musicvideo':
// no parent item download for now
break;
}
return p;
}
function downloadItem(apiClient, libraryItem, itemId, serverInfo) {
return apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (downloadedItem) {
downloadedItem.CanDelete = false;
downloadedItem.CanDownload = false;
downloadedItem.SupportsSync = false;
downloadedItem.People = [];
downloadedItem.UserData = {};
downloadedItem.SpecialFeatureCount = null;
downloadedItem.BackdropImageTags = null;
return localassetmanager.createLocalItem(downloadedItem, serverInfo, null).then(function (localItem) {
return localassetmanager.addOrUpdateLocalItem(localItem).then(function () {
return Promise.resolve(localItem);
});
});
}, function (err) {
console.error('[mediasync] downloadItem failed: ' + err.toString());
return Promise.resolve(null);
});
}
function downloadMedia(apiClient, jobItem, localItem, options) {
var url = apiClient.getUrl('Sync/JobItems/' + jobItem.SyncJobItemId + '/File', {
@ -332,8 +410,23 @@
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.SeriesId, libraryItem.SeriesPrimaryImageTag, 'Primary');
});
}
if (libraryItem.SeriesId && libraryItem.SeriesThumbImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.SeriesId, libraryItem.SeriesPrimaryImageTag, 'Thumb');
return downloadImage(localItem, apiClient, serverId, libraryItem.SeriesId, libraryItem.SeriesThumbImageTag, 'Thumb');
});
}
if (libraryItem.SeriesId && libraryItem.SeriesLogoImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.SeriesId, libraryItem.SeriesLogoImageTag, 'Logo');
});
}
if (libraryItem.SeasonId && libraryItem.SeasonPrimaryImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.SeasonId, libraryItem.SeasonPrimaryImageTag, 'Primary');
});
}
@ -365,10 +458,16 @@
return Promise.resolve();
}
var imageUrl = apiClient.getImageUrl(itemId, {
var maxWidth = 400;
if (imageType === 'backdrop') {
maxWidth = null;
}
var imageUrl = apiClient.getScaledImageUrl(itemId, {
tag: imageTag,
type: imageType,
format: 'png',
maxWidth: maxWidth,
api_key: apiClient.accessToken()
});