-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathetsy_sucker.rb
More file actions
32 lines (26 loc) · 764 Bytes
/
etsy_sucker.rb
File metadata and controls
32 lines (26 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'etsy'
OUTPUT_FILE = File.join(File.dirname(__FILE__), "config", "products", "from_etsy.rb")
Etsy.api_key = ''
Etsy.environment = :production
user = Etsy.user('username')
File.open(OUTPUT_FILE, "w") do |out|
# listing = user.shop.listings.first
listings = user.shop.listings
listings.each do |listing|
description = listing.description.split(/[\n\r]/).reject(&:empty?)
images = listing.images.map(&:full)
out.puts <<END
Products << Product.new(
:title => "#{listing.title}",
:section => Sections[:state_mirrors],
:images => #{images},
:blurb => "",
:description => #{description},
:price => #{listing.price.gsub(/\..*/, '')},
:shipping => {},
:size => nil
)
END
end
puts "Imported #{listings.size} listings"
end