@ -17205,8 +17205,8 @@ const CSS_STYLE = {
} ;
const supported = {
kodi : [ 'movie' , 'episode' ] ,
androidtv : [ 'movie' , 'show' , 'season' , 'episode' ],
plexPlayer : [ 'movie' , 'show' , 'season' , 'episode' ]
androidtv : [ 'movie' , 'show' , 'season' , 'episode' , 'clip' ],
plexPlayer : [ 'movie' , 'show' , 'season' , 'episode' , 'clip' ]
} ;
var bind = function bind ( fn , thisArg ) {
@ -19041,6 +19041,71 @@ const getOffset = (el) => {
}
return { top : y , left : x } ;
} ;
const createEpisodesView = ( playController , plexProtocol , ip , port , token , data ) => {
const episodeContainer = document . createElement ( 'div' ) ;
episodeContainer . className = 'episodeContainer' ;
episodeContainer . style . width = ` ${ CSS _STYLE . episodeWidth } px ` ;
const episodeThumbURL = ` ${ plexProtocol } :// ${ ip } : ${ port } /photo/:/transcode?width= ${ CSS _STYLE . episodeWidth } &height= ${ CSS _STYLE . episodeHeight } &minSize=1&upscale=1&url= ${ data . thumb } &X-Plex-Token= ${ token } ` ;
const episodeElem = document . createElement ( 'div' ) ;
episodeElem . className = 'episodeElem' ;
episodeElem . style . width = ` ${ CSS _STYLE . episodeWidth } px ` ;
episodeElem . style . height = ` ${ CSS _STYLE . episodeHeight } px ` ;
episodeElem . style . backgroundImage = ` url(' ${ episodeThumbURL } ') ` ;
episodeElem . dataset . clicked = 'false' ;
if ( typeof data . lastViewedAt === 'undefined' ) {
const toViewElem = document . createElement ( 'div' ) ;
toViewElem . className = 'toViewEpisode' ;
episodeElem . appendChild ( toViewElem ) ;
}
if ( playController . isPlaySupported ( data ) ) {
const episodeInteractiveArea = document . createElement ( 'div' ) ;
episodeInteractiveArea . className = 'interactiveArea' ;
const episodePlayButton = document . createElement ( 'button' ) ;
episodePlayButton . name = 'playButton' ;
episodePlayButton . addEventListener ( 'click' , episodeEvent => {
episodeEvent . stopPropagation ( ) ;
playController . play ( data , true ) ;
} ) ;
episodeInteractiveArea . append ( episodePlayButton ) ;
episodeElem . append ( episodeInteractiveArea ) ;
}
episodeContainer . append ( episodeElem ) ;
const episodeTitleElem = document . createElement ( 'div' ) ;
episodeTitleElem . className = 'episodeTitleElem' ;
episodeTitleElem . innerHTML = escapeHtml ( data . title ) ;
episodeContainer . append ( episodeTitleElem ) ;
const episodeNumber = document . createElement ( 'div' ) ;
episodeNumber . className = 'episodeNumber' ;
if ( data . type === 'episode' ) {
episodeNumber . innerHTML = escapeHtml ( ` Episode ${ escapeHtml ( data . index ) } ` ) ;
}
else if ( data . type === 'clip' ) {
let text = '' ;
switch ( data . subtype ) {
case 'behindTheScenes' :
text = 'Behind the Scenes' ;
break ;
case 'trailer' :
text = 'Trailer' ;
break ;
case 'scene' :
text = 'Scene' ;
break ;
case 'sceneOrSample' :
text = 'Scene' ;
break ;
default :
text = data . subtype ;
break ;
}
episodeNumber . innerHTML = escapeHtml ( text ) ;
}
episodeContainer . append ( episodeNumber ) ;
episodeContainer . addEventListener ( 'click' , episodeEvent => {
episodeEvent . stopPropagation ( ) ;
} ) ;
return episodeContainer ;
} ;
const isScrolledIntoView = ( elem ) => {
const rect = elem . getBoundingClientRect ( ) ;
const elemTop = rect . top ;
@ -19558,6 +19623,14 @@ style.textContent = css `
margin - right : 10 px ;
transition : 0.5 s ;
}
. movieExtras {
z - index : 4 ;
position : absolute ;
top : 340 px ;
width : calc ( 100 % - 32 px ) ;
left : 0 ;
padding : 16 px ;
}
. interactiveArea {
position : relative ;
width : 100 % ;
@ -20134,49 +20207,8 @@ class PlexMeetsHomeAssistant extends HTMLElement {
this . episodesElem . style . transition = ` 0s ` ;
this . episodesElem . style . top = ` ${ top + 2000 } px ` ;
lodash . forEach ( episodesData , episodeData => {
if ( this . episodesElem ) {
const episodeContainer = document . createElement ( 'div' ) ;
episodeContainer . className = 'episodeContainer' ;
episodeContainer . style . width = ` ${ CSS _STYLE . episodeWidth } px ` ;
const episodeThumbURL = ` ${ this . plexProtocol } :// ${ this . config . ip } : ${ this . config . port } /photo/:/transcode?width= ${ CSS _STYLE . episodeWidth } &height= ${ CSS _STYLE . episodeHeight } &minSize=1&upscale=1&url= ${ episodeData . thumb } &X-Plex-Token= ${ this . config . token } ` ;
const episodeElem = document . createElement ( 'div' ) ;
episodeElem . className = 'episodeElem' ;
episodeElem . style . width = ` ${ CSS _STYLE . episodeWidth } px ` ;
episodeElem . style . height = ` ${ CSS _STYLE . episodeHeight } px ` ;
episodeElem . style . backgroundImage = ` url(' ${ episodeThumbURL } ') ` ;
episodeElem . dataset . clicked = 'false' ;
if ( typeof episodeData . lastViewedAt === 'undefined' ) {
const toViewElem = document . createElement ( 'div' ) ;
toViewElem . className = 'toViewEpisode' ;
episodeElem . appendChild ( toViewElem ) ;
}
if ( this . playController && this . playController . isPlaySupported ( episodeData ) ) {
const episodeInteractiveArea = document . createElement ( 'div' ) ;
episodeInteractiveArea . className = 'interactiveArea' ;
const episodePlayButton = document . createElement ( 'button' ) ;
episodePlayButton . name = 'playButton' ;
episodePlayButton . addEventListener ( 'click' , episodeEvent => {
episodeEvent . stopPropagation ( ) ;
if ( this . plex && this . playController ) {
this . playController . play ( episodeData , true ) ;
}
} ) ;
episodeInteractiveArea . append ( episodePlayButton ) ;
episodeElem . append ( episodeInteractiveArea ) ;
}
episodeContainer . append ( episodeElem ) ;
const episodeTitleElem = document . createElement ( 'div' ) ;
episodeTitleElem . className = 'episodeTitleElem' ;
episodeTitleElem . innerHTML = escapeHtml ( episodeData . title ) ;
episodeContainer . append ( episodeTitleElem ) ;
const episodeNumber = document . createElement ( 'div' ) ;
episodeNumber . className = 'episodeNumber' ;
episodeNumber . innerHTML = escapeHtml ( ` Episode ${ escapeHtml ( episodeData . index ) } ` ) ;
episodeContainer . append ( episodeNumber ) ;
episodeContainer . addEventListener ( 'click' , episodeEvent => {
episodeEvent . stopPropagation ( ) ;
} ) ;
this . episodesElem . append ( episodeContainer ) ;
if ( this . episodesElem && this . playController ) {
this . episodesElem . append ( createEpisodesView ( this . playController , this . plexProtocol , this . config . ip , this . config . port , this . config . token , episodeData ) ) ;
}
} ) ;
clearInterval ( this . episodesLoadTimeout ) ;
@ -20245,7 +20277,33 @@ class PlexMeetsHomeAssistant extends HTMLElement {
} , 200 ) ;
}
else {
console . log ( await this . plex . getDetails ( data . key . split ( '/' ) [ 3 ] ) ) ;
const movieDetails = await this . plex . getDetails ( data . key . split ( '/' ) [ 3 ] ) ;
const extras = movieDetails . Extras . Metadata ;
this . episodesElemFreshlyLoaded = true ;
if ( this . episodesElem ) {
this . episodesElemHidden = false ;
this . episodesElem . style . display = 'block' ;
this . episodesElem . innerHTML = '' ;
this . episodesElem . style . transition = ` 0s ` ;
this . episodesElem . style . top = ` ${ top + 2000 } px ` ;
lodash . forEach ( extras , extrasData => {
if ( this . episodesElem && this . playController ) {
this . episodesElem . append ( createEpisodesView ( this . playController , this . plexProtocol , this . config . ip , this . config . port , this . config . token , extrasData ) ) ;
}
} ) ;
clearInterval ( this . episodesLoadTimeout ) ;
this . episodesLoadTimeout = setTimeout ( ( ) => {
if ( this . episodesElem ) {
this . episodesElem . style . transition = ` 0.7s ` ;
this . episodesElem . style . top = ` ${ top + CSS _STYLE . expandedHeight + 16 } px ` ;
this . resizeBackground ( ) ;
}
} , 200 ) ;
clearInterval ( this . episodesElemFreshlyLoadedTimeout ) ;
this . episodesElemFreshlyLoadedTimeout = setTimeout ( ( ) => {
this . episodesElemFreshlyLoaded = false ;
} , 700 ) ;
}
}
}
} ;