Skip to content

Commit

Permalink
Add workaround for invidious legacy format issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MarmadileManteater committed Mar 7, 2023
1 parent 8c58028 commit 5a0e392
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/renderer/views/Watch/Watch.js
Expand Up @@ -306,7 +306,17 @@ export default defineComponent({

try {
let result = await getLocalVideoInfo(this.videoId)

// if we need to proxy videos through invidious
if (!process.env.IS_ELECTRON || this.proxyVideos) {
result.streaming_data.formats = result.streaming_data.formats.map(format => {
return {
...format,
// hacky af, but this technically gets past a very recent issue with invidious servers
// not honouring the `&local=true` flag
url: `${this.currentInvidiousInstance}/${format.url.split('.googlevideo.com/')[1]}`
}
})
}
this.isFamilyFriendly = result.basic_info.is_family_safe

this.recommendedVideos = result.watch_next_feed
Expand Down Expand Up @@ -490,7 +500,6 @@ export default defineComponent({
this.showLegacyPlayer = true
this.showDashPlayer = false
this.activeFormat = 'legacy'
this.activeSourceList = this.videoSourceList
} else if (this.isUpcoming) {
const upcomingTimestamp = result.basic_info.start_timestamp

Expand Down Expand Up @@ -550,6 +559,7 @@ export default defineComponent({
} else {
this.videoSourceList = filterFormats(result.streaming_data.adaptive_formats, this.allowDashAv1Formats).map(mapLocalFormat).reverse()
}

this.adaptiveFormats = this.videoSourceList

const formats = [...result.streaming_data.formats, ...result.streaming_data.adaptive_formats]
Expand Down Expand Up @@ -1113,6 +1123,20 @@ export default defineComponent({

const watchedProgress = this.getWatchedProgress()
this.activeFormat = 'legacy'
// if we need to proxy videos through invidious
if (!process.env.IS_ELECTRON || this.proxyVideos) {
this.videoSourceList = this.videoSourceList.map(format => {
if (format.url.indexOf('.googlevideo.com/') === -1) {
return format
}
return {
...format,
// hacky af, but this technically gets past a very recent issue with invidious servers
// not honouring the `&local=true` flag
url: `${this.currentInvidiousInstance}/${format.url.split('.googlevideo.com/')[1]}`
}
})
}
this.activeSourceList = this.videoSourceList
this.hidePlayer = true

Expand Down

0 comments on commit 5a0e392

Please sign in to comment.