From 8cecce75707a31f9aa31d5ecbdb2999afd2dae70 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sat, 1 Jun 2019 16:26:18 -0500 Subject: [PATCH] Fix audio mode for raw URLs --- src/invidious.cr | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 86df1775..3d69cef1 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -470,11 +470,23 @@ get "/watch" do |env| thumbnail = "/vi/#{video.id}/maxres.jpg" if params.raw - url = fmt_stream[0]["url"] + if params.listen + url = audio_streams[0]["url"] - fmt_stream.each do |fmt| - if fmt["label"].split(" - ")[0] == params.quality - url = fmt["url"] + audio_streams.each do |fmt| + pp fmt["bitrate"] + pp params.quality.rchop("k") + if fmt["bitrate"] == params.quality.rchop("k") + url = fmt["url"] + end + end + else + url = fmt_stream[0]["url"] + + fmt_stream.each do |fmt| + if fmt["label"].split(" - ")[0] == params.quality + url = fmt["url"] + end end end