@@ -867,7 +867,9 @@ export function convertInvidiousToLocalFormat(format) {
867
867
const [ initStart , initEnd ] = format . init . split ( '-' )
868
868
const [ indexStart , indexEnd ] = format . index . split ( '-' )
869
869
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 )
871
873
872
874
// only converts the properties that are needed to generate a DASH manifest with YouTube.js
873
875
// audioQuality and qualityLabel don't go inside the DASH manifest, but are used by YouTube.js
@@ -904,6 +906,27 @@ export function convertInvidiousToLocalFormat(format) {
904
906
} )
905
907
} )
906
908
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
+
907
930
return localFormat
908
931
}
909
932
0 commit comments