Skip to content

Commit 15fb9ee

Browse files
PikachuEXEefb4f5ff-1298-471a-8973-3d47447115dcabsidue
authored
Local API: Implement SABR for VODs (FreeTubeApp#8047)
* Local API: Implement SABR for VODs * * Allow max 3 player reloads for the same video before fallback to older DASH * ! Fix data type for `playerTimeMs` (googlevideo 4.0.4) * * Update player reload handling to restart player at the current timestamp * * Do not count reload if player is loaded after that * ! Fix access from nullable object * * Remove code for debug only * ! Workaround infinite backoff (mostly at the middle of playback * ! Workaround infinite retry due to nextRequestPolicy (mostly at the middle of playback * ! Fix no audio track selection when SABR used * ! Fix no audio track selection when SABR used with less requests * * Use Math.round instead of Math.trunc for start time / duration like googlevideo repo * * Add requestNumber to SABR URL * ! Fix SABR redirect handling * ! Fix reload sometimes not working * * Reload with less cumulative backoff requested (5 > 3) * * Implement poToken fallback (visitorData bind > videoID bind * ! Fix progress saving run for video reloading in the middle * * Implement proper poToken selection * - Remove accidentially introduced debug code * * skip the call to concatenateChunks if it isn't needed * * Make changes for VS Code * * Update new toast messaages to be translatable * * Enable SABR by default * * Load less data when requesting video data * ! Workaround player stuck at the end on windows Due to duration somehow being slightly longer than what's available * ! Fix null endSegmentIndex handling * ~ Update comment about workaround * ! Fix player stuck at the end of video with shortest duration due to use of duration from first format with format of shorter duration selected for playback * ! Avoid using `player` when it's null (on reload) * ~ Fix type definition * ! Workaround player reload issue * * Make new setting related text translatable & update text * Add support for Voice Boost formats * ! Fix legacy format handling * Fix voice boost being selected as the default audio track --------- Co-authored-by: efb4f5ff-1298-471a-8973-3d47447115dc <73130443+efb4f5ff-1298-471a-8973-3d47447115dc@users.noreply.github.com> Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
1 parent 6cd05c3 commit 15fb9ee

File tree

18 files changed

+3039
-227
lines changed

18 files changed

+3039
-227
lines changed

_scripts/webpack.web.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ const config = {
3131
filename: '[name].js',
3232
},
3333
externals: {
34-
'youtubei.js': '{}'
34+
'youtubei.js': '{}',
35+
googlevideo: '{}'
3536
},
3637
module: {
3738
rules: [
@@ -137,7 +138,7 @@ const config = {
137138
'process.env.SWIPER_VERSION': `'${swiperVersion}'`
138139
}),
139140
new webpack.ProvidePlugin({
140-
process: 'process/browser'
141+
process: 'process/browser.js'
141142
}),
142143
new HtmlWebpackPlugin({
143144
excludeChunks: ['processTaskWorker'],

jsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"target": 3.5
44
},
55
"compilerOptions": {
6+
"module": "esnext",
7+
"moduleResolution": "bundler",
68
"strictNullChecks": true,
79
"baseUrl": "./",
810
"paths": {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"autolinker": "^4.1.5",
6464
"bgutils-js": "^3.2.0",
6565
"electron-context-menu": "^4.1.1",
66+
"googlevideo": "^4.0.4",
6667
"marked": "^17.0.1",
6768
"process": "^0.11.10",
6869
"shaka-player": "^4.16.13",

src/renderer/components/ExperimentalSettings/ExperimentalSettings.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
@change="handleRestartPrompt"
1717
/>
1818
</FtFlexBox>
19+
<FtFlexBox v-if="sabrAllowedOnPlatform">
20+
<FtToggleSwitch
21+
tooltip-position="top"
22+
:label="$t('Settings.SABR.Label')"
23+
compact
24+
:default-value="sabrEnabled"
25+
:tooltip="$t('Settings.SABR.Tooltip')"
26+
@change="updateSabrEnabled"
27+
/>
28+
</FtFlexBox>
1929
<FtPrompt
2030
v-if="showRestartPrompt"
2131
:label="$t('Settings[\'The app needs to restart for changes to take effect. Restart and apply change?\']')"
@@ -27,13 +37,15 @@
2737
</template>
2838

2939
<script setup>
30-
import { onMounted, ref } from 'vue'
40+
import { computed, onMounted, ref } from 'vue'
3141
3242
import FtSettingsSection from '../FtSettingsSection/FtSettingsSection.vue'
3343
import FtFlexBox from '../ft-flex-box/ft-flex-box.vue'
3444
import FtToggleSwitch from '../FtToggleSwitch/FtToggleSwitch.vue'
3545
import FtPrompt from '../FtPrompt/FtPrompt.vue'
3646
47+
import store from '../../store/index'
48+
3749
const replaceHttpCacheLoading = ref(true)
3850
const replaceHttpCache = ref(false)
3951
const showRestartPrompt = ref(false)
@@ -69,6 +81,18 @@ function handleReplaceHttpCache(value) {
6981
window.ftElectron.toggleReplaceHttpCache()
7082
}
7183
}
84+
85+
const sabrAllowedOnPlatform = process.env.SUPPORTS_LOCAL_API
86+
/** @type {import('vue').ComputedRef<boolean>} */
87+
const sabrEnabled = process.env.SUPPORTS_LOCAL_API ? computed(() => store.getters.getSabrEnabled) : false
88+
89+
/**
90+
* @param {boolean} value
91+
*/
92+
function updateSabrEnabled(value) {
93+
store.dispatch('updateSabrEnabled', value)
94+
}
95+
7296
</script>
7397

7498
<style scoped src="./ExperimentalSettings.css" />

0 commit comments

Comments
 (0)