Roll back some changes. Looks like my Crystal install needs work
This commit is contained in:
parent
5150d965a3
commit
17d218c123
@ -38,7 +38,7 @@ end
|
|||||||
|
|
||||||
spawn do
|
spawn do
|
||||||
loop do
|
loop do
|
||||||
time = Time.local
|
time = Time.now
|
||||||
url_tuple = get_reddit_post(subreddit, completed) if (active_hours.includes? time.hour)
|
url_tuple = get_reddit_post(subreddit, completed) if (active_hours.includes? time.hour)
|
||||||
if url_tuple
|
if url_tuple
|
||||||
url, title = url_tuple
|
url, title = url_tuple
|
||||||
|
@ -21,7 +21,7 @@ class RedditResponse
|
|||||||
children: Array(RedditWrapper(RedditChild)))
|
children: Array(RedditWrapper(RedditChild)))
|
||||||
|
|
||||||
def self.from_subreddits(subreddits : Array(String))
|
def self.from_subreddits(subreddits : Array(String))
|
||||||
request_url = URI.new scheme: "https", host: "www.reddit.com", path: "/r/hot.json", query: "limit=30"
|
request_url = URI.new scheme: "https", host: "www.reddit.com", path: "/r/#{subreddits.join "+"}/hot.json", query: "limit=30"
|
||||||
response = HTTP::Client.get(request_url, headers: HTTP::Headers {
|
response = HTTP::Client.get(request_url, headers: HTTP::Headers {
|
||||||
"User-agent" => "Joann-Pupper-Bot"
|
"User-agent" => "Joann-Pupper-Bot"
|
||||||
})
|
})
|
||||||
@ -30,7 +30,7 @@ class RedditResponse
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
RedditWrapper(RedditResponse).from_json body
|
RedditWrapper(RedditResponse).from_json body
|
||||||
rescue
|
rescue e
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -46,7 +46,7 @@ class RedditResponse
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def filter_reddit_json(json, completed, extensions = ["png", "json"])
|
def filter_reddit_json(json, completed, extensions = ["png", "jpeg"])
|
||||||
json.data.posts_matching do |post|
|
json.data.posts_matching do |post|
|
||||||
extensions.any? { |it| post.url.ends_with? it } && !completed.includes? post.url
|
extensions.any? { |it| post.url.ends_with? it } && !completed.includes? post.url
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user