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 regalis
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 pectoralis
Category:Quality_images_of_Circus
Category:Quality images of Circus aeruginosus
Category:Quality images of Circus cyaneus
Category:Quality images of Circus hudsonius
Category:Quality_images_of_Haliaeetus
Category:Quality images of Haliaeetus albicilla
Category:Quality images of Haliaeetus leucocephalus
Category:Quality images of Haliaeetus leucogaster

View File

@ -6,6 +6,8 @@ def get_images_by_category(categories)
random_category = random_category.gsub("Category:", "")
end
puts random_category
photos = []
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
end
data = JSON.parse(response.body)
info = data['query']['pages'].values.first
user = info['imageinfo'].first['user']
user_url = info['imageinfo'].first['extmetadata']['Artist']['value']
url = info['imageinfo'].first['url']
license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value']
license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value']
desc = info['imageinfo'].first['extmetadata']['ImageDescription']['value']
thumb = info['imageinfo'].first['thumburl']
begin
data = JSON.parse(response.body)
info = data['query']['pages'].values.first
user = info['imageinfo'].first['user']
user_url = info['imageinfo'].first['extmetadata']['Artist']['value']
url = info['imageinfo'].first['url']
license = info['imageinfo'].first['extmetadata']['LicenseShortName']['value']
license_url = info['imageinfo'].first['extmetadata']['LicenseUrl']['value']
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}
end