Sha256: 8f9dcf9d1838c5cc20ce8be9df272e6a70cc043a13ff7eb4d9c99bbf277e5dc9
Contents?: true
Size: 971 Bytes
Versions: 2
Compression:
Stored size: 971 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: #{url}" 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tubedl-0.1.8 | lib/tubedl.rb |
tubedl-0.1.7 | lib/tubedl.rb |