update api libs

This commit is contained in:
Luke Pulverenti 2016-11-13 11:55:00 -05:00
parent 70d67d6b14
commit 369b16e760
19 changed files with 249 additions and 247 deletions

View File

@ -16,15 +16,14 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.1.83",
"_release": "1.1.83",
"version": "1.1.94",
"_release": "1.1.94",
"_resolution": {
"type": "version",
"tag": "1.1.83",
"commit": "64d6582c85ba3ab677f81bdb9d535587b5de3c65"
"tag": "1.1.94",
"commit": "dfd0b14c1af141e548fe2cee92a1f86967c50e8f"
},
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
"_target": "^1.1.83",
"_originalSource": "emby-apiclient",
"_direct": true
"_originalSource": "emby-apiclient"
}

View File

@ -1,4 +1,5 @@
define(['events'], function (events) {
'use strict';
/**
* Creates a new api client instance
@ -29,11 +30,11 @@
if (val != null) {
if (val.toLowerCase().indexOf('http') != 0) {
if (val.toLowerCase().indexOf('http') !== 0) {
throw new Error('Invalid url: ' + val);
}
var changed = val != serverAddress;
var changed = val !== serverAddress;
serverAddress = val;
@ -189,7 +190,7 @@
var headers = request.headers || {};
if (request.dataType == 'json') {
if (request.dataType === 'json') {
headers.accept = 'application/json';
}
@ -274,16 +275,16 @@
self.setRequestHeaders(request.headers);
}
if (self.enableAutomaticNetworking === false || request.type != "GET") {
if (self.enableAutomaticNetworking === false || request.type !== "GET") {
console.log('Requesting url without automatic networking: ' + request.url);
return getFetchPromise(request).then(function (response) {
if (response.status < 400) {
if (request.dataType == 'json' || request.headers.accept == 'application/json') {
if (request.dataType === 'json' || request.headers.accept === 'application/json') {
return response.json();
} else if (request.dataType == 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') == 0) {
} else if (request.dataType === 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') === 0) {
return response.text();
} else {
return response;
@ -349,7 +350,7 @@
console.log("Attempting reconnection to " + url);
var timeout = connectionMode == MediaBrowser.ConnectionMode.Local ? 7000 : 15000;
var timeout = connectionMode === MediaBrowser.ConnectionMode.Local ? 7000 : 15000;
fetchWithTimeout(url + "/system/info/public", {
@ -406,9 +407,9 @@
if (response.status < 400) {
if (request.dataType == 'json' || request.headers.accept == 'application/json') {
if (request.dataType === 'json' || request.headers.accept === 'application/json') {
return response.json();
} else if (request.dataType == 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') == 0) {
} else if (request.dataType === 'text' || (response.headers.get('Content-Type') || '').toLowerCase().indexOf('text/') === 0) {
return response.text();
} else {
return response;
@ -478,11 +479,11 @@
throw new Error("serverAddress is yet not set");
}
var lowered = url.toLowerCase();
if (lowered.indexOf('/emby') == -1 && lowered.indexOf('/mediabrowser') == -1) {
if (lowered.indexOf('/emby') === -1 && lowered.indexOf('/mediabrowser') === -1) {
url += '/emby';
}
if (name.charAt(0) != '/') {
if (name.charAt(0) !== '/') {
url += '/';
}
@ -602,7 +603,7 @@
else if (msg.MessageType === "UserUpdated" || msg.MessageType === "UserConfigurationUpdated") {
var user = msg.Data;
if (user.Id == self.getCurrentUserId()) {
if (user.Id === self.getCurrentUserId()) {
currentUser = null;
}
@ -674,13 +675,13 @@
return self.getDownloadSpeed(1000000).then(function (bitrate) {
if (bitrate < 1000000) {
return Math.round(bitrate * .8);
return Math.round(bitrate * 0.8);
} else {
// If that produced a fairly high speed, try again with a larger size to get a more accurate result
return self.getDownloadSpeed(2400000).then(function (bitrate) {
return Math.round(bitrate * .8);
return Math.round(bitrate * 0.8);
});
}
@ -1739,7 +1740,7 @@
* Adds a virtual folder
* @param {String} name
*/
self.addVirtualFolder = function (name, type, refreshLibrary, initialPaths, libraryOptions) {
self.addVirtualFolder = function (name, type, refreshLibrary, libraryOptions) {
if (!name) {
throw new Error("null name");
@ -1762,7 +1763,6 @@
type: "POST",
url: url,
data: JSON.stringify({
Paths: initialPaths,
LibraryOptions: libraryOptions
}),
contentType: 'application/json'
@ -1817,7 +1817,7 @@
* Adds an additional mediaPath to an existing virtual folder
* @param {String} name
*/
self.addMediaPath = function (virtualFolderName, mediaPath, refreshLibrary) {
self.addMediaPath = function (virtualFolderName, mediaPath, networkSharePath, refreshLibrary) {
if (!virtualFolderName) {
throw new Error("null virtualFolderName");
@ -1829,15 +1829,50 @@
var url = "Library/VirtualFolders/Paths";
var pathInfo = {
Path: mediaPath
};
if (networkSharePath) {
pathInfo.NetworkPath = networkSharePath;
}
url = self.getUrl(url, {
refreshLibrary: refreshLibrary ? true : false,
path: mediaPath,
name: virtualFolderName
refreshLibrary: refreshLibrary ? true : false
});
return self.ajax({
type: "POST",
url: url
url: url,
data: JSON.stringify({
Name: virtualFolderName,
PathInfo: pathInfo
}),
contentType: 'application/json'
});
};
self.updateMediaPath = function (virtualFolderName, pathInfo) {
if (!virtualFolderName) {
throw new Error("null virtualFolderName");
}
if (!pathInfo) {
throw new Error("null pathInfo");
}
var url = "Library/VirtualFolders/Paths/Update";
url = self.getUrl(url);
return self.ajax({
type: "POST",
url: url,
data: JSON.stringify({
Name: virtualFolderName,
PathInfo: pathInfo
}),
contentType: 'application/json'
});
};
@ -2039,7 +2074,7 @@
throw new Error("File must be an image.");
}
if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") {
if (file.type !== "image/png" && file.type !== "image/jpeg" && file.type !== "image/jpeg") {
throw new Error("File must be an image.");
}
@ -2096,7 +2131,7 @@
throw new Error("File must be an image.");
}
if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") {
if (file.type !== "image/png" && file.type !== "image/jpeg" && file.type !== "image/jpeg") {
throw new Error("File must be an image.");
}
@ -2330,7 +2365,7 @@
};
self.getDefaultImageQuality = function (imageType) {
return imageType.toLowerCase() == 'backdrop' ? 80 : 90;
return imageType.toLowerCase() === 'backdrop' ? 80 : 90;
};
function normalizeImageOptions(options) {
@ -2870,7 +2905,7 @@
var url;
if ((typeof userId).toString().toLowerCase() == 'string') {
if ((typeof userId).toString().toLowerCase() === 'string') {
url = self.getUrl("Users/" + userId + "/Items", options);
} else {

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
var myStore = {};
var cache;
@ -11,7 +12,7 @@
myStore.setItem = function (name, value) {
if (localData) {
var changed = localData[name] != value;
var changed = localData[name] !== value;
if (changed) {
localData[name] = value;

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
var myStore = {};
var cache;
@ -12,7 +13,7 @@
localStorage.setItem(name, value);
if (localData) {
var changed = localData[name] != value;
var changed = localData[name] !== value;
if (changed) {
localData[name] = value;

View File

@ -1,21 +1,22 @@
define([], function () {
'use strict';
function myStore(defaultObject) {
function MyStore(defaultObject) {
this.localData = {};
}
myStore.prototype.setItem = function (name, value) {
MyStore.prototype.setItem = function (name, value) {
this.localData[name] = value;
};
myStore.prototype.getItem = function (name) {
MyStore.prototype.getItem = function (name) {
return this.localData[name];
};
myStore.prototype.removeItem = function (name) {
MyStore.prototype.removeItem = function (name) {
this.localData[name] = null;
};
return new myStore();
return new MyStore();
});

View File

@ -1,4 +1,5 @@
define(['events', 'apiclient', 'appStorage'], function (events, apiClientFactory, appStorage) {
'use strict';
var ConnectionState = {
Unavailable: 0,
@ -83,7 +84,7 @@
var headers = request.headers || {};
if (request.dataType == 'json') {
if (request.dataType === 'json') {
headers.accept = 'application/json';
}
@ -177,7 +178,7 @@
if (response.status < 400) {
if (request.dataType == 'json' || request.headers.accept == 'application/json') {
if (request.dataType === 'json' || request.headers.accept === 'application/json') {
return response.json();
} else {
return response;
@ -215,7 +216,7 @@
return connectUser;
};
var minServerVersion = '3.0.5980';
var minServerVersion = '3.0.7000';
self.minServerVersion = function (val) {
if (val) {
@ -256,7 +257,7 @@
return servers.filter(function (s) {
return s.Id == id;
return s.Id === id;
})[0];
};
@ -402,7 +403,7 @@
var credentials = credentialProvider.credentials();
var servers = credentials.Servers.filter(function (s) {
return s.Id == result.ServerId;
return s.Id === result.ServerId;
});
var server = servers.length ? servers[0] : apiClient.serverInfo();
@ -435,7 +436,7 @@
var info = {
Id: user.Id,
IsSignedInOffline: true
}
};
credentialProvider.addOrUpdateUser(server, info);
}
@ -471,7 +472,7 @@
return new Promise(function (resolve, reject) {
if (connectUser && connectUser.Id == credentials.ConnectUserId) {
if (connectUser && connectUser.Id === credentials.ConnectUserId) {
resolve();
}
@ -707,7 +708,7 @@
var credentials = credentialProvider.credentials();
var servers = credentials.Servers.filter(function (u) {
return u.UserLinkType != "Guest";
return u.UserLinkType !== "Guest";
});
for (var j = 0, numServers = servers.length; j < numServers; j++) {
@ -785,7 +786,7 @@
Name: i.Name,
RemoteAddress: i.Url,
LocalAddress: i.LocalAddress,
UserLinkType: (i.UserType || '').toLowerCase() == "guest" ? "Guest" : "LinkedUser"
UserLinkType: (i.UserType || '').toLowerCase() === "guest" ? "Guest" : "LinkedUser"
};
});
@ -849,7 +850,7 @@
return connectServers.filter(function (connectServer) {
return server.Id == connectServer.Id;
return server.Id === connectServer.Id;
}).length > 0;
});
@ -924,11 +925,11 @@
console.log('Begin connectToServers, with ' + servers.length + ' servers');
if (servers.length == 1) {
if (servers.length === 1) {
return self.connectToServer(servers[0], options).then(function (result) {
if (result.State == ConnectionState.Unavailable) {
if (result.State === ConnectionState.Unavailable) {
result.State = result.ConnectUser == null ?
ConnectionState.ConnectSignIn :
@ -945,7 +946,7 @@
if (firstServer) {
return self.connectToServer(firstServer, options).then(function (result) {
if (result.State == ConnectionState.SignedIn) {
if (result.State === ConnectionState.SignedIn) {
return result;
@ -992,9 +993,9 @@
if (server.LastConnectionMode != null) {
//tests.push(server.LastConnectionMode);
}
if (tests.indexOf(ConnectionMode.Manual) == -1) { tests.push(ConnectionMode.Manual); }
if (tests.indexOf(ConnectionMode.Local) == -1) { tests.push(ConnectionMode.Local); }
if (tests.indexOf(ConnectionMode.Remote) == -1) { tests.push(ConnectionMode.Remote); }
if (tests.indexOf(ConnectionMode.Manual) === -1) { tests.push(ConnectionMode.Manual); }
if (tests.indexOf(ConnectionMode.Local) === -1) { tests.push(ConnectionMode.Local); }
if (tests.indexOf(ConnectionMode.Remote) === -1) { tests.push(ConnectionMode.Remote); }
//beginWakeServer(server);
@ -1007,7 +1008,7 @@
function stringEqualsIgnoreCase(str1, str2) {
return (str1 || '').toLowerCase() == (str2 || '').toLowerCase();
return (str1 || '').toLowerCase() === (str2 || '').toLowerCase();
}
function compareVersions(a, b) {
@ -1049,7 +1050,7 @@
var skipTest = false;
var timeout = defaultTimeout;
if (mode == ConnectionMode.Local) {
if (mode === ConnectionMode.Local) {
enableRetry = true;
timeout = 8000;
@ -1060,7 +1061,7 @@
}
}
else if (mode == ConnectionMode.Manual) {
else if (mode === ConnectionMode.Manual) {
if (stringEqualsIgnoreCase(address, server.LocalAddress)) {
enableRetry = true;
@ -1078,7 +1079,7 @@
tryConnect(address, timeout).then(function (result) {
if (compareVersions(self.minServerVersion(), result.Version) == 1) {
if (compareVersions(self.minServerVersion(), result.Version) === 1) {
console.log('minServerVersion requirement not met. Server version: ' + result.Version);
resolve({
@ -1086,6 +1087,12 @@
Servers: [server]
});
}
else if (result.Id !== server.Id) {
// http request succeeded, but it's a different server than what was expected
testNextConnectionMode(tests, index + 1, server, options, resolve);
} else {
console.log('calling onSuccessfulConnection with connection mode ' + mode + ' with server ' + server.Name);
onSuccessfulConnection(server, result, mode, options, resolve);
@ -1178,7 +1185,7 @@
result.Servers.push(server);
result.ApiClient.updateServerInfo(server, connectionMode);
if (result.State == ConnectionState.SignedIn) {
if (result.State === ConnectionState.SignedIn) {
afterConnected(result.ApiClient, options);
}
@ -1197,7 +1204,7 @@
// attempt to correct bad input
address = address.trim();
if (address.toLowerCase().indexOf('http') != 0) {
if (address.toLowerCase().indexOf('http') !== 0) {
address = "http://" + address;
}
@ -1243,49 +1250,38 @@
self.loginToConnect = function (username, password) {
return new Promise(function (resolve, reject) {
if (!username) {
return Promise.reject();
}
if (!password) {
return Promise.reject();
}
if (!username) {
reject();
return;
}
if (!password) {
reject();
return;
return ajax({
type: "POST",
url: "https://connect.emby.media/service/user/authenticate",
data: {
nameOrEmail: username,
rawpw: password
},
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {
"X-Application": appName + "/" + appVersion
}
require(['cryptojs-md5'], function () {
}).then(function (result) {
var md5 = getConnectPasswordHash(password);
var credentials = credentialProvider.credentials();
ajax({
type: "POST",
url: "https://connect.emby.media/service/user/authenticate",
data: {
nameOrEmail: username,
password: md5
},
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {
"X-Application": appName + "/" + appVersion
}
credentials.ConnectAccessToken = result.AccessToken;
credentials.ConnectUserId = result.User.Id;
}).then(function (result) {
credentialProvider.credentials(credentials);
var credentials = credentialProvider.credentials();
onConnectUserSignIn(result.User);
credentials.ConnectAccessToken = result.AccessToken;
credentials.ConnectUserId = result.User.Id;
credentialProvider.credentials(credentials);
onConnectUserSignIn(result.User);
resolve(result);
}, reject);
});
return result;
});
};
@ -1296,104 +1292,61 @@
var password = options.password;
var passwordConfirm = options.passwordConfirm;
return new Promise(function (resolve, reject) {
if (!email) {
return Promise.reject({ errorCode: 'invalidinput' });
}
if (!username) {
return Promise.reject({ errorCode: 'invalidinput' });
}
if (!password) {
return Promise.reject({ errorCode: 'invalidinput' });
}
if (!passwordConfirm) {
return Promise.reject({ errorCode: 'passwordmatch' });
}
if (password !== passwordConfirm) {
return Promise.reject({ errorCode: 'passwordmatch' });
}
if (!email) {
reject({ errorCode: 'invalidinput' });
return;
}
if (!username) {
reject({ errorCode: 'invalidinput' });
return;
}
if (!password) {
reject({ errorCode: 'invalidinput' });
return;
}
if (!passwordConfirm) {
reject({ errorCode: 'passwordmatch' });
return;
}
if (password != passwordConfirm) {
reject({ errorCode: 'passwordmatch' });
return;
var data = {
email: email,
userName: username,
rawpw: password
};
if (options.grecaptcha) {
data.grecaptcha = options.grecaptcha;
}
return ajax({
type: "POST",
url: "https://connect.emby.media/service/register",
data: data,
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {
"X-Application": appName + "/" + appVersion,
"X-CONNECT-TOKEN": "CONNECT-REGISTER"
}
require(['cryptojs-md5'], function () {
}).catch(function (response) {
var md5 = getConnectPasswordHash(password);
try {
return response.json();
} catch (err) {
throw err;
}
var data = {
email: email,
userName: username,
password: md5
};
}).then(function (result) {
if (options.grecaptcha) {
data.grecaptcha = options.grecaptcha;
}
ajax({
type: "POST",
url: "https://connect.emby.media/service/register",
data: data,
dataType: "json",
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
headers: {
"X-Application": appName + "/" + appVersion,
"X-CONNECT-TOKEN": "CONNECT-REGISTER"
}
}).then(resolve, function (response) {
try {
return response.json();
} catch (err) {
reject();
}
}).then(function (result) {
if (result && result.Status) {
reject({ errorCode: result.Status });
} else {
reject();
}
}, reject);
});
if (result && result.Status) {
return Promise.reject({ errorCode: result.Status });
} else {
Promise.reject();
}
});
};
function replaceAllWithSplit(str, find, replace) {
return str.split(find).join(replace);
}
function cleanConnectPassword(password) {
password = password || '';
password = replaceAllWithSplit(password, "&", "&amp;");
password = replaceAllWithSplit(password, "/", "&#092;");
password = replaceAllWithSplit(password, "!", "&#33;");
password = replaceAllWithSplit(password, "$", "&#036;");
password = replaceAllWithSplit(password, "\"", "&quot;");
password = replaceAllWithSplit(password, "<", "&lt;");
password = replaceAllWithSplit(password, ">", "&gt;");
password = replaceAllWithSplit(password, "'", "&#39;");
return password;
}
function getConnectPasswordHash(password) {
password = cleanConnectPassword(password);
return CryptoJS.MD5(password).toString();
}
self.getApiClient = function (item) {
// Accept string + object
@ -1406,7 +1359,7 @@
var serverInfo = a.serverInfo();
// We have to keep this hack in here because of the addApiClient method
return !serverInfo || serverInfo.Id == item;
return !serverInfo || serverInfo.Id === item;
})[0];
};
@ -1443,7 +1396,7 @@
}
var server = credentialProvider.credentials().Servers.filter(function (s) {
return s.Id == serverId;
return s.Id === serverId;
});
server = server.length ? server[0] : null;
@ -1453,7 +1406,7 @@
var credentials = credentialProvider.credentials();
credentials.Servers = credentials.Servers.filter(function (s) {
return s.Id != serverId;
return s.Id !== serverId;
});
credentialProvider.credentials(credentials);
@ -1556,11 +1509,11 @@
var updateDevicePromise;
// Cache for 3 days
if (params.deviceId && (new Date().getTime() - (regInfo.lastValidDate || 0)) < 259200000) {
if (params.deviceId && (new Date().getTime() - (regInfo.lastValidDate || 0)) < 604800000) {
console.log('getRegistrationInfo has cached info');
if (regInfo.deviceId == params.deviceId) {
if (regInfo.deviceId === params.deviceId) {
console.log('getRegistrationInfo returning cached info');
return Promise.resolve();
}
@ -1593,17 +1546,17 @@
var status = response.status;
console.log('getRegistrationInfo response: ' + status);
if (status == 200) {
if (status === 200) {
appStorage.setItem(cacheKey, JSON.stringify({
lastValidDate: new Date().getTime(),
deviceId: params.deviceId
}));
return Promise.resolve();
}
if (status == 401) {
if (status === 401) {
return Promise.reject();
}
if (status == 403) {
if (status === 403) {
return Promise.reject('overlimit');
}

View File

@ -1,4 +1,5 @@
define(['events', 'appStorage'], function (events, appStorage) {
'use strict';
return function (key) {
@ -57,7 +58,7 @@
}
var existing = list.filter(function (s) {
return s.Id == server.Id;
return s.Id === server.Id;
})[0];
if (existing) {
@ -109,7 +110,7 @@
server.Users = server.Users || [];
var existing = server.Users.filter(function (s) {
return s.Id == user.Id;
return s.Id === user.Id;
})[0];
if (existing) {

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
function getCallbacks(obj, name) {
@ -32,7 +33,7 @@
var list = getCallbacks(obj, eventName);
var i = list.indexOf(fn);
if (i != -1) {
if (i !== -1) {
list.splice(i, 1);
}
},

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
return function () {

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
function getLocalMediaSource(serverId, itemId) {
return Promise.resolve(null);

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
function stringToArrayBuffer(string) {
// UTF-16LE
@ -79,7 +80,7 @@
console.log(info);
if (info != null && info.socketId == socketId) {
if (info != null && info.socketId === socketId) {
var json = arrayBufferToString(info.data);
console.log('Server discovery json: ' + json);
var server = JSON.parse(json);
@ -119,7 +120,7 @@
console.log('chrome.sockets.udp.bind');
chrome.sockets.udp.bind(createInfo.socketId, '0.0.0.0', 0, function (bindResult) {
if (getResultCode(bindResult) != 0) {
if (getResultCode(bindResult) !== 0) {
console.log('bind fail: ' + bindResult);
return;
}
@ -130,7 +131,7 @@
chrome.sockets.udp.send(createInfo.socketId, data, '255.255.255.255', port, function (sendResult) {
if (getResultCode(sendResult) != 0) {
if (getResultCode(sendResult) !== 0) {
console.log('send fail: ' + sendResult);
} else {

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
function listenerSession(resolve, timeoutMs) {
@ -78,7 +79,7 @@
var stringLength = eventArguments.getDataReader().unconsumedBufferLength;
var receivedMessage = eventArguments.getDataReader().readString(stringLength);
if (receivedMessage == stringToSend) {
if (receivedMessage === stringToSend) {
return;
}
@ -97,7 +98,7 @@
servers.push(server);
} catch (exception) {
onError("Error receiving message: " + receivedMessage);
onError("Error receiving message: " + exception);
}
}

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
return {

View File

@ -1,4 +1,5 @@
define(['localassetmanager'], function (localAssetManager) {
'use strict';
return function (connectionManager) {
@ -43,9 +44,9 @@
return uploadHistory.FilesUploaded.filter(function (u) {
return getUploadId(file) == u.Id;
return getUploadId(file) === u.Id;
}).length == 0;
}).length === 0;
});
}

View File

@ -1,4 +1,5 @@
define(['localassetmanager'], function (LocalAssetManager) {
'use strict';
return function () {
@ -248,55 +249,54 @@
// Just for now while media syncing gets worked out
deferred.resolve();
return;
var libraryItem = localItem.Item;
//var libraryItem = localItem.Item;
var serverId = libraryItem.ServerId;
var itemId = null;
var imageTag = null;
var imageType = "Primary";
//var serverId = libraryItem.ServerId;
//var itemId = null;
//var imageTag = null;
//var imageType = "Primary";
switch (index) {
//switch (index) {
case 0:
itemId = libraryItem.Id;
imageType = "Primary";
imageTag = (libraryItem.ImageTags || {})["Primary"];
break;
case 1:
itemId = libraryItem.SeriesId;
imageType = "Primary";
imageTag = libraryItem.SeriesPrimaryImageTag;
break;
case 2:
itemId = libraryItem.SeriesId;
imageType = "Thumb";
imageTag = libraryItem.SeriesPrimaryImageTag;
break;
case 3:
itemId = libraryItem.AlbumId;
imageType = "Primary";
imageTag = libraryItem.AlbumPrimaryImageTag;
break;
default:
break;
}
// case 0:
// itemId = libraryItem.Id;
// imageType = "Primary";
// imageTag = (libraryItem.ImageTags || {})["Primary"];
// break;
// case 1:
// itemId = libraryItem.SeriesId;
// imageType = "Primary";
// imageTag = libraryItem.SeriesPrimaryImageTag;
// break;
// case 2:
// itemId = libraryItem.SeriesId;
// imageType = "Thumb";
// imageTag = libraryItem.SeriesPrimaryImageTag;
// break;
// case 3:
// itemId = libraryItem.AlbumId;
// imageType = "Primary";
// imageTag = libraryItem.AlbumPrimaryImageTag;
// break;
// default:
// break;
//}
if (!itemId || !imageTag) {
getNextImage(index + 1, apiClient, localItem, deferred);
return;
}
//if (!itemId || !imageTag) {
// getNextImage(index + 1, apiClient, localItem, deferred);
// return;
//}
downloadImage(apiClient, serverId, itemId, imageTag, imageType).then(function () {
//downloadImage(apiClient, serverId, itemId, imageTag, imageType).then(function () {
// For the sake of simplicity, limit to one image
deferred.resolve();
return;
// // For the sake of simplicity, limit to one image
// deferred.resolve();
// return;
getNextImage(index + 1, apiClient, localItem, deferred);
// getNextImage(index + 1, apiClient, localItem, deferred);
}, getOnFail(deferred));
//}, getOnFail(deferred));
}
function downloadImage(apiClient, serverId, itemId, imageTag, imageType) {
@ -340,7 +340,7 @@
}
var files = jobItem.AdditionalFiles.filter(function (f) {
return f.Type == 'Subtitles';
return f.Type === 'Subtitles';
});
var mediaSource = jobItem.Item.MediaSources[0];
@ -375,7 +375,7 @@
var deferred = DeferredBuilder.Deferred();
var subtitleStream = mediaSource.MediaStreams.filter(function (m) {
return m.Type == 'Subtitle' && m.Index == file.Index;
return m.Type === 'Subtitle' && m.Index === file.Index;
})[0];
if (!subtitleStream) {
@ -445,7 +445,7 @@
var userIdsWithAccess = syncDataResult.ItemUserAccess[itemId];
if (userIdsWithAccess.join(',') == savedUserIdsWithAccess.join(',')) {
if (userIdsWithAccess.join(',') === savedUserIdsWithAccess.join(',')) {
// Hasn't changed, nothing to do
deferred.resolve();
}

View File

@ -1,4 +1,5 @@
define(['serversync'], function (ServerSync) {
'use strict';
function syncNext(connectionManager, servers, index, options, resolve, reject) {

View File

@ -1,4 +1,5 @@
define(['localassetmanager'], function (localAssetManager) {
'use strict';
function syncNext(users, index, resolve, reject, apiClient, server) {

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
return function (connectionManager) {
@ -20,7 +21,7 @@
return connectionManager.connectToServer(server, connectionOptions).then(function (result) {
if (result.State == MediaBrowser.ConnectionState.SignedIn) {
if (result.State === MediaBrowser.ConnectionState.SignedIn) {
return performSync(server, options);
} else {
console.log('Unable to connect to server id: ' + server.Id);
@ -42,7 +43,7 @@
var uploadPhotos = options.uploadPhotos !== false;
if (options.cameraUploadServers && options.cameraUploadServers.indexOf(server.Id) == -1) {
if (options.cameraUploadServers && options.cameraUploadServers.indexOf(server.Id) === -1) {
uploadPhotos = false;
}

View File

@ -1,4 +1,5 @@
define([], function () {
'use strict';
function send(info) {