-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
for the love of ruby, can we also implement Geolocation Filtering: Ability to filter photos based on geolocation data, if available. In addition,Date Range Filtering: Ability to search photos within a specific date range.
require 'pexels'
require 'open-uri'
# # Ensure that the API key is set in the environment variable PEXELS_API_KEY
client = Pexels::Client.new(ENV['PEXELS_API_KEY'])
client = Pexels::Client.new
def download_image(url, filename)
File.open(filename, 'wb') do |file|
file.write(URI.open(url).read)
end
end
photos = client.photos.search(
'United Kingdom',
per_page: 2,
page: 1,
geolocation: '51.4875, -0.1694', # Latitude and Longitude of Chelsea, London
date_range: '2023-01-01,2023-10-28' # Example: Download photos uploaded between Jan 1, 2023, and Oct 28, 2023
)
photos.photos.each_with_index do |photo, index|
download_image(photo.src['original'], "photo_#{index + 1}.jpg")
puts "Downloaded photo_#{index + 1}.jpg"
end
Metadata
Metadata
Assignees
Labels
No labels