diff options
| author | Omar Roth <omarroth@hotmail.com> | 2019-04-25 12:41:35 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2019-04-25 12:41:35 -0500 |
| commit | 8c2958b86d0952c176c1df83f2cbaa9adce5e59f (patch) | |
| tree | fa3e7c29264347c3d8dcfb7920cf637d8f36e1a9 /src | |
| parent | f15b7cebac9d9383340a33f4f091badc5d07d2ca (diff) | |
| download | invidious-8c2958b86d0952c176c1df83f2cbaa9adce5e59f.tar.gz invidious-8c2958b86d0952c176c1df83f2cbaa9adce5e59f.tar.bz2 invidious-8c2958b86d0952c176c1df83f2cbaa9adce5e59f.zip | |
Add 'local=true' to hlsUrl
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 29 | ||||
| -rw-r--r-- | src/invidious/views/components/player.ecr | 2 |
2 files changed, 24 insertions, 7 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 2fe2fb42..cf263635 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -4602,13 +4602,21 @@ get "/api/manifest/hls_variant/*" do |env| next end + local = env.params.query["local"]?.try &.== "true" + env.response.content_type = "application/x-mpegURL" env.response.headers.add("Access-Control-Allow-Origin", "*") host_url = make_host_url(config, Kemal.config) manifest = manifest.body - manifest.gsub("https://www.youtube.com", host_url) + + if local + manifest = manifest.gsub("https://www.youtube.com", host_url) + manifest = manifest.gsub("index.m3u8", "index.m3u8?local=true") + end + + manifest end get "/api/manifest/hls_playlist/*" do |env| @@ -4620,15 +4628,24 @@ get "/api/manifest/hls_playlist/*" do |env| next end + local = env.params.query["local"]?.try &.== "true" + + env.response.content_type = "application/x-mpegURL" + env.response.headers.add("Access-Control-Allow-Origin", "*") + host_url = make_host_url(config, Kemal.config) - manifest = manifest.body.gsub("https://www.youtube.com", host_url) - manifest = manifest.gsub(/https:\/\/r\d---.{11}\.c\.youtube\.com/, host_url) - fvip = manifest.match(/hls_chunk_host\/r(?<fvip>\d)---/).not_nil!["fvip"] + manifest = manifest.body + + if local + manifest = manifest.gsub("https://www.youtube.com", host_url) + manifest = manifest.gsub(/https:\/\/r\d---.{11}\.c\.youtube\.com/, host_url) + manifest = manifest.gsub("seg.ts", "seg.ts?local=true") + end + + fvip = manifest.match(/hls_chunk_host\/r(?<fvip>\d+)---/).not_nil!["fvip"] manifest = manifest.gsub("seg.ts", "seg.ts/fvip/#{fvip}") - env.response.content_type = "application/x-mpegURL" - env.response.headers.add("Access-Control-Allow-Origin", "*") manifest end diff --git a/src/invidious/views/components/player.ecr b/src/invidious/views/components/player.ecr index 30f5294f..bdcf999e 100644 --- a/src/invidious/views/components/player.ecr +++ b/src/invidious/views/components/player.ecr @@ -7,7 +7,7 @@ <% if params[:video_loop] %>loop<% end %> <% if params[:controls] %>controls<% end %>> <% if hlsvp %> - <source src="<%= hlsvp %>" type="application/x-mpegURL" label="livestream"> + <source src="<%= hlsvp %>?local=true" type="application/x-mpegURL" label="livestream"> <% else %> <% if params[:listen] %> <% audio_streams.each_with_index do |fmt, i| %> |
