diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-09-23 12:26:12 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-09-23 12:26:12 -0500 |
| commit | 1d9c6f63e1f423c8a4421acbbc5a5541f88b572d (patch) | |
| tree | cc656d37e45ac47de0762ad4cec08b165947a90e | |
| parent | 5bdd8327d4c5d8ea4960480911f713dfd56800ad (diff) | |
| download | invidious-1d9c6f63e1f423c8a4421acbbc5a5541f88b572d.tar.gz invidious-1d9c6f63e1f423c8a4421acbbc5a5541f88b572d.tar.bz2 invidious-1d9c6f63e1f423c8a4421acbbc5a5541f88b572d.zip | |
Add better error for invalid playlists
| -rw-r--r-- | src/invidious.cr | 7 | ||||
| -rw-r--r-- | src/invidious/playlists.cr | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 2e599864..bc85bb74 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -390,9 +390,8 @@ get "/playlist" do |env| page = env.params.query["page"]?.try &.to_i? page ||= 1 - playlist = fetch_playlist(plid) - begin + playlist = fetch_playlist(plid) videos = fetch_playlist_videos(plid, page, playlist.video_count) rescue ex error_message = ex.message @@ -2823,9 +2822,9 @@ get "/api/v1/playlists/:plid" do |env| page = env.params.query["page"]?.try &.to_i? page ||= 1 - playlist = fetch_playlist(plid) - + begin + playlist = fetch_playlist(plid) videos = fetch_playlist_videos(plid, page, playlist.video_count) rescue ex error_message = {"error" => "Playlist is empty"}.to_json diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr index 6afb7a79..e14a7709 100644 --- a/src/invidious/playlists.cr +++ b/src/invidious/playlists.cr @@ -142,6 +142,10 @@ def fetch_playlist(plid) end response = client.get("/playlist?list=#{plid}&disable_polymer=1") + if response.status_code != 200 + raise "Invalid playlist." + end + body = response.body.gsub(<<-END_BUTTON <button class="yt-uix-button yt-uix-button-size-default yt-uix-button-link yt-uix-expander-head playlist-description-expander yt-uix-inlineedit-ignore-edit" type="button" onclick=";return false;"><span class="yt-uix-button-content"> less <img alt="" src="/yts/img/pixel-vfl3z5WfW.gif"> </span></button> |
