Skip to content

Commit

Permalink
Cleaned up your code some. Start using iterators and / or functional …
Browse files Browse the repository at this point in the history
…programming tools (map, reduce, etc). They are the main reason your code becomes cleaner and more verbose than C/C++.
  • Loading branch information
azizmb committed Feb 10, 2012
1 parent d1d30cc commit 9b59fa8
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions fifRC.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,24 @@

source = "http://feeds.feedburner.com/railscasts"

content =""
content = ""

open(source) do |s| content = s.read end
open(source) do |s|
content = s.read
end

rss =RSS::Parser.parse(content, false)
rss = RSS::Parser.parse(content, false)

name =[] #=> to store the name of videos

base_url="http://media.railscasts.com/assets/episodes/videos/"
base_url = "http://media.railscasts.com/assets/episodes/videos/"

#SAMPLE_URL => http://media.railscasts.com/assets/episodes/videos/316-private-pub.webm

0.upto(rss.items.count-1) { |f| name.push(rss.items[f].title) } #=> to fetch the titles from RSS feed
0.upto(name.count-1) { |n| name[n] = name[n].sub("#","") } #=> Slice off # from the beginning
0.upto(name.count-1) { |n| name[n] = name[n].gsub(" ","-") } #=> replace all blank spaces with "-"
#print name

final_url=[] #=> to store the final URL that needs to be passed to wget

0.upto(name.count-1) { |n| final_url[n] = base_url + name[n].downcase + ".webm" }
final_url = rss.items.collect do |item|
"#{ base_url }#{ item.title.sub("#","").gsub(" ","-").downcase }.webm"
end

#print final_url
p final_url.inspect

0.upto(final_url.count-1) { |n| `wget -c #{final_url[n].downcase}` }
final_url.each do |url|
`wget -c #{url.downcase}`
end

0 comments on commit 9b59fa8

Please sign in to comment.