如果你还不知道飞鱼秀是什么,那么。。。请忽略此贴。
我经常写程序的时候听,但是有的时候没有网络,或者网络不太好(比如咖啡馆)。所以写了一个script可以在我网络好的时候去下载飞鱼秀然后存在硬盘上,想什么时候听都可以 ;)
要求,你要有mplayer。这个script是给macos的,但是改一改都适用。
我经常写程序的时候听,但是有的时候没有网络,或者网络不太好(比如咖啡馆)。所以写了一个script可以在我网络好的时候去下载飞鱼秀然后存在硬盘上,想什么时候听都可以 ;)
要求,你要有mplayer。这个script是给macos的,但是改一改都适用。
require 'rubygems'
require 'date'
PREFIX = "mms://media.chinabroadcast.cn/eng/music/morning/"
TARGET_FOLDER = "~/Documents/Radio/"
MPLAYER = "/Applications/MPlayer\\ OSX.app/Contents/Resources/External_Binaries/mplayer.app/Contents/MacOS/mplayer -dumpstream -dumpfile "
for i in 1..2
current_date = Date.today
current_dates = (current_date-i).to_s
url1 = current_dates.sub(/-/, '/')
url2 = url1.sub(/-/,'')
for j in 'a'..'c'
url = PREFIX + url2 + j + '.wma'
if File.exist?(File.expand_path(TARGET_FOLDER + current_dates + j + '.wma'))
puts "File:" + TARGET_FOLDER + current_dates + j + '.wma already exist.'
else
command = MPLAYER + TARGET_FOLDER + current_dates + j + '.wma ' + url
system (command)
puts command
end
end
end