Skip to content

Instantly share code, notes, and snippets.

@neudabei
Last active November 20, 2021 15:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neudabei/ba78dd562281b9fb0f50b0c7b81fd076 to your computer and use it in GitHub Desktop.
Save neudabei/ba78dd562281b9fb0f50b0c7b81fd076 to your computer and use it in GitHub Desktop.
require 'pinboard'
require 'dotenv/load'
require 'csv'
class PinboardExport
TOKEN = ENV['PINBOARD_API_TOKEN']
def initialize
@pinboard = Pinboard::Client.new(:token => TOKEN)
rescue
puts "Couldn't authenticate"
end
def write_pins_to_csv
CSV.open('pinboard_export.csv', 'w') do |csv_object|
header_row = ['Link', 'Description', 'Tags', 'Time added']
csv_object << header_row
@pinboard.posts.each do |post|
link = post.href
description = post.description
tags = post.tag
time_added = post.time
csv_object << [link, description, tags, time_added]
end
end
end
end
pinboard_export = PinboardExport.new
pinboard_export.write_pins_to_csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment