|
|
@ -2133,14 +2133,13 @@ get "/api/v1/annotations/:id" do |env|
|
|
|
|
|
|
|
|
|
|
|
|
file = URI.encode_www_form("#{id[0, 3]}/#{id}.xml")
|
|
|
|
file = URI.encode_www_form("#{id[0, 3]}/#{id}.xml")
|
|
|
|
|
|
|
|
|
|
|
|
client = make_client(ARCHIVE_URL)
|
|
|
|
location = make_client(ARCHIVE_URL, &.get("/download/youtubeannotations_#{index}/#{id[0, 2]}.tar/#{file}"))
|
|
|
|
location = client.get("/download/youtubeannotations_#{index}/#{id[0, 2]}.tar/#{file}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !location.headers["Location"]?
|
|
|
|
if !location.headers["Location"]?
|
|
|
|
env.response.status_code = location.status_code
|
|
|
|
env.response.status_code = location.status_code
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
response = make_client(URI.parse(location.headers["Location"])).get(location.headers["Location"])
|
|
|
|
response = make_client(URI.parse(location.headers["Location"]), &.get(location.headers["Location"]))
|
|
|
|
|
|
|
|
|
|
|
|
if response.body.empty?
|
|
|
|
if response.body.empty?
|
|
|
|
env.response.status_code = 404
|
|
|
|
env.response.status_code = 404
|
|
|
@ -3498,8 +3497,12 @@ get "/videoplayback" do |env|
|
|
|
|
location = URI.parse(response.headers["Location"])
|
|
|
|
location = URI.parse(response.headers["Location"])
|
|
|
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
|
|
|
env.response.headers["Access-Control-Allow-Origin"] = "*"
|
|
|
|
|
|
|
|
|
|
|
|
host = "#{location.scheme}://#{location.host}"
|
|
|
|
new_host = "#{location.scheme}://#{location.host}"
|
|
|
|
client = make_client(URI.parse(host), region)
|
|
|
|
if new_host != host
|
|
|
|
|
|
|
|
host = new_host
|
|
|
|
|
|
|
|
client.close
|
|
|
|
|
|
|
|
client = make_client(URI.parse(new_host), region)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
url = "#{location.full_path}&host=#{location.host}#{region ? "®ion=#{region}" : ""}"
|
|
|
|
url = "#{location.full_path}&host=#{location.host}#{region ? "®ion=#{region}" : ""}"
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -3530,7 +3533,6 @@ get "/videoplayback" do |env|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
client = make_client(URI.parse(host), region)
|
|
|
|
|
|
|
|
client.get(url, headers) do |response|
|
|
|
|
client.get(url, headers) do |response|
|
|
|
|
response.headers.each do |key, value|
|
|
|
|
response.headers.each do |key, value|
|
|
|
|
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
|
|
|
if !RESPONSE_HEADERS_BLACKLIST.includes?(key.downcase)
|
|
|
@ -3571,8 +3573,6 @@ get "/videoplayback" do |env|
|
|
|
|
chunk_end = chunk_start + HTTP_CHUNK_SIZE - 1
|
|
|
|
chunk_end = chunk_start + HTTP_CHUNK_SIZE - 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
client = make_client(URI.parse(host), region)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Record bytes written so we can restart after a chunk fails
|
|
|
|
# TODO: Record bytes written so we can restart after a chunk fails
|
|
|
|
while true
|
|
|
|
while true
|
|
|
|
if !range_end && content_length
|
|
|
|
if !range_end && content_length
|
|
|
@ -3636,6 +3636,7 @@ get "/videoplayback" do |env|
|
|
|
|
if ex.message != "Error reading socket: Connection reset by peer"
|
|
|
|
if ex.message != "Error reading socket: Connection reset by peer"
|
|
|
|
break
|
|
|
|
break
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
client.close
|
|
|
|
client = make_client(URI.parse(host), region)
|
|
|
|
client = make_client(URI.parse(host), region)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -3645,6 +3646,7 @@ get "/videoplayback" do |env|
|
|
|
|
first_chunk = false
|
|
|
|
first_chunk = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
client.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
get "/ggpht/*" do |env|
|
|
|
|
get "/ggpht/*" do |env|
|
|
|
|