Sha256: 8b149b6cdd1830a1f6fb650e647b7361d40d1e0ac9d8ab13472ca5b783bdd2ea

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

# encoding: utf-8

require 'hls'
require 'nokogiri'
require 'json'

class Onsen < HLS
	HEADERS = {
		"Referer" => 'https://www.onsen.ag/'
	}

	def initialize(params, options)
		super
		@cover = "//*[@class='newest-content--left']//img[1]/@src" unless @cover
	end

	def download
		html = URI.open(@url, HEADERS, &:read)
		serial = Nokogiri(html).css('.play-video-info td')[0].text.scan(/\d+/)[0].to_i
		m3u8 = JSON.parse(html.scan(%r|streaming_url:("https:.*?.m3u8")|).flatten.sort.last)
		hls_download(@label, serial, m3u8, HEADERS)
	end

	def dump
		tag = Pathname(@url).basename.to_s.gsub(%r|[-/]|, '_')
		html = Nokogiri(URI.open(@url, HEADERS, &:read))
		title = html.css('h3')[0].text
		return {
			tag => {
				'desc' => title,
				'url' => @url,
				'label' => tag
			}
		}
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rget-4.13.2 lib/onsen.rb
rget-4.13.1 lib/onsen.rb
rget-4.13.0 lib/onsen.rb