diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-07-25 10:34:01 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-07-25 10:36:35 -0500 |
| commit | cfe9d47fa000bb7ba1add20ef41408c19e0df33d (patch) | |
| tree | 94c0c4536a900d3dd33a3eb13e3910bcb7c7ae37 /src/invidious.cr | |
| parent | 607d6125fc50839115edd856e2862e5ccdcf3085 (diff) | |
| download | invidious-cfe9d47fa000bb7ba1add20ef41408c19e0df33d.tar.gz invidious-cfe9d47fa000bb7ba1add20ef41408c19e0df33d.tar.bz2 invidious-cfe9d47fa000bb7ba1add20ef41408c19e0df33d.zip | |
Add support for '/embed/?list'
Diffstat (limited to 'src/invidious.cr')
| -rw-r--r-- | src/invidious.cr | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index a3b5bd1a..835cffc7 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -532,6 +532,30 @@ get "/watch" do |env| templated "watch" end +get "/embed/" do |env| + locale = LOCALES[env.get("preferences").as(Preferences).locale]? + + if plid = env.params.query["list"]? + begin + videos = fetch_playlist_videos(plid, 1, 1, locale: locale) + rescue ex + error_message = ex.message + env.response.status_code = 500 + next templated "error" + end + + url = "/embed/#{videos[0].id}?#{env.params.query}" + + if env.params.query.size > 0 + url += "?#{env.params.query}" + end + else + url = "/" + end + + env.redirect url +end + get "/embed/:id" do |env| locale = LOCALES[env.get("preferences").as(Preferences).locale]? id = env.params.url["id"] |
