Skip to content

Instantly share code, notes, and snippets.

@bascht
Last active September 24, 2024 14:42
Show Gist options
  • Save bascht/a80669400e856357590d to your computer and use it in GitHub Desktop.
Save bascht/a80669400e856357590d to your computer and use it in GitHub Desktop.
Download all a RSS feed and wget all the links for your personal offline reading pleasure. :)
#!/usr/bin/env ruby
# - encoding: utf-8 -
#
# E.g. with: pinget.rb https://feeds.pinboard.in/rss/secret:YOURSECRET/u:YOURUSERNAME/toread/
require 'rss'
require 'open-uri'
require 'uri'
WGET = ['wget',
'--recursive',
'--level=1',
'--quiet',
'--page-requisites',
'--html-extension',
'--tries=5',
'--convert-links',
'--restrict-file-names=windows',
'--no-parent']
open(ARGV[0]) do |rss|
feed = RSS::Parser.parse(rss)
puts "Title: #{feed.channel.title}"
feed.items.each do |item|
puts "Downloading [#{item.title}](#{item.link})"
system(*[WGET, item.link].flatten)
end
end
@marpala
Copy link

marpala commented Nov 14, 2015

Exactly what I was looking for! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment