FreeTube/_scripts/getShakaLocales.js

111 lines
3.0 KiB
JavaScript
Raw Normal View History

Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
const { readFileSync, readdirSync } = require('fs')
2025-05-10 14:36:50 +02:00
const { join } = require('path')
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
function getPreloadedLocales() {
2025-05-10 14:36:50 +02:00
const localesFile = readFileSync(join(__dirname, '../node_modules/shaka-player/dist/locales.js'), 'utf-8')
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
const localesLine = localesFile.match(/^\/\/ LOCALES: ([\w ,-]+)$/m)
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
if (!localesLine) {
throw new Error("Failed to parse shaka-player's preloaded locales")
}
return localesLine[1].split(',').map(locale => locale.trim())
}
function getAllLocales() {
2025-05-10 14:36:50 +02:00
const filenames = readdirSync(join(__dirname, '../node_modules/shaka-player/ui/locales'))
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
return new Set(filenames
.filter(filename => filename !== 'source.json' && filename.endsWith('.json'))
.map(filename => filename.replace('.json', '')))
}
/**
* Maps the shaka locales to FreeTube's active ones
* This allows us to know which locale files are actually needed
* and which shaka locale needs to be activated for a given FreeTube one.
* @param {Set<string>} shakaLocales
* @param {string[]} freeTubeLocales
*/
function getMappings(shakaLocales, freeTubeLocales) {
/**
* @type {[string, string][]}
* Using this structure as it gets passed to `new Map()` in the player component
* The first element is the FreeTube locale, the second one is the shaka-player one
*/
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
const mappings = []
for (const locale of freeTubeLocales) {
if (shakaLocales.has(locale)) {
mappings.push([
locale,
locale
])
} else if (shakaLocales.has(locale.split('-')[0])) {
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
mappings.push([
locale,
locale.split('-')[0]
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
])
}
}
// special cases
mappings.push(
// according to https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
// "no" is the macro language for "nb" and "nn"
[
'nb-NO',
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
'no'
],
[
'nn',
'no'
],
// according to https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
// "iw" is the old/original code for Hebrew, these days it's "he"
[
'he',
'iw'
],
// not sure why we have pt, pt-PT and pt-BR in the FreeTube locales
// as pt and pt-PT are the same thing, but we should handle it here anyway
[
'pt',
'pt-PT'
]
)
return mappings
}
function getShakaLocales() {
const shakaLocales = getAllLocales()
/** @type {string[]} */
2025-05-10 14:36:50 +02:00
const freeTubeLocales = JSON.parse(readFileSync(join(__dirname, '../static/locales/activeLocales.json'), 'utf-8'))
Migrate video player from video.js to shaka-player (#4978) * Migrate video player from video.js to shaka-player * Fix syntax error introduced during cleanup * Fix typo Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Show bitrate in stats for Invidious legacy formats * Sort legacy formats by bitrate instead of qualityLabel * Use Invidious' newly added isPostLiveDvr property * Invidious correctly returns the ratelimit for DASH manifests now * Properly hide unsupported screenshot functionality outside of Electron * Sort captions in data initialiser * Update shaka-player to version 4.8.1 * Use textTrackLabelFormat configuration option * Switch to manifestPreprocessorTXml * Add support for VR videos that use equirectangular projection * The AV1 video streams work okay for vr, so allow list them too * Use woff2 (169 KB) Material Icons font instead of otf (390 KB) * Use material icons for custom player elements * Fix legacy formats exception * Update shaka-player to version 4.8.3 * Sort default quality values the same as in the player * Cleanup representations search in live subtitle fix * Slightly speed up sortCaptions * Fix setPositionState error when playback rate is 0 * Update shaka-player to version 4.8.4 * Fix playback rate changes getting overridden * Fix current chapter index not updating * Fix next video not automatically playing * Fix volume changes not propagating to the mute button * Reduce work done during UI config updates * Fix UI customizations not applying after UI config changes * Update shaka-player to version 4.8.5 * Replace non-reactive workaround with a Vue 3 friendly one * Fix error when all sponsorblock segments are set to do nothing * Add some guards to hopefully reduce errors during fast naviagtions * Make SponsorBlock failure non-fatal * Update shaka-player to version 4.8.6 * Update shaka-player to version 4.8.8 * Update shaka-player to version 4.9.0 * Update shaka-player to version 4.9.1 * Minor performance improvements * Update shaka-player to version 4.9.6 * Update shaka-player to version 4.9.9 * Fix sponsor block markers not showing up * Add some basic error messages for expired urls and ratelimits * Add some basic error messages for 403s * Cleanup code comments * Migrate player to composition API for better performance * Use reactive for stats instead of ref, as it never gets reassigned * Update shaka-player to version 4.10.0 * Fix i18n import in custom player components * Add chapter markers * Move shaka-player CSS import into the Vue file * Bump mpd_version from 5 to 7 * Apply suggestions from code review Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> * Fix seeking with the arrow keys * Update shaka-player to version 4.10.3 * Truncate long video titles to the screen width in the full screen overlay * Fix mouse scroll handlers firing multiple times * Cleanup unneeded code * Update shaka-player to version 4.10.6 * Various small optimisations * Move skipped sponsorblock segement messages to the top right corner * Support prefers-reduced-transparency in overlays * Fix stylelint errors * Update shaka-player to version 4.10.7 * Update shaka-player to version 4.10.8 * Only use variants that are predicted to play smoothly * Only set preferredDecodingAttributes for DASH playback * Implement a custom audio track selector instead of using shaka-player's * Move skipped sponsorblock segement messages to the bottom right corner * Fix scrolling over the big play pause button not working * Update shaka-player to version 4.10.9 * Fix some type issues * Add support for secondary audio tracks * Downgrade shaka-player to fix subtitle alignment * Actually downgrade shaka-player * Fix Invidious API error * Update outdated comment * Fix multiple audio track detection for Invidious * Fix duplicate qualities with the Invidious API * Use vp9 streams if the Invidious instance is running a new enough version * When an error occurs with the thumbnails just log it * Include the video ID in the error logs * Gracefully handle the internet connection disappearing during playback * Show a message while buffering if it was caused by the internet connection disappearing * Fix the text color and RTL handling * Cleanup the Invidious DASH manifest in builds without the local API * Fix quality selection when switching from audio to DASH Unfortunately shaka-player will still override the quality selections with its ABR bug. * Update shaka-player to version 4.10.10 * Fix position and alignment for auto-generated subtitles * Update shaka-player to version 4.10.11 * Use the HLS manifests for live streams The live DASH manifests are currently unusable on both API backends as they return 403s after 1 minute of playback. Unfortunately this means we lose the ability to seek and use the audio formats for live streams. * Update shaka-player to version 4.10.12 --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
2024-09-02 21:40:42 +02:00
const mappings = getMappings(shakaLocales, freeTubeLocales)
const preloaded = getPreloadedLocales()
const shakaMappings = mappings.map(mapping => mapping[1])
// use a set to deduplicate the list
// we don't need to bundle any locale files that are already embedded in shaka-player/preloaded
/** @type {string[]} */
const toBeBundled = [...new Set(shakaMappings.filter(locale => !preloaded.includes(locale)))]
return {
SHAKA_LOCALE_MAPPINGS: mappings,
SHAKA_LOCALES_PREBUNDLED: preloaded,
SHAKA_LOCALES_TO_BE_BUNDLED: toBeBundled
}
}
module.exports = getShakaLocales()