Fix change requests and general formatting improvements

This commit is contained in:
MrTimscampi 2020-02-17 20:41:04 +01:00
parent e12e6731b2
commit f1fb59ec26
11 changed files with 74 additions and 74 deletions

View File

@ -29,7 +29,6 @@ define(['require', 'inputManager', 'browser', 'globalize', 'connectionManager',
var offset = newPct - left; var offset = newPct - left;
var pctOfWidth = (offset / width) * 100; var pctOfWidth = (offset / width) * 100;
//console.debug(pctOfWidth);
var guideProgramName = cell.guideProgramName; var guideProgramName = cell.guideProgramName;
if (!guideProgramName) { if (!guideProgramName) {
guideProgramName = cell.querySelector('.guideProgramName'); guideProgramName = cell.querySelector('.guideProgramName');

View File

@ -298,7 +298,7 @@ define(['events', 'browser', 'require', 'apphost', 'appSettings', 'htmlMediaHelp
var errorCode = this.error ? (this.error.code || 0) : 0; var errorCode = this.error ? (this.error.code || 0) : 0;
var errorMessage = this.error ? (this.error.message || '') : ''; var errorMessage = this.error ? (this.error.message || '') : '';
console.error('Media element error: ' + errorCode.toString() + ' ' + errorMessage); console.error('media element error: ' + errorCode.toString() + ' ' + errorMessage);
var type; var type;

View File

@ -408,7 +408,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
lrd.media.streamType = cast.receiver.media.StreamType.OTHER; lrd.media.streamType = cast.receiver.media.StreamType.OTHER;
lrd.media.customData = options; lrd.media.customData = options;
console.debug('loading media url into mediaManager'); console.debug('loading media url into media manager');
try { try {
mediaManager.load(lrd); mediaManager.load(lrd);
@ -418,7 +418,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
return Promise.resolve(); return Promise.resolve();
} catch (err) { } catch (err) {
console.debug('mediaManager error: ' + err); console.debug('media manager error: ' + err);
return Promise.reject(); return Promise.reject();
} }
} }
@ -461,10 +461,10 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
} }
console.debug('loading playback url: ' + url); console.debug('loading playback url: ' + url);
console.debug('contentType: ' + contentType); console.debug('content type: ' + contentType);
host.onError = function (errorCode) { host.onError = function (errorCode) {
console.error("Fatal Error - " + errorCode); console.error("fatal Error - " + errorCode);
}; };
mediaElement.autoplay = false; mediaElement.autoplay = false;
@ -911,7 +911,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
function onError() { function onError() {
var errorCode = this.error ? (this.error.code || 0) : 0; var errorCode = this.error ? (this.error.code || 0) : 0;
var errorMessage = this.error ? (this.error.message || '') : ''; var errorMessage = this.error ? (this.error.message || '') : '';
console.error('Media element error: ' + errorCode.toString() + ' ' + errorMessage); console.error('media element error: ' + errorCode.toString() + ' ' + errorMessage);
var type; var type;
@ -1328,7 +1328,7 @@ define(['browser', 'require', 'events', 'apphost', 'loading', 'dom', 'playbackMa
function setCurrentTrackElement(streamIndex) { function setCurrentTrackElement(streamIndex) {
console.debug('Setting new text track index to: ' + streamIndex); console.debug('setting new text track index to: ' + streamIndex);
var mediaStreamTextTracks = getMediaStreamTextTracks(self._currentPlayOptions.mediaSource); var mediaStreamTextTracks = getMediaStreamTextTracks(self._currentPlayOptions.mediaSource);

View File

@ -1,8 +1,6 @@
define(["inputManager", "layoutManager"], function (inputManager, layoutManager) { define(["inputManager", "layoutManager"], function (inputManager, layoutManager) {
"use strict"; "use strict";
console.debug("keyboardnavigation");
/** /**
* Key name mapping. * Key name mapping.
*/ */
@ -142,7 +140,7 @@ define(["inputManager", "layoutManager"], function (inputManager, layoutManager)
} }
if (capture) { if (capture) {
console.debug("Disabling default event handling"); console.debug("disabling default event handling");
e.preventDefault(); e.preventDefault();
} }
}); });

View File

@ -581,8 +581,7 @@ define(['require', 'datetime', 'itemHelper', 'events', 'browser', 'imageLoader',
} }
function onPlaybackStart(e, state) { function onPlaybackStart(e, state) {
console.debug('nowplaying event: ' + e.type);
//console.debug('nowplaying event: ' + e.type);
var player = this; var player = this;

View File

@ -10,7 +10,7 @@ define(["loading", "globalize", "dashboardcss", "emby-input", "emby-button", "em
} }
function onUpdateUserComplete(result) { function onUpdateUserComplete(result) {
console.debug(result); console.debug("user update complete: " + result);
loading.hide(); loading.hide();
nextWizardPage(); nextWizardPage();
} }

View File

@ -68,6 +68,7 @@ define(["events", "appStorage"], function(events, appStorage) {
console.debug("ApiClient appVersion: " + appVersion); console.debug("ApiClient appVersion: " + appVersion);
console.debug("ApiClient deviceName: " + deviceName); console.debug("ApiClient deviceName: " + deviceName);
console.debug("ApiClient deviceId: " + deviceId); console.debug("ApiClient deviceId: " + deviceId);
this._serverInfo = {}; this._serverInfo = {};
this._serverAddress = serverAddress; this._serverAddress = serverAddress;
this._deviceId = deviceId; this._deviceId = deviceId;
@ -165,9 +166,10 @@ define(["events", "appStorage"], function(events, appStorage) {
function setSocketOnClose(apiClient, socket) { function setSocketOnClose(apiClient, socket) {
socket.onclose = function() { socket.onclose = function() {
console.debug("web socket closed"); console.debug("web socket closed");
apiClient._webSocket === socket; if (apiClient._webSocket === socket) {
console.debug("nulling out web socket"); console.debug("nulling out web socket");
apiClient._webSocket = null; apiClient._webSocket = null;
}
setTimeout(function() { setTimeout(function() {
events.trigger(apiClient, "websocketclose") events.trigger(apiClient, "websocketclose")
}, 0) }, 0)

View File

@ -2,7 +2,7 @@ define([], function() {
"use strict"; "use strict";
function onCachePutFail(e) { function onCachePutFail(e) {
console.error(e); console.error("cannot put to a cache: " + e);
} }
function updateCache(instance) { function updateCache(instance) {

View File

@ -2,7 +2,7 @@ define(["filerepository", "itemrepository", "useractionrepository", "transferman
"use strict"; "use strict";
function getLocalItem(serverId, itemId) { function getLocalItem(serverId, itemId) {
return console.debug("[localassetmanager] Begin getLocalItem"), itemrepository.get(serverId, itemId) return console.debug("localassetmanager: begin getLocalItem"), itemrepository.get(serverId, itemId)
} }
function recordUserAction(action) { function recordUserAction(action) {
@ -25,7 +25,7 @@ define(["filerepository", "itemrepository", "useractionrepository", "transferman
} }
function getServerItems(serverId) { function getServerItems(serverId) {
return console.debug("[localassetmanager] Begin getServerItems"), itemrepository.getAll(serverId) return console.debug("localassetmanager: begin getServerItems"), itemrepository.getAll(serverId)
} }
function getItemsFromIds(serverId, ids) { function getItemsFromIds(serverId, ids) {

View File

@ -2,9 +2,9 @@ define(["localassetmanager"], function(localassetmanager) {
"use strict"; "use strict";
function processDownloadStatus(apiClient, serverInfo, options) { function processDownloadStatus(apiClient, serverInfo, options) {
return console.debug("[mediasync] Begin processDownloadStatus"), localassetmanager.resyncTransfers().then(function() { return console.debug("mediasync: begin processDownloadStatus"), localassetmanager.resyncTransfers().then(function() {
return localassetmanager.getServerItems(serverInfo.Id).then(function(items) { return localassetmanager.getServerItems(serverInfo.Id).then(function(items) {
console.debug("[mediasync] Begin processDownloadStatus getServerItems completed"); console.debug("mediasync: begin processDownloadStatus getServerItems completed");
var p = Promise.resolve(), var p = Promise.resolve(),
cnt = 0; cnt = 0;
return items.filter(function(item) { return items.filter(function(item) {
@ -14,7 +14,9 @@ define(["localassetmanager"], function(localassetmanager) {
return reportTransfer(apiClient, item) return reportTransfer(apiClient, item)
}), cnt++ }), cnt++
}), p.then(function() { }), p.then(function() {
return console.debug("[mediasync] Exit processDownloadStatus. Items reported: " + cnt.toString()), Promise.resolve() console.debug("mediasync: exit processDownloadStatus");
console.debug("items reported: " + cnt.toString());
return Promise.resolve();
}) })
}) })
}) })
@ -23,39 +25,39 @@ define(["localassetmanager"], function(localassetmanager) {
function reportTransfer(apiClient, item) { function reportTransfer(apiClient, item) {
return localassetmanager.getItemFileSize(item.LocalPath).then(function(size) { return localassetmanager.getItemFileSize(item.LocalPath).then(function(size) {
return size > 0 ? apiClient.reportSyncJobItemTransferred(item.SyncJobItemId).then(function() { return size > 0 ? apiClient.reportSyncJobItemTransferred(item.SyncJobItemId).then(function() {
return item.SyncStatus = "synced", console.debug("[mediasync] reportSyncJobItemTransferred called for " + item.LocalPath), localassetmanager.addOrUpdateLocalItem(item) return item.SyncStatus = "synced", console.debug("mediasync: reportSyncJobItemTransferred called for " + item.LocalPath), localassetmanager.addOrUpdateLocalItem(item)
}, function(error) { }, function(error) {
return console.error("[mediasync] Mediasync error on reportSyncJobItemTransferred", error), item.SyncStatus = "error", localassetmanager.addOrUpdateLocalItem(item) return console.error("mediasync: mediasync error on reportSyncJobItemTransferred", error), item.SyncStatus = "error", localassetmanager.addOrUpdateLocalItem(item)
}) : localassetmanager.isDownloadFileInQueue(item.LocalPath).then(function(result) { }) : localassetmanager.isDownloadFileInQueue(item.LocalPath).then(function(result) {
return result ? Promise.resolve() : (console.debug("[mediasync] reportTransfer: Size is 0 and download no longer in queue. Deleting item."), localassetmanager.removeLocalItem(item).then(function() { return result ? Promise.resolve() : (console.debug("mediasync: reportTransfer: Size is 0 and download no longer in queue. Deleting item."), localassetmanager.removeLocalItem(item).then(function() {
return console.debug("[mediasync] reportTransfer: Item deleted."), Promise.resolve() return console.debug("mediasync: reportTransfer: Item deleted."), Promise.resolve()
}, function(err2) { }, function(err2) {
return console.debug("[mediasync] reportTransfer: Failed to delete item.", err2), Promise.resolve() return console.debug("mediasync: reportTransfer: Failed to delete item.", err2), Promise.resolve()
})) }))
}) })
}, function(error) { }, function(error) {
return console.error("[mediasync] reportTransfer: error on getItemFileSize. Deleting item.", error), localassetmanager.removeLocalItem(item).then(function() { return console.error("mediasync: reportTransfer: error on getItemFileSize. Deleting item.", error), localassetmanager.removeLocalItem(item).then(function() {
return console.debug("[mediasync] reportTransfer: Item deleted."), Promise.resolve() return console.debug("mediasync: reportTransfer: Item deleted."), Promise.resolve()
}, function(err2) { }, function(err2) {
return console.error("[mediasync] reportTransfer: Failed to delete item.", err2), Promise.resolve() return console.error("mediasync: reportTransfer: Failed to delete item.", err2), Promise.resolve()
}) })
}) })
} }
function reportOfflineActions(apiClient, serverInfo) { function reportOfflineActions(apiClient, serverInfo) {
return console.debug("[mediasync] Begin reportOfflineActions"), localassetmanager.getUserActions(serverInfo.Id).then(function(actions) { return console.debug("mediasync: begin reportOfflineActions"), localassetmanager.getUserActions(serverInfo.Id).then(function(actions) {
return actions.length ? apiClient.reportOfflineActions(actions).then(function() { return actions.length ? apiClient.reportOfflineActions(actions).then(function() {
return localassetmanager.deleteUserActions(actions).then(function() { return localassetmanager.deleteUserActions(actions).then(function() {
return console.debug("[mediasync] Exit reportOfflineActions (actions reported and deleted.)"), Promise.resolve() return console.debug("mediasync: exit reportOfflineActions (actions reported and deleted.)"), Promise.resolve()
}) })
}, function(err) { }, function(err) {
return console.error("[mediasync] error on apiClient.reportOfflineActions: " + err.toString()), localassetmanager.deleteUserActions(actions) return console.error("mediasync: error on apiClient.reportOfflineActions: " + err.toString()), localassetmanager.deleteUserActions(actions)
}) : (console.debug("[mediasync] Exit reportOfflineActions (no actions)"), Promise.resolve()) }) : (console.debug("mediasync: exit reportOfflineActions (no actions)"), Promise.resolve())
}) })
} }
function syncData(apiClient, serverInfo) { function syncData(apiClient, serverInfo) {
return console.debug("[mediasync] Begin syncData"), localassetmanager.getServerItems(serverInfo.Id).then(function(items) { return console.debug("mediasync: begin syncData"), localassetmanager.getServerItems(serverInfo.Id).then(function(items) {
var completedItems = items.filter(function(item) { var completedItems = items.filter(function(item) {
return item && ("synced" === item.SyncStatus || "error" === item.SyncStatus) return item && ("synced" === item.SyncStatus || "error" === item.SyncStatus)
}), }),
@ -67,16 +69,16 @@ define(["localassetmanager"], function(localassetmanager) {
}; };
return apiClient.syncData(request).then(function(result) { return apiClient.syncData(request).then(function(result) {
return afterSyncData(apiClient, serverInfo, result).then(function() { return afterSyncData(apiClient, serverInfo, result).then(function() {
return console.debug("[mediasync] Exit syncData"), Promise.resolve() return console.debug("mediasync: exit syncData"), Promise.resolve()
}, function(err) { }, function(err) {
return console.error("[mediasync] Error in syncData: " + err.toString()), Promise.resolve() return console.error("mediasync: error in syncData: " + err.toString()), Promise.resolve()
}) })
}) })
}) })
} }
function afterSyncData(apiClient, serverInfo, syncDataResult) { function afterSyncData(apiClient, serverInfo, syncDataResult) {
console.debug("[mediasync] Begin afterSyncData"); console.debug("mediasync: begin afterSyncData");
var p = Promise.resolve(); var p = Promise.resolve();
return syncDataResult.ItemIdsToRemove && syncDataResult.ItemIdsToRemove.length > 0 && syncDataResult.ItemIdsToRemove.forEach(function(itemId) { return syncDataResult.ItemIdsToRemove && syncDataResult.ItemIdsToRemove.length > 0 && syncDataResult.ItemIdsToRemove.forEach(function(itemId) {
p = p.then(function() { p = p.then(function() {
@ -85,25 +87,25 @@ define(["localassetmanager"], function(localassetmanager) {
}), p = p.then(function() { }), p = p.then(function() {
return removeObsoleteContainerItems(serverInfo.Id) return removeObsoleteContainerItems(serverInfo.Id)
}), p.then(function() { }), p.then(function() {
return console.debug("[mediasync] Exit afterSyncData"), Promise.resolve() return console.debug("mediasync: exit afterSyncData"), Promise.resolve()
}) })
} }
function removeObsoleteContainerItems(serverId) { function removeObsoleteContainerItems(serverId) {
return console.debug("[mediasync] Begin removeObsoleteContainerItems"), localassetmanager.removeObsoleteContainerItems(serverId) return console.debug("mediasync: begin removeObsoleteContainerItems"), localassetmanager.removeObsoleteContainerItems(serverId)
} }
function removeLocalItem(itemId, serverId) { function removeLocalItem(itemId, serverId) {
return console.debug("[mediasync] Begin removeLocalItem"), localassetmanager.getLocalItem(serverId, itemId).then(function(item) { return console.debug("mediasync: begin removeLocalItem"), localassetmanager.getLocalItem(serverId, itemId).then(function(item) {
return item ? localassetmanager.removeLocalItem(item) : Promise.resolve() return item ? localassetmanager.removeLocalItem(item) : Promise.resolve()
}, function(err2) { }, function(err2) {
return console.error("[mediasync] removeLocalItem: Failed: ", err2), Promise.resolve() return console.error("mediasync: removeLocalItem: Failed: ", err2), Promise.resolve()
}) })
} }
function getNewMedia(apiClient, downloadCount) { function getNewMedia(apiClient, downloadCount) {
return console.debug("[mediasync] Begin getNewMedia"), apiClient.getReadySyncItems(apiClient.deviceId()).then(function(jobItems) { return console.debug("mediasync: begin getNewMedia"), apiClient.getReadySyncItems(apiClient.deviceId()).then(function(jobItems) {
console.debug("[mediasync] getReadySyncItems returned " + jobItems.length + " items"); console.debug("mediasync: getReadySyncItems returned " + jobItems.length + " items");
var p = Promise.resolve(), var p = Promise.resolve(),
currentCount = downloadCount; currentCount = downloadCount;
return jobItems.forEach(function(jobItem) { return jobItems.forEach(function(jobItem) {
@ -111,15 +113,15 @@ define(["localassetmanager"], function(localassetmanager) {
return getNewItem(jobItem, apiClient) return getNewItem(jobItem, apiClient)
})) }))
}), p.then(function() { }), p.then(function() {
return console.debug("[mediasync] Exit getNewMedia"), Promise.resolve() return console.debug("mediasync: exit getNewMedia"), Promise.resolve()
}) })
}, function(err) { }, function(err) {
return console.error("[mediasync] getReadySyncItems: Failed: ", err), Promise.resolve() return console.error("mediasync: getReadySyncItems: Failed: ", err), Promise.resolve()
}) })
} }
function afterMediaDownloaded(apiClient, jobItem, localItem) { function afterMediaDownloaded(apiClient, jobItem, localItem) {
return console.debug("[mediasync] Begin afterMediaDownloaded"), getImages(apiClient, jobItem, localItem).then(function() { return console.debug("mediasync: begin afterMediaDownloaded"), getImages(apiClient, jobItem, localItem).then(function() {
var libraryItem = jobItem.Item; var libraryItem = jobItem.Item;
return downloadParentItems(apiClient, jobItem, libraryItem).then(function() { return downloadParentItems(apiClient, jobItem, libraryItem).then(function() {
return getSubtitles(apiClient, jobItem, localItem) return getSubtitles(apiClient, jobItem, localItem)
@ -128,21 +130,21 @@ define(["localassetmanager"], function(localassetmanager) {
} }
function createLocalItem(libraryItem, jobItem) { function createLocalItem(libraryItem, jobItem) {
console.debug("[localassetmanager] Begin createLocalItem"); console.debug("localassetmanager: begin createLocalItem");
var item = { var item = {
Item: libraryItem, Item: libraryItem,
ItemId: libraryItem.Id, ItemId: libraryItem.Id,
ServerId: libraryItem.ServerId, ServerId: libraryItem.ServerId,
Id: libraryItem.Id Id: libraryItem.Id
}; };
return jobItem && (item.SyncJobItemId = jobItem.SyncJobItemId), console.debug("[localassetmanager] End createLocalItem"), item return jobItem && (item.SyncJobItemId = jobItem.SyncJobItemId), console.debug("localassetmanager: end createLocalItem"), item
} }
function getNewItem(jobItem, apiClient) { function getNewItem(jobItem, apiClient) {
console.debug("[mediasync] Begin getNewItem"); console.debug("mediasync: begin getNewItem");
var libraryItem = jobItem.Item; var libraryItem = jobItem.Item;
return localassetmanager.getLocalItem(libraryItem.ServerId, libraryItem.Id).then(function(existingItem) { return localassetmanager.getLocalItem(libraryItem.ServerId, libraryItem.Id).then(function(existingItem) {
if (existingItem && ("queued" === existingItem.SyncStatus || "transferring" === existingItem.SyncStatus || "synced" === existingItem.SyncStatus) && (console.debug("[mediasync] getNewItem: getLocalItem found existing item"), localassetmanager.enableBackgroundCompletion())) return Promise.resolve(); if (existingItem && ("queued" === existingItem.SyncStatus || "transferring" === existingItem.SyncStatus || "synced" === existingItem.SyncStatus) && (console.debug("mediasync: getNewItem: getLocalItem found existing item"), localassetmanager.enableBackgroundCompletion())) return Promise.resolve();
libraryItem.CanDelete = !1, libraryItem.CanDownload = !1, libraryItem.SupportsSync = !1, libraryItem.People = [], libraryItem.Chapters = [], libraryItem.Studios = [], libraryItem.SpecialFeatureCount = null, libraryItem.LocalTrailerCount = null, libraryItem.RemoteTrailers = []; libraryItem.CanDelete = !1, libraryItem.CanDownload = !1, libraryItem.SupportsSync = !1, libraryItem.People = [], libraryItem.Chapters = [], libraryItem.Studios = [], libraryItem.SpecialFeatureCount = null, libraryItem.LocalTrailerCount = null, libraryItem.RemoteTrailers = [];
var localItem = createLocalItem(libraryItem, jobItem); var localItem = createLocalItem(libraryItem, jobItem);
return localItem.SyncStatus = "queued", downloadMedia(apiClient, jobItem, localItem) return localItem.SyncStatus = "queued", downloadMedia(apiClient, jobItem, localItem)
@ -169,7 +171,7 @@ define(["localassetmanager"], function(localassetmanager) {
return localassetmanager.addOrUpdateLocalItem(localItem).then(function() { return localassetmanager.addOrUpdateLocalItem(localItem).then(function() {
return Promise.resolve(localItem) return Promise.resolve(localItem)
}, function(err) { }, function(err) {
return console.error("[mediasync] downloadItem failed: " + err.toString()), Promise.resolve(null) return console.error("mediasync: downloadItem failed: " + err.toString()), Promise.resolve(null)
}) })
}) })
} }
@ -183,12 +185,12 @@ define(["localassetmanager"], function(localassetmanager) {
} }
function downloadMedia(apiClient, jobItem, localItem) { function downloadMedia(apiClient, jobItem, localItem) {
console.debug("[mediasync] downloadMedia: start."); console.debug("mediasync: downloadMedia: start.");
var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/File", { var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/File", {
api_key: apiClient.accessToken() api_key: apiClient.accessToken()
}); });
return ensureLocalPathParts(localItem, jobItem), localassetmanager.downloadFile(url, localItem).then(function(result) { return ensureLocalPathParts(localItem, jobItem), localassetmanager.downloadFile(url, localItem).then(function(result) {
console.debug("[mediasync] downloadMedia-downloadFile returned path: " + result.path); console.debug("mediasync: downloadMedia-downloadFile returned path: " + result.path);
var localPath = result.path, var localPath = result.path,
libraryItem = localItem.Item; libraryItem = localItem.Item;
if (localPath && libraryItem.MediaSources) if (localPath && libraryItem.MediaSources)
@ -200,18 +202,18 @@ define(["localassetmanager"], function(localassetmanager) {
return afterMediaDownloaded(apiClient, jobItem, localItem).then(function() { return afterMediaDownloaded(apiClient, jobItem, localItem).then(function() {
return result.isComplete ? (localItem.SyncStatus = "synced", reportTransfer(apiClient, localItem)) : Promise.resolve() return result.isComplete ? (localItem.SyncStatus = "synced", reportTransfer(apiClient, localItem)) : Promise.resolve()
}, function(err) { }, function(err) {
return console.debug("[mediasync] downloadMedia: afterMediaDownloaded failed: " + err), Promise.reject(err) return console.debug("mediasync: downloadMedia: afterMediaDownloaded failed: " + err), Promise.reject(err)
}) })
}, function(err) { }, function(err) {
return console.debug("[mediasync] downloadMedia: addOrUpdateLocalItem failed: " + err), Promise.reject(err) return console.debug("mediasync: downloadMedia: addOrUpdateLocalItem failed: " + err), Promise.reject(err)
}) })
}, function(err) { }, function(err) {
return console.debug("[mediasync] downloadMedia: localassetmanager.downloadFile failed: " + err), Promise.reject(err) return console.debug("mediasync: downloadMedia: localassetmanager.downloadFile failed: " + err), Promise.reject(err)
}) })
} }
function getImages(apiClient, jobItem, localItem) { function getImages(apiClient, jobItem, localItem) {
console.debug("[mediasync] Begin getImages"); console.debug("mediasync: begin getImages");
var p = Promise.resolve(), var p = Promise.resolve(),
libraryItem = localItem.Item, libraryItem = localItem.Item,
serverId = libraryItem.ServerId, serverId = libraryItem.ServerId,
@ -249,15 +251,15 @@ define(["localassetmanager"], function(localassetmanager) {
})), libraryItem.ParentPrimaryImageItemId && libraryItem.ParentPrimaryImageTag && (p = p.then(function() { })), libraryItem.ParentPrimaryImageItemId && libraryItem.ParentPrimaryImageTag && (p = p.then(function() {
return downloadImage(localItem, apiClient, serverId, libraryItem.ParentPrimaryImageItemId, libraryItem.ParentPrimaryImageTag, "Primary") return downloadImage(localItem, apiClient, serverId, libraryItem.ParentPrimaryImageItemId, libraryItem.ParentPrimaryImageTag, "Primary")
})), p.then(function() { })), p.then(function() {
return console.debug("[mediasync] Finished getImages"), localassetmanager.addOrUpdateLocalItem(localItem) return console.debug("mediasync: finished getImages"), localassetmanager.addOrUpdateLocalItem(localItem)
}, function(err) { }, function(err) {
return console.error("[mediasync] Error getImages: " + err.toString()), Promise.resolve() return console.error("mediasync: error getImages: " + err.toString()), Promise.resolve()
}) })
} }
function downloadImage(localItem, apiClient, serverId, itemId, imageTag, imageType, index) { function downloadImage(localItem, apiClient, serverId, itemId, imageTag, imageType, index) {
return index = index || 0, localassetmanager.hasImage(serverId, itemId, imageType, index).then(function(hasImage) { return index = index || 0, localassetmanager.hasImage(serverId, itemId, imageType, index).then(function(hasImage) {
if (hasImage) return console.debug("[mediasync] downloadImage - skip existing: " + itemId + " " + imageType + "_" + index.toString()), Promise.resolve(); if (hasImage) return console.debug("mediasync: downloadImage - skip existing: " + itemId + " " + imageType + "_" + index.toString()), Promise.resolve();
var maxWidth = 400; var maxWidth = 400;
"backdrop" === imageType && (maxWidth = null); "backdrop" === imageType && (maxWidth = null);
var imageUrl = apiClient.getScaledImageUrl(itemId, { var imageUrl = apiClient.getScaledImageUrl(itemId, {
@ -266,18 +268,18 @@ define(["localassetmanager"], function(localassetmanager) {
maxWidth: maxWidth, maxWidth: maxWidth,
api_key: apiClient.accessToken() api_key: apiClient.accessToken()
}); });
return console.debug("[mediasync] downloadImage " + itemId + " " + imageType + "_" + index.toString()), localassetmanager.downloadImage(localItem, imageUrl, serverId, itemId, imageType, index).then(function(result) { return console.debug("mediasync: downloadImage " + itemId + " " + imageType + "_" + index.toString()), localassetmanager.downloadImage(localItem, imageUrl, serverId, itemId, imageType, index).then(function(result) {
return Promise.resolve(result) return Promise.resolve(result)
}, function(err) { }, function(err) {
return console.error("[mediasync] Error downloadImage: " + err.toString()), Promise.resolve() return console.error("mediasync: error downloadImage: " + err.toString()), Promise.resolve()
}) })
}, function(err) { }, function(err) {
return console.error("[mediasync] Error downloadImage: " + err.toString()), Promise.resolve() return console.error("mediasync: error downloadImage: " + err.toString()), Promise.resolve()
}) })
} }
function getSubtitles(apiClient, jobItem, localItem) { function getSubtitles(apiClient, jobItem, localItem) {
if (console.debug("[mediasync] Begin getSubtitles"), !jobItem.Item.MediaSources.length) return console.debug("[mediasync] Cannot download subtitles because video has no media source info."), Promise.resolve(); if (console.debug("mediasync: begin getSubtitles"), !jobItem.Item.MediaSources.length) return console.debug("mediasync: cannot download subtitles because video has no media source info."), Promise.resolve();
var files = jobItem.AdditionalFiles.filter(function(f) { var files = jobItem.AdditionalFiles.filter(function(f) {
return "Subtitles" === f.Type return "Subtitles" === f.Type
}), }),
@ -288,16 +290,16 @@ define(["localassetmanager"], function(localassetmanager) {
return getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource) return getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource)
}) })
}), p.then(function() { }), p.then(function() {
return console.debug("[mediasync] Exit getSubtitles"), Promise.resolve() return console.debug("mediasync: exit getSubtitles"), Promise.resolve()
}) })
} }
function getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource) { function getItemSubtitle(file, apiClient, jobItem, localItem, mediaSource) {
console.debug("[mediasync] Begin getItemSubtitle"); console.debug("mediasync: begin getItemSubtitle");
var subtitleStream = mediaSource.MediaStreams.filter(function(m) { var subtitleStream = mediaSource.MediaStreams.filter(function(m) {
return "Subtitle" === m.Type && m.Index === file.Index return "Subtitle" === m.Type && m.Index === file.Index
})[0]; })[0];
if (!subtitleStream) return console.debug("[mediasync] Cannot download subtitles because matching stream info was not found."), Promise.resolve(); if (!subtitleStream) return console.debug("mediasync: cannot download subtitles because matching stream info was not found."), Promise.resolve();
var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/AdditionalFiles", { var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/AdditionalFiles", {
Name: file.Name, Name: file.Name,
api_key: apiClient.accessToken() api_key: apiClient.accessToken()
@ -311,7 +313,7 @@ define(["localassetmanager"], function(localassetmanager) {
} }
function checkLocalFileExistence(apiClient, serverInfo, options) { function checkLocalFileExistence(apiClient, serverInfo, options) {
return options.checkFileExistence ? (console.debug("[mediasync] Begin checkLocalFileExistence"), localassetmanager.getServerItems(serverInfo.Id).then(function(items) { return options.checkFileExistence ? (console.debug("mediasync: begin checkLocalFileExistence"), localassetmanager.getServerItems(serverInfo.Id).then(function(items) {
var completedItems = items.filter(function(item) { var completedItems = items.filter(function(item) {
return item && ("synced" === item.SyncStatus || "error" === item.SyncStatus) return item && ("synced" === item.SyncStatus || "error" === item.SyncStatus)
}), }),
@ -332,13 +334,13 @@ define(["localassetmanager"], function(localassetmanager) {
return function() { return function() {
var self = this; var self = this;
"string" == typeof webWorkerBaseUrl && -1 !== webWorkerBaseUrl.indexOf("ms-appx://") ? self.sync = function(apiClient, serverInfo, options) { "string" == typeof webWorkerBaseUrl && -1 !== webWorkerBaseUrl.indexOf("ms-appx://") ? self.sync = function(apiClient, serverInfo, options) {
return console.debug("[mediasync]************************************* Start sync"), checkLocalFileExistence(apiClient, serverInfo, options).then(function() { return console.debug("mediasync: start sync"), checkLocalFileExistence(apiClient, serverInfo, options).then(function() {
return processDownloadStatus(apiClient, serverInfo, options).then(function() { return processDownloadStatus(apiClient, serverInfo, options).then(function() {
return localassetmanager.getDownloadItemCount().then(function(downloadCount) { return localassetmanager.getDownloadItemCount().then(function(downloadCount) {
return !0 === options.syncCheckProgressOnly && downloadCount > 2 ? Promise.resolve() : reportOfflineActions(apiClient, serverInfo).then(function() { return !0 === options.syncCheckProgressOnly && downloadCount > 2 ? Promise.resolve() : reportOfflineActions(apiClient, serverInfo).then(function() {
return getNewMedia(apiClient, downloadCount).then(function() { return getNewMedia(apiClient, downloadCount).then(function() {
return syncData(apiClient, serverInfo).then(function() { return syncData(apiClient, serverInfo).then(function() {
return console.debug("[mediasync]************************************* Exit sync"), Promise.resolve() return console.debug("mediasync: Exit sync"), Promise.resolve()
}) })
}) })
}) })
@ -348,7 +350,7 @@ define(["localassetmanager"], function(localassetmanager) {
console.error(err.toString()) console.error(err.toString())
}) })
} : self.sync = function(apiClient, serverInfo, options) { } : self.sync = function(apiClient, serverInfo, options) {
return console.debug("[mediasync]************************************* Start sync"), checkLocalFileExistence(apiClient, serverInfo, options).then(function() { return console.debug("mediasync: Start sync"), checkLocalFileExistence(apiClient, serverInfo, options).then(function() {
return syncData(apiClient, serverInfo).then(function() { return syncData(apiClient, serverInfo).then(function() {
return processDownloadStatus(apiClient, serverInfo, options).then(function() { return processDownloadStatus(apiClient, serverInfo, options).then(function() {
return localassetmanager.getDownloadItemCount().then(function(downloadCount) { return localassetmanager.getDownloadItemCount().then(function(downloadCount) {

View File

@ -588,7 +588,7 @@ var AppInfo = {};
require(['apphost', 'appRouter'], function (appHost, appRouter) { require(['apphost', 'appRouter'], function (appHost, appRouter) {
window.Emby = {}; window.Emby = {};
console.debug("onAppReady - loading dependencies"); console.debug("onAppReady: loading dependencies");
if (browser.iOS) { if (browser.iOS) {
require(['css!assets/css/ios.css']); require(['css!assets/css/ios.css']);
} }