SeCeRiTyRaBbiT.com =o\=o\=o\>

Always hacking at something, rabbitear's thoughts and notes about free software, computer security, and the random.

About Me bLog Resume' tHe sHacK! My GitHub

Completed School! \o/

01 May 2010

I'm finished! Done! Completed! Has been a long haul since Fall of 2006, great experiences, lots of work. Now I'm in a state of bliss. I think I will get back into this blogging again, maybe refine some ideas that I've had rolling around in my head. One of which is a Ruby on Rails web app, might have to do some preliminary websites for the feel of Rails.

Ruby is such a smooth language. Wrote a script to grab SNL (Saturday Night Live) every week so I can watch it on the ASUS O!play 99 dollar media player. That took about 4 hours total, and has been working pretty good for the past two months. Here's the script:
#!/usr/bin/ruby

require 'rss/2.0'
require 'date'
require 'open-uri'

unless ARGV.length == 2
puts "Usage: SCRIPT <daysback> <showname>"
exit
end

#rss is the rss url setup for bt-chat
#Should be set at eztv feed for shows
rss = 'http://rss.bt-chat.com/?group=3&cat=9'
day = ARGV[0]
srh = ARGV[1]

puts "day: #{day}"
puts "srh: #{srh}"

#This could be better..
Dir.chdir("/home/storage/watch")

feed = RSS::Parser.parse(open(rss).read, false)
puts "RSS Channel: #{feed.channel.title}"
now = DateTime.now

feed.items.each do |item|
if item.title.to_s =~ /#{srh}/
pub = Date.parse(item.pubDate.to_s)
difference = (now-pub).to_i
if difference <= day.to_i
unless File.file?(item.title.to_s)
puts "downloading: #{item.title}"
writeOut = open(item.title.to_s,"w")
writeOut.write(open(item.link.to_s).read)
writeOut.close
end
end
end
end
puts 'done..'

During the post of this code I relized a couple of things. I don't see a way to use web interface editor to post formatted source code. I used the unix GNU source-highlight to convert to html, with the --src-lang arg. Then piping output to xlcip putting the html into the clip board.

The editor would not take a middle click paste, maybe it will take a right-click paste. At the time did not know that so went through OpenOffice to get it on here. Next think I'll try and post it in a table box.