diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2023-10-22 17:09:52 +0200 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2023-10-22 17:56:04 +0200 |
| commit | 07de1e236f9225ccbebbccedb76036a340837430 (patch) | |
| tree | 2773b469ac832ed2845549408abb87d1357db051 /src | |
| parent | 2414e7db411f9de7ba40cad370d4b195830d4456 (diff) | |
| download | invidious-07de1e236f9225ccbebbccedb76036a340837430.tar.gz invidious-07de1e236f9225ccbebbccedb76036a340837430.tar.bz2 invidious-07de1e236f9225ccbebbccedb76036a340837430.zip | |
Videos: Append '&mpd_version=5' to DASH manifest URL
This makes Youtube return a MPD manifest with templates rather than
lengthy <SegmentList>. The returned manifest is about 44 times smaller.
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/videos.cr | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr index 9fbd1374..a8f02056 100644 --- a/src/invidious/videos.cr +++ b/src/invidious/videos.cr @@ -227,8 +227,22 @@ struct Video info.dig?("streamingData", "hlsManifestUrl").try &.as_s end - def dash_manifest_url - info.dig?("streamingData", "dashManifestUrl").try &.as_s + def dash_manifest_url : String? + raw_dash_url = info.dig?("streamingData", "dashManifestUrl").try &.as_s + return nil if raw_dash_url.nil? + + # Use manifest v5 parameter to reduce file size + # See https://github.com/iv-org/invidious/issues/4186 + dash_url = URI.parse(raw_dash_url) + dash_query = dash_url.query || "" + + if dash_query.empty? + dash_url.path = "#{dash_url.path}/mpd_version/5" + else + dash_url.query = "#{dash_query}&mpd_version=5" + end + + return dash_url.to_s end def genre_url : String? |
