|
|
@ -19033,7 +19033,7 @@ class Plex {
|
|
|
|
let res = await axios.get(this.authorizeURL(decisionURL), {
|
|
|
|
let res = await axios.get(this.authorizeURL(decisionURL), {
|
|
|
|
timeout: this.requestTimeout
|
|
|
|
timeout: this.requestTimeout
|
|
|
|
});
|
|
|
|
});
|
|
|
|
while (parseFloat(res.data.MediaContainer.Metadata[0].Media[0].Part[0].key.split('offset=')[1].split('&')[0]) < 10) {
|
|
|
|
while (parseFloat(res.data.MediaContainer.Metadata[0].Media[0].Part[0].key.split('offset=')[1].split('&')[0]) < 3) {
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
await sleep(500);
|
|
|
|
await sleep(500);
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
|
// eslint-disable-next-line no-await-in-loop
|
|
|
@ -19333,7 +19333,7 @@ class PlayController {
|
|
|
|
this.getKodiSearchResults = async () => {
|
|
|
|
this.getKodiSearchResults = async () => {
|
|
|
|
return JSON.parse((await getState(this.hass, 'sensor.kodi_media_sensor_search')).attributes.data);
|
|
|
|
return JSON.parse((await getState(this.hass, 'sensor.kodi_media_sensor_search')).attributes.data);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.getKodiSearch = async (search) => {
|
|
|
|
this.getKodiSearch = async (search, silent = false) => {
|
|
|
|
await this.hass.callService('kodi_media_sensors', 'call_method', {
|
|
|
|
await this.hass.callService('kodi_media_sensors', 'call_method', {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
entity_id: 'sensor.kodi_media_sensor_search',
|
|
|
|
entity_id: 'sensor.kodi_media_sensor_search',
|
|
|
@ -19351,8 +19351,12 @@ class PlayController {
|
|
|
|
foundResult = result;
|
|
|
|
foundResult = result;
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lodash.isEqual(result.label, search)) {
|
|
|
|
|
|
|
|
foundResult = result;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (lodash.isEmpty(foundResult)) {
|
|
|
|
if (lodash.isEmpty(foundResult) && !silent) {
|
|
|
|
// eslint-disable-next-line no-alert
|
|
|
|
// eslint-disable-next-line no-alert
|
|
|
|
alert(`Title ${search} not found in Kodi.`);
|
|
|
|
alert(`Title ${search} not found in Kodi.`);
|
|
|
|
throw Error(`Title ${search} not found in Kodi.`);
|
|
|
|
throw Error(`Title ${search} not found in Kodi.`);
|
|
|
@ -19549,6 +19553,18 @@ class PlayController {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
this.playViaKodi = async (entityName, data, type) => {
|
|
|
|
this.playViaKodi = async (entityName, data, type) => {
|
|
|
|
if (!lodash.isNil(lodash.get(data, 'epg.Media[0].channelCallSign'))) {
|
|
|
|
if (!lodash.isNil(lodash.get(data, 'epg.Media[0].channelCallSign'))) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const kodiData = await this.getKodiSearch(lodash.get(data, 'epg.Media[0].channelCallSign'), true);
|
|
|
|
|
|
|
|
await this.hass.callService('kodi', 'call_method', {
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
|
|
|
|
entity_id: entityName,
|
|
|
|
|
|
|
|
method: 'Player.Open',
|
|
|
|
|
|
|
|
item: {
|
|
|
|
|
|
|
|
channelid: kodiData.channelid
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (err) {
|
|
|
|
const streamLink = `${this.plex.getBasicURL()}${await this.plex.tune(data.channelIdentifier, 'todo')}`;
|
|
|
|
const streamLink = `${this.plex.getBasicURL()}${await this.plex.tune(data.channelIdentifier, 'todo')}`;
|
|
|
|
await this.hass.callService('kodi', 'call_method', {
|
|
|
|
await this.hass.callService('kodi', 'call_method', {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
|
@ -19559,6 +19575,7 @@ class PlayController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (type === 'movie') {
|
|
|
|
else if (type === 'movie') {
|
|
|
|
const kodiData = await this.getKodiSearch(data.title);
|
|
|
|
const kodiData = await this.getKodiSearch(data.title);
|
|
|
|
await this.hass.callService('kodi', 'call_method', {
|
|
|
|
await this.hass.callService('kodi', 'call_method', {
|
|
|
|