-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YouTube improvements. Add a hidden way to use the RSS Box endpoint (h…
…old the shift key when submitting the form). Add YouTube feed options to the modal. Fix the shorts filter by querying youtube.com/shorts/ for each video (it will make the query more expensive, consider using `min_length` instead).
- Loading branch information
1 parent
a079717
commit 55b5fa8
Showing
6 changed files
with
151 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
# https://developers.google.com/youtube/v3/docs/ | ||
|
||
module App | ||
class YouTube < Google | ||
BASE_URL = "https://www.googleapis.com/youtube/v3" | ||
|
||
def self.is_short?(video_id) | ||
is_short, _ = App::Cache.cache("youtube.shorts", video_id, 7*24*60*60, 60) do | ||
url = "https://www.youtube.com/shorts/#{video_id}" | ||
uri = Addressable::URI.parse(url) | ||
opts = { | ||
use_ssl: uri.scheme == "https", | ||
open_timeout: 10, | ||
read_timeout: 10, | ||
} | ||
Net::HTTP.start(uri.host, uri.port, opts) do |http| | ||
response = http.request_get(uri.request_uri) | ||
$metrics[:requests_total].increment(labels: { service: "youtube", response_code: response.code }) | ||
next (response.code == "200").to_i.to_s | ||
end | ||
rescue => e | ||
raise(self::ERROR_CLASS, e) | ||
end | ||
|
||
return is_short == "1" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters