diff options
| author | Perflyst <mail@perflyst.de> | 2020-12-28 11:30:55 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-28 11:30:55 +0100 |
| commit | b19524d56a49c01ec72deb33bfb423ac25721ffc (patch) | |
| tree | d926ce6b61b7324475f3950ef7e09c5ba5e30f5e /src/invidious.cr | |
| parent | eeeecf9763bc0ee0f34b87e67c7ce02d431a4b84 (diff) | |
| parent | 198dfffaeb91c03889440a9f8141657bd53734d6 (diff) | |
| download | invidious-b19524d56a49c01ec72deb33bfb423ac25721ffc.tar.gz invidious-b19524d56a49c01ec72deb33bfb423ac25721ffc.tar.bz2 invidious-b19524d56a49c01ec72deb33bfb423ac25721ffc.zip | |
Merge pull request #1609 from saltycrys/add-popular-enabled-option
Add `popular-enabled` option
Diffstat (limited to 'src/invidious.cr')
| -rw-r--r-- | src/invidious.cr | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 91798129..1b8be67e 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -168,13 +168,16 @@ end Invidious::Jobs.register Invidious::Jobs::RefreshChannelsJob.new(PG_DB, logger, config) Invidious::Jobs.register Invidious::Jobs::RefreshFeedsJob.new(PG_DB, logger, config) Invidious::Jobs.register Invidious::Jobs::SubscribeToFeedsJob.new(PG_DB, logger, config, HMAC_KEY) -Invidious::Jobs.register Invidious::Jobs::PullPopularVideosJob.new(PG_DB) Invidious::Jobs.register Invidious::Jobs::UpdateDecryptFunctionJob.new if config.statistics_enabled Invidious::Jobs.register Invidious::Jobs::StatisticsRefreshJob.new(PG_DB, config, SOFTWARE) end +if config.popular_enabled + Invidious::Jobs.register Invidious::Jobs::PullPopularVideosJob.new(PG_DB) +end + if config.captcha_key Invidious::Jobs.register Invidious::Jobs::BypassCaptchaJob.new(logger, config) end @@ -1146,13 +1149,20 @@ end get "/feed/top" do |env| locale = LOCALES[env.get("preferences").as(Preferences).locale]? - env.redirect "/" + + message = translate(locale, "The Top feed has been removed from Invidious.") + templated "message" end get "/feed/popular" do |env| locale = LOCALES[env.get("preferences").as(Preferences).locale]? - templated "popular" + if config.popular_enabled + templated "popular" + else + message = translate(locale, "The Popular feed has been disabled by the administrator.") + templated "message" + end end get "/feed/trending" do |env| @@ -2216,6 +2226,12 @@ get "/api/v1/popular" do |env| env.response.content_type = "application/json" + if !config.popular_enabled + error_message = {"error" => "Administrator has disabled this endpoint."}.to_json + env.response.status_code = 400 + next error_message + end + JSON.build do |json| json.array do popular_videos.each do |video| @@ -2229,7 +2245,8 @@ get "/api/v1/top" do |env| locale = LOCALES[env.get("preferences").as(Preferences).locale]? env.response.content_type = "application/json" - "[]" + env.response.status_code = 400 + {"error" => "The Top feed has been removed from Invidious."}.to_json end get "/api/v1/channels/:ucid" do |env| |
