@@ -604,8 +604,13 @@ export default class SoundCloudSource {
604604 if ( ! forceRefresh ) {
605605 const cached = this . nodelink . trackCacheManager . get ( 'soundcloud' , info . identifier )
606606 if ( cached ) {
607- logger ( 'debug' , 'Sources' , `Using cached SoundCloud URL for ${ info . identifier } ` )
608- return cached
607+ const expiresMatch = cached . url . match ( / e x p i r e s = ( \d + ) / )
608+ const expires = expiresMatch ? parseInt ( expiresMatch [ 1 ] ) * 1000 : 0
609+
610+ if ( expires > Date . now ( ) + 5000 ) {
611+ logger ( 'debug' , 'Sources' , `Using cached SoundCloud URL for ${ info . identifier } ` )
612+ return cached
613+ }
609614 }
610615 }
611616
@@ -631,7 +636,7 @@ export default class SoundCloudSource {
631636
632637 const result = await this . _selectTranscoding ( req . body )
633638 if ( result && ! result . exception ) {
634- this . nodelink . trackCacheManager . set ( 'soundcloud' , info . identifier , result , 1000 * 60 * 60 * 3 )
639+ this . nodelink . trackCacheManager . set ( 'soundcloud' , info . identifier , result , 1000 * 60 * 15 )
635640 }
636641 return result
637642 } catch ( err ) {
@@ -769,12 +774,22 @@ export default class SoundCloudSource {
769774 this . _handleProgressive ( url , stream )
770775 return { stream }
771776 } else if ( protocol === 'hls' ) {
777+ let type = additionalData ?. format
778+
779+ if ( type === 'aac_hls' ) {
780+ type = 'fmp4'
781+ } else if ( type === 'mp3' ) {
782+ type = 'mp3'
783+ } else {
784+ type = 'mpegts'
785+ }
786+
772787 const stream = new HLSHandler ( url , {
773- type : 'mpegts' ,
788+ type,
774789 localAddress : this . nodelink . routePlanner ?. getIP ( ) ,
775790 startTime : additionalData ?. startTime || 0
776791 } )
777- return { stream, type : 'mpegts' }
792+ return { stream, type }
778793 } else {
779794 const stream = new PassThrough ( )
780795 stream . destroy ( new Error ( `Unsupported protocol: ${ protocol } ` ) )
0 commit comments