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,15 +18,20 @@ def get_random_image(photos)
req.params = params req.params = params
end end
data = JSON.parse(response.body) begin
info = data['query']['pages'].values.first data = JSON.parse(response.body)
user = info['imageinfo'].first['user'] info = data['query']['pages'].values.first
user_url = info['imageinfo'].first['extmetadata']['Artist']['value'] user = info['imageinfo'].first['user']
url = info['imageinfo'].first['url'] user_url = info['imageinfo'].first['extmetadata']['Artist']['value']
license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value'] url = info['imageinfo'].first['url']
license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value'] license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value']
desc = info['imageinfo'].first['extmetadata']['ImageDescription']['value'] license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value']
thumb = info['imageinfo'].first['thumburl'] desc = info['imageinfo'].first['extmetadata']['ImageDescription']['value']
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