-
-
Save neudabei/ba78dd562281b9fb0f50b0c7b81fd076 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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