@@ -867,7 +867,9 @@ export function convertInvidiousToLocalFormat(format) {
867867 const [ initStart , initEnd ] = format . init . split ( '-' )
868868 const [ indexStart , indexEnd ] = format . index . split ( '-' )
869869
870- const duration = parseInt ( parseFloat ( new URL ( format . url ) . searchParams . get ( 'dur' ) ) * 1000 )
870+ const url = new URL ( format . url )
871+
872+ const duration = parseInt ( parseFloat ( url . searchParams . get ( 'dur' ) ) * 1000 )
871873
872874 // only converts the properties that are needed to generate a DASH manifest with YouTube.js
873875 // audioQuality and qualityLabel don't go inside the DASH manifest, but are used by YouTube.js
@@ -904,6 +906,27 @@ export function convertInvidiousToLocalFormat(format) {
904906 } )
905907 } )
906908
909+ if ( localFormat . has_audio && url . searchParams . has ( 'xtags' ) ) {
910+ const xtags = url . searchParams . get ( 'xtags' ) . split ( ':' )
911+
912+ localFormat . language = xtags . find ( ( tag ) => tag . startsWith ( 'lang=' ) ) ?. split ( '=' ) [ 1 ] || null
913+ localFormat . is_drc = xtags . includes ( 'drc=1' )
914+
915+ const audioContent = xtags . find ( ( tag ) => tag . startsWith ( 'acont=' ) ) ?. split ( '=' ) [ 1 ]
916+ localFormat . is_dubbed = audioContent === 'dubbed'
917+ localFormat . is_descriptive = audioContent === 'descriptive'
918+ localFormat . is_secondary = audioContent === 'secondary'
919+ localFormat . is_auto_dubbed = audioContent === 'dubbed-auto'
920+ localFormat . is_original = audioContent === 'original' ||
921+ (
922+ ! localFormat . is_dubbed &&
923+ ! localFormat . is_descriptive &&
924+ ! localFormat . is_secondary &&
925+ ! localFormat . is_auto_dubbed &&
926+ ! localFormat . is_drc
927+ )
928+ }
929+
907930 return localFormat
908931}
909932
0 commit comments