mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-11-03 19:07:00 -05:00 
			
		
		
		
	Merge pull request #4266 from advplyr/hls_stream_url_update
Update HLS stream endpoints to not include user token
This commit is contained in:
		
						commit
						087835a9f3
					
				@ -1,5 +1,5 @@
 | 
			
		||||
export default class AudioTrack {
 | 
			
		||||
  constructor(track, sessionId, userToken, routerBasePath) {
 | 
			
		||||
  constructor(track, sessionId, routerBasePath) {
 | 
			
		||||
    this.index = track.index || 0
 | 
			
		||||
    this.startOffset = track.startOffset || 0 // Total time of all previous tracks
 | 
			
		||||
    this.duration = track.duration || 0
 | 
			
		||||
@ -11,7 +11,7 @@ export default class AudioTrack {
 | 
			
		||||
    this.sessionId = sessionId
 | 
			
		||||
    this.routerBasePath = routerBasePath || ''
 | 
			
		||||
    if (this.contentUrl?.startsWith('/hls')) {
 | 
			
		||||
      this.sessionTrackUrl = `${this.contentUrl}?token=${userToken}`
 | 
			
		||||
      this.sessionTrackUrl = this.contentUrl
 | 
			
		||||
    } else {
 | 
			
		||||
      this.sessionTrackUrl = `/public/session/${sessionId}/track/${this.index}`
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -37,9 +37,6 @@ export default class PlayerHandler {
 | 
			
		||||
  get isPlayingLocalItem() {
 | 
			
		||||
    return this.libraryItem && this.player instanceof LocalAudioPlayer
 | 
			
		||||
  }
 | 
			
		||||
  get userToken() {
 | 
			
		||||
    return this.ctx.$store.getters['user/getToken']
 | 
			
		||||
  }
 | 
			
		||||
  get playerPlaying() {
 | 
			
		||||
    return this.playerState === 'PLAYING'
 | 
			
		||||
  }
 | 
			
		||||
@ -226,7 +223,7 @@ export default class PlayerHandler {
 | 
			
		||||
 | 
			
		||||
    console.log('[PlayerHandler] Preparing Session', session)
 | 
			
		||||
 | 
			
		||||
    var audioTracks = session.audioTracks.map((at) => new AudioTrack(at, session.id, this.userToken, this.ctx.$config.routerBasePath))
 | 
			
		||||
    var audioTracks = session.audioTracks.map((at) => new AudioTrack(at, session.id, this.ctx.$config.routerBasePath))
 | 
			
		||||
 | 
			
		||||
    this.ctx.playerLoading = true
 | 
			
		||||
    this.isHlsTranscode = true
 | 
			
		||||
 | 
			
		||||
@ -313,7 +313,7 @@ class Server {
 | 
			
		||||
    router.use(express.json({ limit: '5mb' }))
 | 
			
		||||
 | 
			
		||||
    router.use('/api', this.auth.ifAuthNeeded(this.authMiddleware.bind(this)), this.apiRouter.router)
 | 
			
		||||
    router.use('/hls', this.authMiddleware.bind(this), this.hlsRouter.router)
 | 
			
		||||
    router.use('/hls', this.hlsRouter.router)
 | 
			
		||||
    router.use('/public', this.publicRouter.router)
 | 
			
		||||
 | 
			
		||||
    // Static path to generated nuxt
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user