Skip to content

Instantly share code, notes, and snippets.

@yagays
Last active March 19, 2020 13:33
Show Gist options
  • Save yagays/9898758 to your computer and use it in GitHub Desktop.
Save yagays/9898758 to your computer and use it in GitHub Desktop.
# -*- encoding: utf-8 -*-
#/usr/bin/env ruby
require 'yaml'
radio_dir = "/path/to/radio"
rtmpdump = "/path/to/rtmpdump"
agqr_stream_url = "rtmp://fms-base1.mitene.ad.jp/agqr/aandg22"
schedule = "schedule.yaml"
ffmpeg = "/path/to/ffmpeg"
day = Time.now
schedule_yaml = YAML.load_file(schedule)
schedule_yaml["agqr"].each do |program|
# should record
should_record = program["record"]
# right wday
if program["date"]["hour"] == 0 && program["date"]["min"] == 0
right_wday = program["date"]["wday"] - 1 == day.wday
program_start = Time.local(day.year, day.month, day.day + 1, program["date"]["hour"], program["date"]["min"], 0)
else
right_wday = program["date"]["wday"] == day.wday
program_start = Time.local(day.year, day.month, day.day, program["date"]["hour"], program["date"]["min"], 0)
end
# right now
right_now = (program_start - day).abs < 120
if should_record && right_wday && right_now
if program["personality"]
personality = "_" + program["personality"].gsub(" ","・")
else
personality = ""
end
title = (day.strftime("%Y%m%d") + program["title"] + personality).gsub(" ","")
system("#{rtmpdump} -r #{agqr_stream_url} --live -B #{program["date"]["time"]} -o #{radio_dir}/file/#{title}.flv")
system("#{ffmpeg} -y -i #{radio_dir}/file/#{title}.flv -vcodec copy -acodec copy /path/to/radio/#{title}.mp4")
end
end
agqr:
- record: true
title: A&G NEXT GENERATION Lady Go!!
personality: 上坂すみれ
date:
wday: 1
hour: 17
min: 00
time: 3615
- record: true
title: A&G NEXT GENERATION Lady Go!!
personality: 小松未可子
date:
wday: 2
hour: 17
min: 00
time: 3615
- record: true
title: A&G NEXT GENERATION Lady Go!!
personality: 大久保瑠美
date:
wday: 3
hour: 17
min: 00
time: 3615
- record: true
title: A&G NEXT GENERATION Lady Go!!
personality: 高森奈津美
date:
wday: 4
hour: 17
min: 00
time: 3615
- record: true
title: A&G NEXT GENERATION Lady Go!!
personality: 三上枝織
date:
wday: 5
hour: 17
min: 00
time: 3615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment