summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-04-12 16:37:35 -0500
committerOmar Roth <omarroth@hotmail.com>2019-04-12 16:37:35 -0500
commit80a567bf1ecaa4dc141294c426bf0a92638a1fd1 (patch)
tree81035eb8109a3900cf0e837e82cf66983eab0d4f
parentce2a3361eb906ea94981169a3b36d1848dfdee29 (diff)
downloadinvidious-80a567bf1ecaa4dc141294c426bf0a92638a1fd1.tar.gz
invidious-80a567bf1ecaa4dc141294c426bf0a92638a1fd1.tar.bz2
invidious-80a567bf1ecaa4dc141294c426bf0a92638a1fd1.zip
Fix video count in playlist extractor
-rw-r--r--src/invidious/helpers/helpers.cr8
-rw-r--r--src/invidious/playlists.cr2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr
index 574f1184..a2ea9f7a 100644
--- a/src/invidious/helpers/helpers.cr
+++ b/src/invidious/helpers/helpers.cr
@@ -241,7 +241,7 @@ def extract_items(nodeset, ucid = nil, author_name = nil)
video_count = video_count.rchop("+")
end
- video_count = video_count.to_i?
+ video_count = video_count.gsub(/\D/, "").to_i?
end
video_count ||= 0
@@ -301,10 +301,10 @@ def extract_items(nodeset, ucid = nil, author_name = nil)
author_thumbnail ||= ""
- subscriber_count = node.xpath_node(%q(.//span[contains(@class, "yt-subscriber-count")])).try &.["title"].delete(",").to_i?
+ subscriber_count = node.xpath_node(%q(.//span[contains(@class, "yt-subscriber-count")])).try &.["title"].gsub(/\D/, "").to_i?
subscriber_count ||= 0
- video_count = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li)).try &.content.split(" ")[0].delete(",").to_i?
+ video_count = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li)).try &.content.split(" ")[0].gsub(/\D/, "").to_i?
video_count ||= 0
items << SearchChannel.new(
@@ -466,7 +466,7 @@ def extract_shelf_items(nodeset, ucid = nil, author_name = nil)
video_count_label = child_node.xpath_node(%q(.//span[@class="formatted-video-count-label"]))
if video_count_label
- video_count = video_count_label.content.strip.match(/^\d+/).try &.[0].to_i?
+ video_count = video_count_label.content.gsub(/\D/, "").to_i?
end
video_count ||= 50
diff --git a/src/invidious/playlists.cr b/src/invidious/playlists.cr
index d04a5942..73c9ac69 100644
--- a/src/invidious/playlists.cr
+++ b/src/invidious/playlists.cr
@@ -196,7 +196,7 @@ def fetch_playlist(plid, locale)
author_thumbnail ||= ""
ucid = anchor.xpath_node(%q(.//li[1]/a)).not_nil!["href"].split("/")[-1]
- video_count = anchor.xpath_node(%q(.//li[2])).not_nil!.content.delete("videos, ").to_i
+ video_count = anchor.xpath_node(%q(.//li[2])).not_nil!.content.gsub(/\D/, "").to_i
views = anchor.xpath_node(%q(.//li[3])).not_nil!.content.delete("No views, ")
if views.empty?
views = 0_i64