Skip to content

Commit

Permalink
Invidious API: Extract streaming data expiry date from URL (FreeTubeA…
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored and Alban Dumas committed Jan 24, 2025
1 parent dfe64e0 commit 1d1221b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,8 @@ export default defineComponent({
// // https://github.com/iv-org/invidious/pull/4589
// if (this.proxyVideos) {

this.streamingDataExpiryDate = this.extractExpiryDateFromStreamingUrl(result.adaptiveFormats[0].url)

let hlsManifestUrl = result.hlsUrl

if (this.proxyVideos) {
Expand Down Expand Up @@ -876,6 +878,8 @@ export default defineComponent({
} else {
this.videoLengthSeconds = result.lengthSeconds

this.streamingDataExpiryDate = this.extractExpiryDateFromStreamingUrl(result.adaptiveFormats[0].url)

this.legacyFormats = result.formatStreams.map(mapInvidiousLegacyFormat)

if (!process.env.SUPPORTS_LOCAL_API || this.proxyVideos) {
Expand Down Expand Up @@ -945,6 +949,12 @@ export default defineComponent({
})
},

extractExpiryDateFromStreamingUrl: function (url) {
const expireString = new URL(url).searchParams.get('expire')

return new Date(parseInt(expireString) * 1000)
},

/**
* @param {string} description
*/
Expand Down

0 comments on commit 1d1221b

Please sign in to comment.