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

@ -16,12 +16,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.1.119",
"_release": "1.1.119",
"version": "1.1.121",
"_release": "1.1.121",
"_resolution": {
"type": "version",
"tag": "1.1.119",
"commit": "d3d62a7f416a3b980bf98000830d2ee6203a1658"
"tag": "1.1.121",
"commit": "5785022dd5fdf3633606d4c84d59f52ffa61251d"
},
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
"_target": "^1.1.51",

View file

@ -75,6 +75,7 @@
function getItems(userId, options) {
var serverInfo = apiclientcore.serverInfo();
var i;
if (serverInfo && options.ParentId === 'localview') {
@ -87,7 +88,7 @@
return Promise.resolve(result);
});
} else if (serverInfo && options && startsWith(options.ParentId, localViewPrefix)) {
} else if (serverInfo && options && (startsWith(options.ParentId, localViewPrefix) || startsWith(options.ParentId, localPrefix))) {
return localassetmanager.getViewItems(serverInfo.Id, userId, options.ParentId).then(function (items) {
@ -95,6 +96,8 @@
item.Id = localPrefix + item.Id;
});
items.sort(function (a, b) { return a.SortName.toLowerCase().localeCompare(b.SortName.toLowerCase()); });
var result = {
Items: items,
TotalRecordCount: items.length
@ -104,13 +107,39 @@
});
} else if (options && options.ExcludeItemIds && options.ExcludeItemIds.length) {
var exItems = options.ExcludeItemIds;
var exItems = options.ExcludeItemIds.split(',');
for (var i = 0; i < exItems.length; i++) {
for (i = 0; i < exItems.length; i++) {
if (startsWith(exItems[i], localPrefix)) {
return Promise.resolve(this.createEmptyList());
return Promise.resolve(createEmptyList());
}
}
} else if (options && options.Ids && options.Ids.length) {
var ids = options.Ids.split(',');
var hasLocal = false;
for (i = 0; i < ids.length; i++) {
if (startsWith(ids[i], localPrefix)) {
hasLocal = true;
}
}
if (hasLocal) {
return localassetmanager.getItemsFromIds(serverInfo.Id, ids).then(function (items) {
items.forEach(function (item) {
item.Id = localPrefix + item.Id;
});
var result = {
Items: items,
TotalRecordCount: items.length
};
return Promise.resolve(result);
});
}
}
return apiclientcore.getItems(userId, options);
@ -162,6 +191,37 @@
return apiclientcore.getItem(userId, itemId);
}
function getNextUpEpisodes(options) {
if (options.SeriesId) {
if (startsWith(options.SeriesId, localPrefix)) {
return Promise.resolve(createEmptyList());
}
}
return apiclientcore.getNextUpEpisodes(options);
}
function getSeasons(itemId, options) {
if (startsWith(itemId, localPrefix)) {
options.ParentId = itemId;
return getItems(apiclientcore.getCurrentUserId(), options);
}
return apiclientcore.getSeasons(itemId, options);
}
function getEpisodes(itemId, options) {
if (startsWith(options.SeasonId, localPrefix)) {
options.ParentId = options.SeasonId;
return getItems(apiclientcore.getCurrentUserId(), options);
}
return apiclientcore.getEpisodes(itemId, options);
}
function getThemeMedia(userId, itemId, inherit) {
if (startsWith(itemId, localViewPrefix) || startsWith(itemId, localPrefix)) {
@ -242,7 +302,10 @@
self.getUserViews = getUserViews;
self.getItems = getItems;
self.getItem = getItem;
self.getSeasons = getSeasons;
self.getEpisodes = getEpisodes;
self.getThemeMedia = getThemeMedia;
self.getNextUpEpisodes = getNextUpEpisodes;
self.getSimilarItems = getSimilarItems;
self.updateFavoriteStatus = updateFavoriteStatus;
self.getScaledImageUrl = getScaledImageUrl;

View file

@ -66,6 +66,26 @@
});
}
function getItemsFromIds(serverId, ids) {
var actions = ids.map(function (id) {
var strippedId = stripStart(id, 'local:');
return getLocalItem(serverId, strippedId);
});
return Promise.all(actions).then(function (items) {
var libItems = items.map(function (locItem) {
return locItem.Item;
});
return Promise.resolve(libItems);
});
}
function getViews(serverId, userId) {
return itemrepository.getServerItemTypes(serverId, userId).then(function (types) {
@ -80,7 +100,7 @@
ServerId: serverId,
Id: 'localview:MusicView',
Type: 'MusicView',
CollectionType: 'Music',
CollectionType: 'music',
IsFolder: true
};
@ -94,7 +114,7 @@
ServerId: serverId,
Id: 'localview:PhotosView',
Type: 'PhotosView',
CollectionType: 'Photos',
CollectionType: 'photos',
IsFolder: true
};
@ -108,23 +128,49 @@
ServerId: serverId,
Id: 'localview:TVView',
Type: 'TVView',
CollectionType: 'TvShows',
CollectionType: 'tvshows',
IsFolder: true
};
list.push(item);
}
if (types.indexOf('video') > -1 ||
types.indexOf('movie') > -1 ||
types.indexOf('musicvideo') > -1) {
if (types.indexOf('movie') > -1) {
item = {
Name: 'Movies',
ServerId: serverId,
Id: 'localview:MoviesView',
Type: 'MoviesView',
CollectionType: 'movies',
IsFolder: true
};
list.push(item);
}
if (types.indexOf('video') > -1) {
item = {
Name: 'Videos',
ServerId: serverId,
Id: 'localview:VideosView',
Type: 'VideosView',
CollectionType: 'HomeVideos',
CollectionType: 'videos',
IsFolder: true
};
list.push(item);
}
if (types.indexOf('musicvideo') > -1) {
item = {
Name: 'Music Videos',
ServerId: serverId,
Id: 'localview:MusicVideosView',
Type: 'MusicVideosView',
CollectionType: 'videos',
IsFolder: true
};
@ -135,28 +181,80 @@
});
}
function getTypeFilterForTopLevelView(parentId) {
var typeFilter = null;
switch (parentId) {
case 'localview:MusicView':
typeFilter = 'audio';
break;
case 'localview:PhotosView':
typeFilter = 'photo';
break;
case 'localview:TVView':
typeFilter = 'episode';
break;
case 'localview:VideosView':
typeFilter = 'video';
break;
case 'localview:MoviesView':
typeFilter = 'movie';
break;
case 'localview:MusicVideosView':
typeFilter = 'musicvideo';
break;
}
return typeFilter;
}
function getViewItems(serverId, userId, parentId) {
var typeFilter = getTypeFilterForTopLevelView(parentId);
parentId = stripStart(parentId, 'localview:');
parentId = stripStart(parentId, 'local:');
return getServerItems(serverId).then(function (items) {
var resultItems = items.filter(function (item) {
var resultItemIds = items.filter(function (item) {
var type = (item.Item.Type || '').toLowerCase();
switch (parentId) {
case 'localview:MusicView':
return type === 'audio';
case 'localview:PhotosView':
return type === 'photo';
case 'localview:TVView':
return type === 'episode';
case 'localview:VideosView':
return type === 'movie' || type === 'video' || type === 'musicvideo';
default:
return false;
if (item.SyncStatus && item.SyncStatus !== 'synced') {
return false;
}
if (typeFilter) {
var type = (item.Item.Type || '').toLowerCase();
return typeFilter === type;
}
return item.Item.ParentId === parentId;
}).map(function (item2) {
return item2.Item;
switch (typeFilter) {
case 'audio':
case 'photo':
return item2.Item.AlbumId;
case 'episode':
return item2.Item.SeriesId;
}
return item2.Item.Id;
}).filter(filterDistinct);
var resultItems = [];
items.forEach(function (item) {
var found = false;
resultItemIds.forEach(function (id) {
if (item.Item.Id === id) {
resultItems.push(item.Item);
}
});
});
return Promise.resolve(resultItems);
@ -218,14 +316,19 @@
var path = getDirectoryPath(libraryItem, serverInfo);
var localFolder = filerepository.getFullLocalPath(path);
path.push(getLocalFileName(libraryItem, jobItem.OriginalFileName));
var localPath;
var localPath = filerepository.getFullLocalPath(path);
if (jobItem) {
path.push(getLocalFileName(libraryItem, jobItem.OriginalFileName));
localPath = filerepository.getFullLocalPath(path);
}
for (var i = 0; i < libraryItem.MediaSources.length; i++) {
var mediaSource = libraryItem.MediaSources[i];
mediaSource.Path = localPath;
mediaSource.Protocol = 'File';
if (libraryItem.MediaSources) {
for (var i = 0; i < libraryItem.MediaSources.length; i++) {
var mediaSource = libraryItem.MediaSources[i];
mediaSource.Path = localPath;
mediaSource.Protocol = 'File';
}
}
var item = {
@ -235,11 +338,14 @@
ServerId: serverInfo.Id,
LocalPath: localPath,
LocalFolder: localFolder,
AdditionalFiles: jobItem.AdditionalFiles.slice(0),
Id: getLocalId(serverInfo.Id, libraryItem.Id),
SyncJobItemId: jobItem.SyncJobItemId
Id: getLocalId(serverInfo.Id, libraryItem.Id)
};
if (jobItem) {
item.AdditionalFiles = jobItem.AdditionalFiles.slice(0);
item.SyncJobItemId = jobItem.SyncJobItemId;
}
return Promise.resolve(item);
}
@ -424,7 +530,9 @@
parts.push('Metadata');
parts.push(serverId);
parts.push('images');
parts.push(itemId + '_' + imageType + '_' + index.toString() + '.png');
// Store without extension. This allows mixed image types since the browser will
// detect the type from the content
parts.push(itemId + '_' + imageType + '_' + index.toString()); // + '.jpg');
var finalParts = [];
for (var i = 0; i < parts.length; i++) {
@ -459,6 +567,29 @@
return uuid;
}
function startsWith(str, find) {
if (str && find && str.length > find.length) {
if (str.indexOf(find) === 0) {
return true;
}
}
return false;
}
function stripStart(str, find) {
if (startsWith(str, find)) {
return str.substr(find.length);
}
return str;
}
function filterDistinct(value, index, self) {
return self.indexOf(value) === index;
}
return {
getLocalItem: getLocalItem,
@ -486,6 +617,7 @@
getDownloadItemCount: getDownloadItemCount,
getViews: getViews,
getViewItems: getViewItems,
resyncTransfers: resyncTransfers
resyncTransfers: resyncTransfers,
getItemsFromIds: getItemsFromIds
};
});

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()
});