From 16fb5023e0deeea862349c9942ca31e3de416d18 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 13 Aug 2018 10:50:09 -0500 Subject: [PATCH] Add fix for videos without 'rvs' --- src/invidious.cr | 8 +++----- src/invidious/jobs.cr | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 949b6678..2c1c98bc 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -257,10 +257,8 @@ get "/watch" do |env| end rvs = [] of Hash(String, String) - if video.info.has_key?("rvs") - video.info["rvs"].split(",").each do |rv| - rvs << HTTP::Params.parse(rv).to_h - end + video.info["rvs"]?.try &.split(",").each do |rv| + rvs << HTTP::Params.parse(rv).to_h end rating = video.info["avg_rating"].to_f64 @@ -2007,7 +2005,7 @@ get "/api/v1/videos/:id" do |env| json.field "recommendedVideos" do json.array do - video.info["rvs"].split(",").each do |rv| + video.info["rvs"]?.try &.split(",").each do |rv| rv = HTTP::Params.parse(rv) if rv["id"]? diff --git a/src/invidious/jobs.cr b/src/invidious/jobs.cr index b74bcaf2..a85244a3 100644 --- a/src/invidious/jobs.cr +++ b/src/invidious/jobs.cr @@ -24,10 +24,8 @@ def crawl_videos(db) end rvs = [] of Hash(String, String) - if video.info.has_key?("rvs") - video.info["rvs"].split(",").each do |rv| - rvs << HTTP::Params.parse(rv).to_h - end + video.info["rvs"]?.try &.split(",").each do |rv| + rvs << HTTP::Params.parse(rv).to_h end rvs.each do |rv|