Sha256: 8b1563c9ee05967239b256ba9d5e121f31436830e4f47ef14b478cb10c0d9b12

Contents?: true

Size: 1.21 KB

Versions: 31

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require 'aranha/default_processor'
require 'ehbrs_ruby_utils/videos/opensubtitles/parsers/episode'
require 'ehbrs_ruby_utils/videos/opensubtitles/processors/subtitle'
require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  module Videos
    module Opensubtitles
      module Processors
        class Episode < ::Aranha::DefaultProcessor
          enable_simple_cache
          enable_speaker

          def perform
            infov source_uri, subtitles.count
            subtitles.each(&:perform)
            next_page.if_present(&:perform)
          end

          private

          def next_page_uncached
            data.fetch(:next_page_href)
              .if_present { |v| self.class.new(source_uri + v, extra_data) }
          end

          def subtitle_uri(subtitle_data)
            source_uri + subtitle_data.fetch(:href)
          end

          def subtitles_uncached
            data.fetch(:subtitles).map do |subtitle_data|
              ::EhbrsRubyUtils::Videos::Opensubtitles::Processors::Subtitle.new(
                subtitle_uri(subtitle_data), extra_data
              )
            end + next_page.if_present([], &:subtitles)
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.44.3 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.44.2 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.44.1 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.44.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.41.1 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.41.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.40.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.39.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.38.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.37.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.36.1 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.36.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.35.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.33.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.32.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.31.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.30.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.29.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.28.0 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb
ehbrs_ruby_utils-0.27.1 lib/ehbrs_ruby_utils/videos/opensubtitles/processors/episode.rb