Sha256: d5750ab84013f5ad67ed00b930b68a394b913dec28bd2508355d3b510d66a2a1

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

require_relative 'tubedl/version'
require_relative 'tubedl/playlist_parser'
require 'nokogiri'
require 'open-uri'
require 'yaml'

module Tubedl
  include PlaylistParser

	QULITIES = {
		hd1440: '?version=3&vq=hd1440',
		hd1080: '?version=3&vq=hd1080',
		hd720:  '?version=3&vq=hd720',
		sd480:  '?version=3&vq=large',
		sd360:  '?version=3&vq=medium',
		sd240:  '?version=3&vq=small'
	}

  def self.get_videoID(link)
    link.match(PlaylistParser::YoutubeRegex)[5]
  end

  def self.set_quality(str, quality)
  	str + QULITIES[quality.to_sym]
	end

	def self.get_page_data(url)
		begin
			doc = Nokogiri::HTML(open(url).read)
		rescue Timeout::Error
			STDERR.puts "Timeout while connecting to: #{urlHash}"
			STDERR.puts 'Retrying...'
			retry
		end
		doc
	end

	def self.load_playlist(file_path)
		YAML.load_file(file_path)
	end

	def self.save_object(object)
    File.write("#{object}.yml", YAML.dump(object))
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tubedl-0.1.6 lib/tubedl.rb