Sha256: fbce0b3cb7b5b4453b8d146c6a22b1a67eca95bb52c304004b9853cf23f69216

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

require "youtube_to_rss/version"

module YoutubeToRss
  class Error < StandardError; end
  class << self
    def convert(url)
      url = remove_query_strings(url)

      if url.include?('/channel/')
        channel_id = url.split('/channel/').last
        'https://www.youtube.com/feeds/videos.xml?channel_id=' + channel_id
      elsif url.include?('/user/')
        user = url.split('/user/').last
        'https://www.youtube.com/feeds/videos.xml?user=' + user
      end
    end

    private

    def remove_query_strings(url)
      url.chomp("?").chomp("&")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
youtube_to_rss-0.1.0 lib/youtube_to_rss.rb