Class: PinboardTools::SafariReadingListImporter
- Inherits:
-
Object
- Object
- PinboardTools::SafariReadingListImporter
- Defined in:
- lib/pinboard_tools/srl_to_pinboard.rb
Instance Attribute Summary collapse
-
#tagger ⇒ Object
Returns the value of attribute tagger.
Instance Method Summary collapse
-
#initialize(args) ⇒ SafariReadingListImporter
constructor
A new instance of SafariReadingListImporter.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ SafariReadingListImporter
21 22 23 |
# File 'lib/pinboard_tools/srl_to_pinboard.rb', line 21 def initialize(args) @tagger = Tagger.new(tag: nil, verbose: args[:verbose]) end |
Instance Attribute Details
#tagger ⇒ Object
Returns the value of attribute tagger.
19 20 21 |
# File 'lib/pinboard_tools/srl_to_pinboard.rb', line 19 def tagger @tagger end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pinboard_tools/srl_to_pinboard.rb', line 25 def run links = Array.new # from gist: https://gist.github.com/andphe/3232343 input = %x[/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}:/.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>/g'] input.scan(/(http.+){/).each do |url| links.push url.first # p link end pinboard, = Pinboard::Client.new(:username => tagger.pb_user, password: tagger.pb_pass), ProgressBar.new(links.size) links.reverse_each do |url| begin = tagger.(url) article = { url: url, description: [:title], extended: [:excerpt], tags: [:keywords], replace: true, toread: true, :public => false } pinboard.add(article) rescue false rescue end .increment! end clear_list = %x{cp -R ~/dev/pinboard_tools/lib/Bookmarks.plist ~/Library/Safari/Bookmarks.plist} end |