summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-08-22 11:06:31 -0500
committerOmar Roth <omarroth@hotmail.com>2018-08-22 11:06:31 -0500
commit01a80995d3ebfc0edd18d3d27de22adf3595e8be (patch)
treea3a1012cccabf920eb58472002b166a33d50ddab /src
parent76d3abb5f90dc513e30c996f0d11ba0f8c963bb8 (diff)
downloadinvidious-01a80995d3ebfc0edd18d3d27de22adf3595e8be.tar.gz
invidious-01a80995d3ebfc0edd18d3d27de22adf3595e8be.tar.bz2
invidious-01a80995d3ebfc0edd18d3d27de22adf3595e8be.zip
Add fix for channel endpoint where channel has no subscribers
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index cc8edf0a..e36f28f1 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -2170,10 +2170,16 @@ get "/api/v1/channels/:ucid" do |env|
is_family_friendly = channel_html.xpath_node(%q(//meta[@itemprop="isFamilyFriendly"])).not_nil!["content"] == "True"
allowed_regions = channel_html.xpath_node(%q(//meta[@itemprop="regionsAllowed"])).not_nil!["content"].split(",")
- sub_count, total_views, joined = channel_html.xpath_nodes(%q(//span[@class="about-stat"]))
- sub_count = sub_count.content.rchop(" subscribers").delete(",").to_i64
- total_views = total_views.content.rchop(" views").lchop(" • ").delete(",").to_i64
- joined = Time.parse(joined.content.lchop("Joined "), "%b %-d, %Y", Time::Location.local)
+ anchor = channel_html.xpath_nodes(%q(//span[@class="about-stat"]))
+ if anchor[0].content.includes? "views"
+ sub_count = 0
+ total_views = anchor[0].content.delete("views •,").to_i64
+ joined = Time.parse(anchor[1].content.lchop("Joined "), "%b %-d, %Y", Time::Location.local)
+ else
+ sub_count = anchor[0].content.delete("subscribers").delete(",").to_i64
+ total_views = anchor[1].content.delete("views •,").to_i64
+ joined = Time.parse(anchor[2].content.lchop("Joined "), "%b %-d, %Y", Time::Location.local)
+ end
latest_videos = PG_DB.query_all("SELECT * FROM channel_videos WHERE ucid = $1 ORDER BY published DESC LIMIT 15",
channel.id, as: ChannelVideo)
translation Update German translation Update Serbian (cyrillic) translation Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Jose Delvani <delvani.eletricista@gmail.com> Co-authored-by: Least Significant Bite <leastsignificantbite@proton.me> Co-authored-by: NEXI <nexiphotographer@gmail.com> Co-authored-by: Radoslav Lelchev <rlelchev@abv.bg> Co-authored-by: Random <random-r@users.noreply.hosted.weblate.org> Co-authored-by: Unacceptium <unacceptium@proton.me> Co-authored-by: hiatsu0 <hietsu@gmail.com> 2024-08-13Update Serbian (cyrillic) translationHosted Weblate Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Update Serbian (cyrillic) translation Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Update Serbian (cyrillic) translation Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Update Serbian (cyrillic) translation Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Update Serbian (cyrillic) translation Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Update Bulgarian translation Update German translation Update Serbian (cyrillic) translation Update Serbian translation Update Finnish translation Update Italian translation Update Hungarian translation Update Portuguese (Brazil) translation Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Jose Delvani <delvani.eletricista@gmail.com> Co-authored-by: Least Significant Bite <leastsignificantbite@proton.me> Co-authored-by: NEXI <nexiphotographer@gmail.com> Co-authored-by: Radoslav Lelchev <rlelchev@abv.bg> Co-authored-by: Random <random-r@users.noreply.hosted.weblate.org> Co-authored-by: Unacceptium <unacceptium@proton.me> Co-authored-by: hiatsu0 <hietsu@gmail.com> 2024-08-13use docker compose instead of docker-compose for CIEmilien Devos 2024-07-28Remove unused methods in `Invidious::LogHandler`syeopite 2024-07-25Ameba: Fix Naming/PredicateNamesyeopite 2024-07-24Ameba: Fix Naming/MethodNamessyeopite 2024-07-24Ameba: Fix Lint/HashDuplicatedKeysyeopite 2024-07-24Ameba: Fix Lint/UnusedBlockArgumentsyeopite 2024-07-24Ameba: Fix Lint/UnusedArgumentsyeopite 2024-07-24Ameba: undo Lint/NotNilAfterNoBang in signatures.crsyeopite File is set to be removed with #4772 2024-07-17Exclude spec/parsers_helper from Lint/SpecFilenamesyeopite False positive 2024-07-17Ameba: Fix Lint/UselessAssignsyeopite 2024-07-17Ameba: Disable Naming/BlockParameterNamesyeopite 2024-07-15Ameba: Fix Lint/NotNilAfterNoBangsyeopite 2024-07-11Disable Naming/AccessorMethodName rulesyeopite Most cases of Naming/AccessorMethodName are false positives 2024-07-11Disable Documentation/DocumentationAdmonition rulesyeopite 2024-07-11Fix typosyeopite 2024-07-09Channel: parse subscriber count and channel bannerChunkyProgrammer 2024-07-04Typosyeopite Co-authored-by: Samantaz Fox <coding@samantaz.fr> 2024-07-04Bump nightly container build workflow crystal versyeopite 2024-07-01Fix trigger for stable container buildsyeopite 2024-07-01Rename container workflowssyeopite