SVX日記
2011-03-02(Wed) ソウルをルビーで語る
$ vi ma3.rb
#!/usr/bin/ruby
ep = 8
system('/usr/bin/wget -O ch260.html http://ch.nicovideo.jp/channel/ch260')
movie_url = nil
open('ch260.html') {|fh|
fh.each {|l|
l =~ /href="([^"]+)"/ and movie_url = $1
l =~ /第#{ep}話/ and break
}
}
movie_url or raise('failed to get movie_url')
system("./nicovideo-dl -u mail@example.com -p password #{movie_url}")
movie_url =~ /(\d+)$/ and movie_file = $1 + '.mp4'
movie_file or raise('failed to get movie_file')
system("/usr/bin/ffmpeg -i %s -vcodec mpeg4 -s 320x240 -r 29.97 -b 600k -acodec libfaac -ac 2 -ar 44100 -ab 64k magicaPsp%02d.mp4" % [movie_file, ep])
$ crontab -e
0 5 * * 4 cd /home/mediasrv/magica; ./ma3.rb