Sha256: 84aaa040ea7d68eba95aedae3aa6f38a7d5135da68a2c923347fe0862e23db03
Contents?: true
Size: 695 Bytes
Versions: 17
Compression:
Stored size: 695 Bytes
Contents
require 'open-uri' require 'json' class Himalaya < WebRadio def initialize(params, options) super @offset = 0 end def download html = open(@url).read json_str = html.scan(/__NEXT_DATA__ = (.*)/).flatten.first json = JSON.parse(json_str) tracks = json['props']['seo']['albumData']['data']['tracks']['list'] track = tracks[@offset] m4a_url = track['playPathAacv164'] serial = Time.at(track['createdAt']/1000).strftime('%Y%m%d') @cover ||= track['coverLarge'] m4a_file = "#{@label}##{serial}.m4a" mp3_file = "#{@label}##{serial}.mp3" mp3nize(m4a_file, mp3_file) do open(m4a_file, 'wb:ASCII-8BIT') do |m4a| m4a.write(open(m4a_url).read) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems