diff --git a/dist/plex-meets-homeassistant.js b/dist/plex-meets-homeassistant.js index 7590953..f6d9c1a 100644 --- a/dist/plex-meets-homeassistant.js +++ b/dist/plex-meets-homeassistant.js @@ -17205,9 +17205,9 @@ const CSS_STYLE = { }; const supported = { kodi: ['movie', 'episode'], - androidtv: ['movie', 'show', 'season', 'episode', 'clip'], - plexPlayer: ['movie', 'show', 'season', 'episode', 'clip'], - cast: ['movie', 'episode'] + androidtv: ['movie', 'show', 'season', 'episode', 'clip', 'epg'], + plexPlayer: ['movie', 'show', 'season', 'episode', 'clip', 'epg'], + cast: ['movie', 'episode', 'epg'] }; var bind = function bind(fn, thisArg) { @@ -19283,6 +19283,7 @@ class PlayController { return foundResult; }; this.play = async (data, instantPlay = false) => { + console.log('play'); if (lodash.isArray(this.runBefore)) { const entityID = `${this.runBefore[0]}.${this.runBefore[1]}`; await this.hass.callService(this.runBefore[0], this.runBefore[1], {}); @@ -19292,26 +19293,35 @@ class PlayController { } } const entity = this.getPlayService(data); + let processData = data; + let provider; + if (!lodash.isNil(data.epg)) { + processData = data.epg; + provider = ''; + } + console.log(processData); switch (entity.key) { case 'kodi': - await this.playViaKodi(entity.value, data, data.type); + await this.playViaKodi(entity.value, processData, processData.type); break; case 'androidtv': - await this.playViaAndroidTV(entity.value, data.key.split('/')[3], instantPlay); + await this.playViaAndroidTV(entity.value, processData.key, instantPlay, provider); break; case 'plexPlayer': - await this.playViaPlexPlayer(entity.value, data.key.split('/')[3]); + await this.playViaPlexPlayer(entity.value, processData.key.split('/')[3]); break; case 'cast': if (this.hass.services.plex) { - const libraryName = lodash.isNil(data.librarySectionTitle) ? this.libraryName : data.librarySectionTitle; + const libraryName = lodash.isNil(processData.librarySectionTitle) + ? this.libraryName + : processData.librarySectionTitle; try { - switch (data.type) { + switch (processData.type) { case 'movie': await this.playViaCastPlex(entity.value, 'movie', `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase library_name: libraryName, - title: data.title + title: processData.title })}`); break; case 'episode': @@ -19319,28 +19329,28 @@ class PlayController { // eslint-disable-next-line @typescript-eslint/camelcase library_name: libraryName, // eslint-disable-next-line @typescript-eslint/camelcase - show_name: data.grandparentTitle, + show_name: processData.grandparentTitle, // eslint-disable-next-line @typescript-eslint/camelcase - season_number: data.parentIndex, + season_number: processData.parentIndex, // eslint-disable-next-line @typescript-eslint/camelcase - episode_number: data.index + episode_number: processData.index })}`); break; default: - this.playViaCast(entity.value, data.Media[0].Part[0].key); + this.playViaCast(entity.value, processData.Media[0].Part[0].key); } } catch (err) { console.log(err); - this.playViaCast(entity.value, data.Media[0].Part[0].key); + this.playViaCast(entity.value, processData.Media[0].Part[0].key); } } else { - this.playViaCast(entity.value, data.Media[0].Part[0].key); + this.playViaCast(entity.value, processData.Media[0].Part[0].key); } break; default: - throw Error(`No service available to play ${data.title}!`); + throw Error(`No service available to play ${processData.title}!`); } if (lodash.isArray(this.runAfter)) { await this.hass.callService(this.runAfter[0], this.runAfter[1], {}); @@ -19481,13 +19491,14 @@ class PlayController { media_content_id: mediaLink }); }; - this.playViaAndroidTV = async (entityName, mediaID, instantPlay = false) => { + this.playViaAndroidTV = async (entityName, mediaID, instantPlay = false, provider = 'com.plexapp.plugins.library') => { const serverID = await this.plex.getServerID(); let command = `am start`; if (instantPlay) { command += ' --ez "android.intent.extra.START_PLAYBACK" true'; } - command += ` -a android.intent.action.VIEW 'plex://server://${serverID}/com.plexapp.plugins.library/library/metadata/${mediaID}'`; + command += ` -a android.intent.action.VIEW 'plex://server://${serverID}/${provider}${mediaID}'`; + console.log(command); this.hass.callService('androidtv', 'adb_command', { // eslint-disable-next-line @typescript-eslint/camelcase entity_id: entityName, @@ -21302,6 +21313,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { lodash.forEach(this.data[key], (libraryData, libraryKey) => { if (!lodash.isNil(this.epgData[key][libraryData.channelCallSign])) { this.data[key][libraryKey].epg = this.epgData[key][libraryData.channelCallSign]; + this.data[key][libraryKey].type = 'epg'; } }); }); @@ -21850,7 +21862,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { fullscreenTrailer.style.visibility = 'hidden'; }; this.showDetails = async (data) => { - console.log(data); this.detailsShown = true; const top = this.getTop(); if (this.detailElem) { diff --git a/src/const.ts b/src/const.ts index 12de975..1c65a35 100644 --- a/src/const.ts +++ b/src/const.ts @@ -10,9 +10,9 @@ const CSS_STYLE: any = { const supported: any = { kodi: ['movie', 'episode'], - androidtv: ['movie', 'show', 'season', 'episode', 'clip'], - plexPlayer: ['movie', 'show', 'season', 'episode', 'clip'], - cast: ['movie', 'episode'] + androidtv: ['movie', 'show', 'season', 'episode', 'clip', 'epg'], + plexPlayer: ['movie', 'show', 'season', 'episode', 'clip', 'epg'], + cast: ['movie', 'episode', 'epg'] }; const LOREM_IPSUM = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec semper risus vitae aliquet interdum. Nulla facilisi. Pellentesque viverra sagittis lorem eget aliquet. Cras vehicula, purus vel consectetur mattis, ipsum arcu ullamcorper mi, id viverra purus ex eu dolor. Integer vehicula lacinia sem convallis iaculis. Nulla fermentum erat interdum, efficitur felis in, mollis neque. Vivamus luctus metus eget nisl pellentesque, placerat elementum magna eleifend. diff --git a/src/modules/PlayController.ts b/src/modules/PlayController.ts index f63dc46..88baf99 100644 --- a/src/modules/PlayController.ts +++ b/src/modules/PlayController.ts @@ -103,6 +103,7 @@ class PlayController { }; play = async (data: Record, instantPlay = false): Promise => { + console.log('play'); if (_.isArray(this.runBefore)) { const entityID = `${this.runBefore[0]}.${this.runBefore[1]}`; await this.hass.callService(this.runBefore[0], this.runBefore[1], {}); @@ -113,21 +114,31 @@ class PlayController { } } const entity = this.getPlayService(data); + + let processData = data; + let provider; + if (!_.isNil(data.epg)) { + processData = data.epg; + provider = ''; + } + console.log(processData); switch (entity.key) { case 'kodi': - await this.playViaKodi(entity.value, data, data.type); + await this.playViaKodi(entity.value, processData, processData.type); break; case 'androidtv': - await this.playViaAndroidTV(entity.value, data.key.split('/')[3], instantPlay); + await this.playViaAndroidTV(entity.value, processData.key, instantPlay, provider); break; case 'plexPlayer': - await this.playViaPlexPlayer(entity.value, data.key.split('/')[3]); + await this.playViaPlexPlayer(entity.value, processData.key.split('/')[3]); break; case 'cast': if (this.hass.services.plex) { - const libraryName = _.isNil(data.librarySectionTitle) ? this.libraryName : data.librarySectionTitle; + const libraryName = _.isNil(processData.librarySectionTitle) + ? this.libraryName + : processData.librarySectionTitle; try { - switch (data.type) { + switch (processData.type) { case 'movie': await this.playViaCastPlex( entity.value, @@ -135,7 +146,7 @@ class PlayController { `plex://${JSON.stringify({ // eslint-disable-next-line @typescript-eslint/camelcase library_name: libraryName, - title: data.title + title: processData.title })}` ); break; @@ -147,27 +158,27 @@ class PlayController { // eslint-disable-next-line @typescript-eslint/camelcase library_name: libraryName, // eslint-disable-next-line @typescript-eslint/camelcase - show_name: data.grandparentTitle, + show_name: processData.grandparentTitle, // eslint-disable-next-line @typescript-eslint/camelcase - season_number: data.parentIndex, + season_number: processData.parentIndex, // eslint-disable-next-line @typescript-eslint/camelcase - episode_number: data.index + episode_number: processData.index })}` ); break; default: - this.playViaCast(entity.value, data.Media[0].Part[0].key); + this.playViaCast(entity.value, processData.Media[0].Part[0].key); } } catch (err) { console.log(err); - this.playViaCast(entity.value, data.Media[0].Part[0].key); + this.playViaCast(entity.value, processData.Media[0].Part[0].key); } } else { - this.playViaCast(entity.value, data.Media[0].Part[0].key); + this.playViaCast(entity.value, processData.Media[0].Part[0].key); } break; default: - throw Error(`No service available to play ${data.title}!`); + throw Error(`No service available to play ${processData.title}!`); } if (_.isArray(this.runAfter)) { await this.hass.callService(this.runAfter[0], this.runAfter[1], {}); @@ -317,7 +328,12 @@ class PlayController { }); }; - private playViaAndroidTV = async (entityName: string, mediaID: number, instantPlay = false): Promise => { + private playViaAndroidTV = async ( + entityName: string, + mediaID: string, + instantPlay = false, + provider = 'com.plexapp.plugins.library' + ): Promise => { const serverID = await this.plex.getServerID(); let command = `am start`; @@ -325,7 +341,9 @@ class PlayController { command += ' --ez "android.intent.extra.START_PLAYBACK" true'; } - command += ` -a android.intent.action.VIEW 'plex://server://${serverID}/com.plexapp.plugins.library/library/metadata/${mediaID}'`; + command += ` -a android.intent.action.VIEW 'plex://server://${serverID}/${provider}${mediaID}'`; + + console.log(command); this.hass.callService('androidtv', 'adb_command', { // eslint-disable-next-line @typescript-eslint/camelcase diff --git a/src/plex-meets-homeassistant.ts b/src/plex-meets-homeassistant.ts index 082bc17..8c7ecf4 100644 --- a/src/plex-meets-homeassistant.ts +++ b/src/plex-meets-homeassistant.ts @@ -450,6 +450,7 @@ class PlexMeetsHomeAssistant extends HTMLElement { _.forEach(this.data[key], (libraryData, libraryKey) => { if (!_.isNil(this.epgData[key][libraryData.channelCallSign])) { this.data[key][libraryKey].epg = this.epgData[key][libraryData.channelCallSign]; + this.data[key][libraryKey].type = 'epg'; } }); }); @@ -1054,7 +1055,6 @@ class PlexMeetsHomeAssistant extends HTMLElement { }; showDetails = async (data: any): Promise => { - console.log(data); this.detailsShown = true; const top = this.getTop(); if (this.detailElem) {