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

Version Path
rget-4.8.4 lib/himalaya.rb
rget-4.8.3 lib/himalaya.rb
rget-4.8.2 lib/himalaya.rb
rget-4.8.1 lib/himalaya.rb
rget-4.8.0 lib/himalaya.rb
rget-4.7.9 lib/himalaya.rb
rget-4.7.8 lib/himalaya.rb
rget-4.7.7 lib/himalaya.rb
rget-4.7.6 lib/himalaya.rb
rget-4.7.5 lib/himalaya.rb
rget-4.7.4 lib/himalaya.rb
rget-4.7.3 lib/himalaya.rb
rget-4.7.2 lib/himalaya.rb
rget-4.7.1 lib/himalaya.rb
rget-4.7.0 lib/himalaya.rb
rget-4.6.1 lib/himalaya.rb
rget-4.6.0 lib/himalaya.rb