@@ -2,7 +2,7 @@ import { singleton } from './decorators';
2
2
3
3
import type { YoutubePlayer } from '@/types/youtube-player' ;
4
4
import type { GetState } from '@/types/datahost-get-state' ;
5
- import type { AlbumDetails , VideoDataChangeValue } from '@/types/player-api-events' ;
5
+ import type { AlbumDetails , PlayerOverlays , VideoDataChangeValue } from '@/types/player-api-events' ;
6
6
7
7
import type { SongInfo } from './song-info' ;
8
8
import type { VideoDataChanged } from '@/types/video-data-changed' ;
@@ -208,28 +208,35 @@ export default (api: YoutubePlayer) => {
208
208
list : playlistId
209
209
} = api . getVideoData ( ) ;
210
210
211
- const { playerOverlays } = api . getWatchNextResponse ( ) ;
211
+ const watchNextResponse = api . getWatchNextResponse ( ) ;
212
212
213
- sendSongInfo ( < VideoDataChangeValue > {
213
+ sendSongInfo ( {
214
214
title, author, videoId, playlistId,
215
215
216
216
isUpcoming : false ,
217
217
lengthSeconds : video . duration ,
218
218
loading : true ,
219
219
220
- uhhh : { playerOverlays }
221
- } ) ;
220
+ ytmdWatchNextResponse : watchNextResponse ,
221
+ } satisfies VideoDataChangeValue ) ;
222
222
}
223
223
}
224
224
225
225
function sendSongInfo ( videoData : VideoDataChangeValue ) {
226
226
const data = api . getPlayerResponse ( ) ;
227
227
228
- data . videoDetails . album = (
229
- Object . entries ( videoData ) . find (
230
- ( [ , value ] ) => value && Object . hasOwn ( value , 'playerOverlays' ) ,
231
- ) as [ string , AlbumDetails | undefined ]
232
- ) ?. [ 1 ] ?. playerOverlays ?. playerOverlayRenderer ?. browserMediaSession ?. browserMediaSessionRenderer ?. album ?. runs ?. at (
228
+ let playerOverlay : PlayerOverlays | undefined ;
229
+
230
+ if ( ! videoData . ytmdWatchNextResponse ) {
231
+ playerOverlay = (
232
+ Object . entries ( videoData ) . find (
233
+ ( [ , value ] ) => value && Object . hasOwn ( value , 'playerOverlays' ) ,
234
+ ) as [ string , AlbumDetails | undefined ]
235
+ ) ?. [ 1 ] ?. playerOverlays ;
236
+ } else {
237
+ playerOverlay = videoData . ytmdWatchNextResponse ?. playerOverlays ;
238
+ }
239
+ data . videoDetails . album = playerOverlay ?. playerOverlayRenderer ?. browserMediaSession ?. browserMediaSessionRenderer ?. album ?. runs ?. at (
233
240
0 ,
234
241
) ?. text ;
235
242
data . videoDetails . elapsedSeconds = 0 ;
0 commit comments