Created
February 21, 2012 19:08
Revisions
-
joshuap revised this gist
Feb 25, 2012 . 1 changed file with 17 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,12 @@ #!/usr/bin/env ruby require 'nokogiri' require 'open-uri' class Mp3Crawler def initialize(url) @data = Nokogiri::XML(open(url)) end def links @data.xpath('//enclosure').select{|e| e.attributes['type'].value.strip == 'audio/mpeg' }.map do |e| e.attributes['url'].value.strip @@ -16,27 +16,29 @@ end feeds = DATA.read.split("\n").reject(&:empty?) links = feeds.reduce([]) do |links, feed| puts "Crawling #{feed}" links << Mp3Crawler.new(feed).links links end links.flatten! puts "Captured #{links.size} files. Starting download..." soundcloud = ->(l) { l =~ /soundcloud\.com/ } links.each do |link| filename = URI.decode(File.basename(case link when soundcloud then link[/\/(.*)\/download/n, 1] else link end)) filename.concat('.mp3') if File.extname(filename).empty? path = File.join(ENV['HOME'], 'Music', 'Blogs', filename) puts "Downloading #{link}" `wget -cO '#{path}' #{link}` end -
joshuap created this gist
Feb 21, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ #!/usr/bin/ruby require 'nokogiri' require 'open-uri' class Mp3Crawler def initialize(url) @data = Nokogiri::XML(open(url)) end def links @data.xpath('//enclosure').select{|e| e.attributes['type'].value.strip == 'audio/mpeg' }.map do |e| e.attributes['url'].value.strip end end end feeds = DATA.read.split("\n").reject(&:empty?) links = feeds.inject([]) do |links, feed| puts %[Crawling #{feed}] links << Mp3Crawler.new(feed).links links end.flatten puts %[Captured #{links.size} files. Starting download...] soundcloud = proc {|l| l =~ /soundcloud\.com/ } links.each do |link| filename = URI.decode(File.basename(case link when soundcloud link[/\/(.*)\/download/n, 1] else link end)) filename.concat('.mp3') if File.extname(filename).empty? path = File.join(ENV['HOME'], 'mp3s', filename) puts %[Downloading #{link}] `wget -cO '#{path}' #{link}` end __END__ http://feeds2.feedburner.com/aurgasm http://feeds.feedburner.com/tinyways http://boomboomchik.com/feed http://www.audiodrums.com/feed/ http://www.qcmixtapes.com/?feed=rss2 http://bambooorchestra.blogspot.com/feeds/posts/default?alt=rss http://www.undomondo.com/rss http://www.mixtaperiot.com/feed/ http://www.blogotheque.net/feed/ http://feeds2.feedburner.com/bigstereo http://palmsout.net/feed/ http://www.scissorkick.com/feed/ http://music.for-robots.com/?feed=rss2 http://soul-sides.com/feed/ http://bennloxo.com/feed/ http://3hive.com/feed/