@@ -86,12 +86,14 @@ export function openDetails(item) {
8686 renderEpisodes ( seasons [ seasonKeys [ 0 ] ] , seasonKeys [ 0 ] ) ;
8787
8888 seasonSelect . onchange = ( e ) => {
89- const selectedKey = e . target && typeof e . target . value === 'string' ? e . target . value : null ;
90- const selectedSeason = selectedKey && Object . prototype . hasOwnProperty . call ( seasons , selectedKey )
91- ? seasons [ selectedKey ]
89+ const rawValue = e . target && typeof e . target . value === 'string' ? e . target . value : null ;
90+ const selectedKey = rawValue && Object . prototype . hasOwnProperty . call ( seasons , rawValue )
91+ ? rawValue
9292 : null ;
93+ const selectedSeason = selectedKey ? seasons [ selectedKey ] : null ;
9394 if ( selectedSeason ) {
94- renderEpisodes ( selectedSeason , selectedKey ) ;
95+ const safeSeasonId = String ( selectedKey ) ;
96+ renderEpisodes ( selectedSeason , safeSeasonId ) ;
9597 }
9698 } ;
9799 } else {
@@ -133,13 +135,17 @@ function renderEpisodes(episodes, seasonNum) {
133135 ] ;
134136 }
135137
138+ const safeSeasonNum = typeof seasonNum === 'string'
139+ ? seasonNum . replace ( / [ ^ 0 - 9 ] / g, '' ) || '1'
140+ : String ( Number . isFinite ( seasonNum ) ? seasonNum : 1 ) ;
141+
136142 if ( episodes . length > 0 ) activeVideoSrc = episodes [ 0 ] . video ;
137143
138144 episodes . forEach ( ( ep , idx ) => {
139145 const row = document . createElement ( 'div' ) ;
140146 row . className = "episode-item flex flex-col md:flex-row items-center gap-6 p-4 rounded-2xl cursor-pointer transition-all border border-transparent hover:border-white/5 hover:bg-white/[0.02] group bg-[#0a0a0a]" ;
141147
142- const fallbackThumb = `https://placehold.co/300x200/333/666?text=S${ seasonNum } -EP${ idx + 1 } ` ;
148+ const fallbackThumb = `https://placehold.co/300x200/333/666?text=S${ safeSeasonNum } -EP${ idx + 1 } ` ;
143149 const thumbUrl = activeDetailItem ? activeDetailItem . banner : fallbackThumb ;
144150
145151 // Left container: index + thumbnail
0 commit comments