From e47b95ff422ba7194647cb060f5dead425da1457 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Sun, 5 Aug 2018 14:08:39 -0500 Subject: [PATCH] Add fix for parsing videos with 1 view --- src/invidious.cr | 4 ++-- src/invidious/search.cr | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 111f0cbf..a8b9e6d1 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -2279,12 +2279,12 @@ get "/api/v1/channels/:ucid/videos" do |env| if metadata.size == 0 next elsif metadata.size == 1 - view_count = metadata[0].content.rchop(" watching").delete(",").to_i64 + view_count = metadata[0].content.split(" ")[0].delete(",").to_i64 published = Time.now else published = decode_date(metadata[0].content) - view_count = metadata[1].content.rchop(" views") + view_count = metadata[1].content.split(" ")[0] if view_count == "No" view_count = 0_i64 else diff --git a/src/invidious/search.cr b/src/invidious/search.cr index 847a38e4..08c8d100 100644 --- a/src/invidious/search.cr +++ b/src/invidious/search.cr @@ -44,12 +44,12 @@ def search(query, page = 1, search_params = build_search_params(content_type: "v if metadata.size == 0 next elsif metadata.size == 1 - view_count = metadata[0].content.rchop(" watching").delete(",").to_i64 + view_count = metadata[0].content.split(" ")[0].delete(",").to_i64 published = Time.now else published = decode_date(metadata[0].content) - view_count = metadata[1].content.rchop(" views") + view_count = metadata[1].content.split(" ")[0] if view_count == "No" view_count = 0_i64 else