Skip to content

Commit

Permalink
Fix YouTube playlist lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansundin committed Sep 21, 2021
1 parent 4b3d484 commit 25adf9a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@
user = params[:q]
end

if playlist_id
redirect "https://www.youtube.com/feeds/videos.xml" + Addressable::URI.new(query: "playlist_id=#{playlist_id}").normalize.to_s, 301
return
end

if user
channel_id, _ = App::Cache.cache("youtube.user", user.downcase, 60*60, 60) do
response = App::HTTP.get("https://www.youtube.com/#{user}")
Expand Down Expand Up @@ -346,8 +351,6 @@
redirect Addressable::URI.new(path: "/youtube/#{channel_id}/#{username}", query_values: { q: query }.merge(params.slice(:tz))).normalize.to_s, 301
elsif channel_id
redirect "https://www.youtube.com/feeds/videos.xml" + Addressable::URI.new(query: "channel_id=#{channel_id}").normalize.to_s, 301
elsif playlist_id
redirect "https://www.youtube.com/feeds/videos.xml" + Addressable::URI.new(query: "playlist_id=#{playlist_id}").normalize.to_s, 301
else
return [404, "Could not find the channel."]
end
Expand Down

0 comments on commit 25adf9a

Please sign in to comment.