Sha256: 8238d1504ffa9de141af2fc8ea5212fc249cc93f369c2d0c5f2d06c73612e428

Contents?: true

Size: 879 Bytes

Versions: 14

Compression:

Stored size: 879 Bytes

Contents

# typed: true

module Mangadex
  class AtHome
    extend T::Sig

    sig { params(chapter_id: String).returns(T::Api::GenericResponse) }
    def self.server(chapter_id)
      Mangadex::Internal::Request.get(
        "/at-home/server/#{chapter_id}",
      )
    end

    sig { params(chapter_id: String, data_saver: T::Boolean).returns(T.nilable(T::Array[String])) }
    def self.page_urls(chapter_id, data_saver: true)
      response = self.server(chapter_id)
      return if response.is_a?(Mangadex::Api::Response)

      base_url = response['baseUrl']
      chapter_data = response['chapter']
      hash = chapter_data['hash']
      source = data_saver ? chapter_data['dataSaver'] : chapter_data['data']
      data_source = data_saver ? 'data-saver' : 'data'

      source.map do |filename|
        [base_url, data_source, hash, filename].join('/')
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mangadex-5.10.0 lib/mangadex/at_home.rb
mangadex-5.9.0 lib/mangadex/at_home.rb
mangadex-5.8.0 lib/mangadex/at_home.rb
mangadex-5.7.5.3 lib/mangadex/at_home.rb
mangadex-5.7.5.2 lib/mangadex/at_home.rb
mangadex-5.7.5.1 lib/mangadex/at_home.rb
mangadex-5.7.5 lib/mangadex/at_home.rb
mangadex-5.5.8 lib/mangadex/at_home.rb
mangadex-5.5.6 lib/mangadex/at_home.rb
mangadex-5.4.16 lib/mangadex/at_home.rb
mangadex-5.4.11.3 lib/mangadex/at_home.rb
mangadex-5.4.11.2 lib/mangadex/at_home.rb
mangadex-5.4.11.1 lib/mangadex/at_home.rb
mangadex-5.4.11 lib/mangadex/at_home.rb