Created
August 13, 2013 23:51
-
-
Save izumogeiger/6226822 to your computer and use it in GitHub Desktop.
NHKラジオ第2を録音し、DropBoxにアップロードするスクリプト
サイマルラジオの受信にmplayerを使用
This file contains 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 characters
#!/bin/sh | |
mplayer -playlist http://mfile.akamai.com/129932/live/reflector:46056.asx -vo null -ao pcm:waveheader:fast:file=>(lame -q 4 - $1) |
This file contains 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 characters
# coding:utf-8 | |
require "pp" | |
require "fileutils" | |
require "dropbox_sdk" | |
if ARGV.size < 2 | |
puts "#{File.basename(__FILE__)} title sec" | |
end | |
now = Time.now | |
dir = File.join(ENV["HOME"],"radio",now.strftime("%Y"),now.strftime("%m")) | |
FileUtils.mkdir_p(dir) | |
mp3 = File.join(dir,"#{ARGV[0]}_#{now.strftime("%Y%m%d%H%M%S")}.mp3") | |
dirname = File.expand_path(File.dirname(__FILE__)) | |
mplaysh = File.join(dirname,"mplay.sh") | |
pid = Process.fork do | |
`/bin/bash #{mplaysh} #{mp3}` | |
end | |
sleep ARGV[1].to_i | |
`kill #{pid}` if pid | |
mp3base = File.basename(mp3) | |
remotefile = File.join("nhk-radio-2",now.strftime("%Y%m%d"),mp3base) | |
puts mp3 | |
puts remotefile | |
access_token = "xxxxxxxxxxxx" | |
client = DropboxClient.new(access_token) | |
puts "linked account:", client.account_info().inspect | |
f = open(mp3) | |
response = client.put_file(remotefile, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment