From 34b725ff6027266d73c475ad6a5dfe1bc2269e61 Mon Sep 17 00:00:00 2001 From: Manchewable Date: Sun, 16 Jun 2024 21:29:41 -0700 Subject: [PATCH] refactor GET_PLEX_PROFILE_EXTRAS and fix lint issues --- src/store/modules/slplayer/getters.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/store/modules/slplayer/getters.js b/src/store/modules/slplayer/getters.js index 4d32b6ec..97c27b56 100644 --- a/src/store/modules/slplayer/getters.js +++ b/src/store/modules/slplayer/getters.js @@ -216,20 +216,29 @@ export default { 'plex/GET_PLEX_BASE_PARAMS'](getters.GET_PLEX_SERVER_ACCESS_TOKEN), GET_PLEX_PROFILE_EXTRAS: (state, getters, rootState, rootGetters) => { + const targetCodec = (x) => `append-transcode-target-codec(${x})`; + const addLimitation = (x) => `+add-limitation(${x})`; + const videoStream = getters.GET_STREAMS.find(({ streamType }) => streamType === 1); const protocol = getters.GET_STREAMING_PROTOCOL; - let base = `append-transcode-target-codec('type=videoProfile&context=streaming&audioCodec=aac&protocol=${protocol})`; + let extras = targetCodec('type=videoProfile&context=streaming&audioCodec=aac' + + `&protocol=${protocol}`); if (videoStream.codec === 'hevc' && !getters.GET_FORCE_TRANSCODE) { - base = `append-transcode-target-codec(type=videoProfile&context=streaming&protocol=${protocol}&videoCodec=hevc&audioCodec=aac)` - + '+add-limitation(scope=videoCodec&scopeName=hevc&type=upperBound&name=video.bitDepth&value=10&replace=true)'; + extras = targetCodec('type=videoProfile&context=streaming&videoCodec=hevc&audioCodec=aac' + + `&protocol=${protocol}`); + extras += addLimitation('scope=videoCodec&scopeName=hevc&type=upperBound' + + '&name=video.bitDepth&value=10&replace=true'); } - return rootGetters['settings/GET_SLPLAYERQUALITY'] - ? `${base}+add-limitation(scope=videoCodec&scopeName=*&type=upperBound&name=video.bitrate&value=${ - rootGetters['settings/GET_SLPLAYERQUALITY']}&replace=true)` - : base; + if (rootGetters['settings/GET_SLPLAYERQUALITY']) { + const quality = rootGetters['settings/GET_SLPLAYERQUALITY']; + extras += addLimitation('scope=videoCodec&scopeName=*&type=upperBound' + + `&name=video.bitrate&value=${quality}&replace=true`); + } + + return extras; }, SHOULD_FORCE_BURN_SUBTITLES: (state, getters) => getters.IS_IN_PICTURE_IN_PICTURE