Last active
November 17, 2019 16:41
-
-
Save Ishotihadus/d107f9d27fb4e120dc8c9af0c9e4debe to your computer and use it in GitHub Desktop.
e-onkyo の試聴をダウンロードするやつ。Usage: eonkyo-trial lacm14865
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'json' | |
require 'net/http' | |
require 'shellwords' | |
require 'uri' | |
unless ARGV[0] | |
warn "usage: #{$0} RecordID [TrackNo] [Output]" | |
exit 1 | |
end | |
album_id = ARGV[0] | |
track_no = ARGV[1] | |
output = ARGV[2] | |
response = Net::HTTP.get_response(URI.parse("https://www.e-onkyo.com/api/getplaylist.aspx?album_id=#{album_id}")) | |
response.value | |
json = JSON.parse(response.body) | |
json['track_list'].select!{|e| e['track_no'] == track_no.to_i} if track_no | |
json['track_list'].each do |track| | |
url = "https://onkyo-1.hls.wseod.stream.ne.jp/www11/onkyo-1/_definst_/#{track['file']}/chunklist.m3u8" | |
out = output || File.basename(track['file']) | |
shell = ['ffmpeg', '-i', url, '-vn', '-acodec', 'copy', out].shelljoin | |
system(shell) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment