Sha256: 4b454a1e3004e9af5be6d6e9dc8b9fb4a13d725a68d01cf0497690756effeda4

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module PopcorntimeSearch
  class ShowResult < MovieResult
    base_uri "#{BASE_URL}/show/"

    attr_accessor :season, :episode

    def initialize(result, season, episode)
      super(result)

      @kind    = :show
      @season  = season
      @episode = episode
    end

    private

    def build_links
      episode_links = self.class.get("/#{@imdb_id}")['episodes'].find do |episode|
        episode['season'] == @season && episode['episode'] == @episode
      end

      return [] unless episode_links

      episode_links['torrents'].each_with_object([]) do |(quality, info), links_list|
        next if quality == '0'
        links_list << Link.new(title: "#{@title} #{@season}x#{@episode.to_s.rjust(2, '0')}",
                               imdb_id: imdb_id,
                               magnet: info['url'],
                               seeders: info['seeds'],
                               leechers: info['peers'],
                               language: 'en',
                               quality: quality,
                               provider: info['provider'])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
popcorntime_search-1.1.0 lib/popcorntime_search/show_result.rb
popcorntime_search-1.0.0 lib/popcorntime_search/show_result.rb
popcorntime_search-0.1.0 lib/popcorntime_search/show_result.rb