Update: Better error message for unavailable plexPlayer

pull/16/head
Juraj Nyíri 4 years ago
parent 21ea17b9b1
commit 693e6c2481

@ -18806,6 +18806,7 @@ class PlayController {
this.playViaPlexPlayer = async (movieID) => { this.playViaPlexPlayer = async (movieID) => {
const { playQueueID, playQueueSelectedMetadataItemID } = await this.plexPlayerCreateQueue(movieID); const { playQueueID, playQueueSelectedMetadataItemID } = await this.plexPlayerCreateQueue(movieID);
const url = `${this.plex.protocol}://${this.plex.ip}:${this.plex.port}/player/playback/playMedia?address=${this.plex.ip}&commandID=1&containerKey=/playQueues/${playQueueID}?window=100%26own=1&key=/library/metadata/${playQueueSelectedMetadataItemID}&machineIdentifier=${await this.plex.getServerID()}&offset=0&port=${this.plex.port}&token=${this.plex.token}&type=video&protocol=${this.plex.protocol}`; const url = `${this.plex.protocol}://${this.plex.ip}:${this.plex.port}/player/playback/playMedia?address=${this.plex.ip}&commandID=1&containerKey=/playQueues/${playQueueID}?window=100%26own=1&key=/library/metadata/${playQueueSelectedMetadataItemID}&machineIdentifier=${await this.plex.getServerID()}&offset=0&port=${this.plex.port}&token=${this.plex.token}&type=video&protocol=${this.plex.protocol}`;
try {
const plexResponse = await axios({ const plexResponse = await axios({
method: 'post', method: 'post',
url, url,
@ -18820,6 +18821,15 @@ class PlayController {
if (!lodash.includes(plexResponse.data, 'status="OK"')) { if (!lodash.includes(plexResponse.data, 'status="OK"')) {
throw Error('Error while asking plex to play a movie - target device not available.'); throw Error('Error while asking plex to play a movie - target device not available.');
} }
}
catch (err) {
if (lodash.includes(err.message, '404')) {
throw Error('Defined plexPlayer is currently not available for playback.');
}
else {
throw err;
}
}
}; };
this.playViaKodi = async (data, type) => { this.playViaKodi = async (data, type) => {
if (type === 'movie') { if (type === 'movie') {

@ -127,6 +127,7 @@ class PlayController {
}&commandID=1&containerKey=/playQueues/${playQueueID}?window=100%26own=1&key=/library/metadata/${playQueueSelectedMetadataItemID}&machineIdentifier=${await this.plex.getServerID()}&offset=0&port=${ }&commandID=1&containerKey=/playQueues/${playQueueID}?window=100%26own=1&key=/library/metadata/${playQueueSelectedMetadataItemID}&machineIdentifier=${await this.plex.getServerID()}&offset=0&port=${
this.plex.port this.plex.port
}&token=${this.plex.token}&type=video&protocol=${this.plex.protocol}`; }&token=${this.plex.token}&type=video&protocol=${this.plex.protocol}`;
try {
const plexResponse = await axios({ const plexResponse = await axios({
method: 'post', method: 'post',
url, url,
@ -141,6 +142,13 @@ class PlayController {
if (!_.includes(plexResponse.data, 'status="OK"')) { if (!_.includes(plexResponse.data, 'status="OK"')) {
throw Error('Error while asking plex to play a movie - target device not available.'); throw Error('Error while asking plex to play a movie - target device not available.');
} }
} catch (err) {
if (_.includes(err.message, '404')) {
throw Error('Defined plexPlayer is currently not available for playback.');
} else {
throw err;
}
}
}; };
private playViaKodi = async (data: Record<string, any>, type: string): Promise<void> => { private playViaKodi = async (data: Record<string, any>, type: string): Promise<void> => {

Loading…
Cancel
Save