diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-12-05 15:46:21 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-12-05 15:46:21 -0500 |
| commit | 513363504f28d32c9bfb0d325296701f660b766a (patch) | |
| tree | e5105da2130470928a10934c558c105b6c9afecc /src | |
| parent | 0e844edacb45c803d5142bf63d35000fbbefce8d (diff) | |
| download | invidious-513363504f28d32c9bfb0d325296701f660b766a.tar.gz invidious-513363504f28d32c9bfb0d325296701f660b766a.tar.bz2 invidious-513363504f28d32c9bfb0d325296701f660b766a.zip | |
Add better error message for fetch_channel
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/channels.cr | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index 10e826e5..ccb87d6f 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -215,7 +215,17 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil) url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated) response = YT_POOL.client &.get(url) - json = JSON.parse(response.body) + + begin + json = JSON.parse(response.body) + rescue ex + if response.body.includes?("To continue with your YouTube experience, please fill out the form below.") || + response.body.includes?("https://www.google.com/sorry/index") + raise "Could not extract channel info. Instance is likely blocked." + end + + raise "Could not extract JSON" + end if json["content_html"]? && !json["content_html"].as_s.empty? document = XML.parse_html(json["content_html"].as_s) |
