diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-09-12 13:06:27 -0400 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-09-12 13:06:27 -0400 |
| commit | 34c43b83496a525560b589754a386905d9371782 (patch) | |
| tree | 6cfbdfd49db071ecfe7e48fdbc7e7be827eb9894 /src | |
| parent | 7002a316fd29c68e05fe28dbf359f5612351ba69 (diff) | |
| download | invidious-34c43b83496a525560b589754a386905d9371782.tar.gz invidious-34c43b83496a525560b589754a386905d9371782.tar.bz2 invidious-34c43b83496a525560b589754a386905d9371782.zip | |
Add support for abbreviated sub count in search
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/helpers.cr | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/invidious/helpers/helpers.cr b/src/invidious/helpers/helpers.cr index 331f6360..bd9d0b4e 100644 --- a/src/invidious/helpers/helpers.cr +++ b/src/invidious/helpers/helpers.cr @@ -415,7 +415,12 @@ 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"].gsub(/\D/, "").to_i? + subscriber_count_text = node.xpath_node(%q(.//span[contains(@class, "yt-subscriber-count")])).try &.["title"] + begin + subscriber_count = subscriber_count_text.try { |text| short_text_to_number(text) } + rescue ex + subscriber_count = subscriber_count_text.try &.gsub(/\D/, "").to_i? + end subscriber_count ||= 0 video_count = node.xpath_node(%q(.//ul[@class="yt-lockup-meta-info"]/li)).try &.content.split(" ")[0].gsub(/\D/, "").to_i? |
