Sha256: 94b5ae5f9361413baef3c9dc7c612f69214f8641b76ad58a67d32825abfa67b1
Contents?: true
Size: 686 Bytes
Versions: 1
Compression:
Stored size: 686 Bytes
Contents
require 'youtube_to_rss/version' module YoutubeToRss class Error < StandardError; end class << self def convert(url) url = remove_query_strings(url) base_url = 'https://www.youtube.com/feeds/videos.xml?' if url.include?('/channel/') "#{base_url}channel_id=#{extract_param(url, '/channel/')}" elsif url.include?('/user/') "#{base_url}user=#{extract_param(url, '/user/')}" else raise 'URL should have channel or user param.' end end private def extract_param(url, param) url.split(param).last end def remove_query_strings(url) url.split('?').first.split('&').first end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
youtube_to_rss-0.1.1 | lib/youtube_to_rss.rb |