Remove categories that were causing issues

This commit is contained in:
Hexaitos 2024-11-10 15:44:34 +01:00
parent 0e0f5650e6
commit 61f0903c19
3 changed files with 16 additions and 14 deletions

View File

@ -26,16 +26,11 @@ Category:Quality images of Buteo jamaicensis
Category:Quality images of Buteo lineatus Category:Quality images of Buteo lineatus
Category:Quality images of Buteo regalis Category:Quality images of Buteo regalis
Category:Quality images of Buteogallus Category:Quality images of Buteogallus
Category:Quality images of Aquila
Category:Quality images of Buteo
Category:Quality images of Circaetus
Category:Quality images of Circaetus gallicus Category:Quality images of Circaetus gallicus
Category:Quality images of Circaetus pectoralis Category:Quality images of Circaetus pectoralis
Category:Quality_images_of_Circus
Category:Quality images of Circus aeruginosus Category:Quality images of Circus aeruginosus
Category:Quality images of Circus cyaneus Category:Quality images of Circus cyaneus
Category:Quality images of Circus hudsonius Category:Quality images of Circus hudsonius
Category:Quality_images_of_Haliaeetus
Category:Quality images of Haliaeetus albicilla Category:Quality images of Haliaeetus albicilla
Category:Quality images of Haliaeetus leucocephalus Category:Quality images of Haliaeetus leucocephalus
Category:Quality images of Haliaeetus leucogaster Category:Quality images of Haliaeetus leucogaster

View File

@ -6,6 +6,8 @@ def get_images_by_category(categories)
random_category = random_category.gsub("Category:", "") random_category = random_category.gsub("Category:", "")
end end
puts random_category
photos = [] photos = []
conn = Faraday.new(url: 'https://commons.wikimedia.org/w/api.php') do |faraday| conn = Faraday.new(url: 'https://commons.wikimedia.org/w/api.php') do |faraday|

View File

@ -18,6 +18,7 @@ def get_random_image(photos)
req.params = params req.params = params
end end
begin
data = JSON.parse(response.body) data = JSON.parse(response.body)
info = data['query']['pages'].values.first info = data['query']['pages'].values.first
user = info['imageinfo'].first['user'] user = info['imageinfo'].first['user']
@ -27,6 +28,10 @@ def get_random_image(photos)
license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value'] license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value']
desc = info['imageinfo'].first['extmetadata']['ImageDescription']['value'] desc = info['imageinfo'].first['extmetadata']['ImageDescription']['value']
thumb = info['imageinfo'].first['thumburl'] thumb = info['imageinfo'].first['thumburl']
rescue
puts "ERROR OCCURRED"
return {:user => user, :url => url, :thumb => thumb, :license => license, :desc => desc, :license_url => license_url, :user_url => user_url}
end
return {:user => user, :url => url, :thumb => thumb, :license => license, :desc => desc, :license_url => license_url, :user_url => user_url} return {:user => user, :url => url, :thumb => thumb, :license => license, :desc => desc, :license_url => license_url, :user_url => user_url}
end end