anilibria-api-ruby 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile +0 -1
 - data/Gemfile.lock +1 -1
 - data/README.md +26 -13
 - data/lib/anilibria/api/client.rb +34 -13
 - data/lib/anilibria/api/exceptions/api_error.rb +2 -1
 - data/lib/anilibria/api/exceptions/auth_error.rb +16 -5
 - data/lib/anilibria/api/exceptions/response_error.rb +3 -2
 - data/lib/anilibria/api/types/title.rb +19 -17
 - data/lib/anilibria/api/version.rb +1 -1
 - data/sample/rss.rb +14 -0
 - data/sample/schedule.rb +25 -0
 - data/sample/search_titles.rb +29 -0
 - data/sample/title.rb +21 -0
 - metadata +6 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 69881766a2287e012e03871b9997435a9d8f7080eed1377c267847b865c9a0be
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c70122a1d4aafea3218cc3f9b9323df801289733f394e7b1f5e847dff72ea466
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c25155e4d2fe623944cfa58b6b5ff8836132c4963980db42ea52cc0431301c052dd4accb81722d36d9d8faf148bd26c7d064f10bbfc92602744d13b45fa84b17
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 57c3db01725fe8fc00a193269777b9d491816503b996ad105fda3c6210d1d5d9b3c6014317c8138cb8772614b982ecd209f3fe81452de6b27aa3886f84df096f
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -24,43 +24,56 @@ $ gem install anilibria-api-ruby 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
            ## Usage
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
      
 27 
     | 
    
         
            +
            ### Client
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
       27 
29 
     | 
    
         
             
            Usage example:
         
     | 
| 
       28 
30 
     | 
    
         | 
| 
       29 
31 
     | 
    
         
             
            ```ruby
         
     | 
| 
       30 
32 
     | 
    
         
             
            require 'anilibria/api'
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
34 
     | 
    
         
             
            anilibria = Anilibria::Api::Client.new
         
     | 
| 
      
 35 
     | 
    
         
            +
            # => #<Anilibria::Api::Client:0x00007f25c52fc1b8 ...
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            anilibria.get_years
         
     | 
| 
      
 38 
     | 
    
         
            +
            # => [1996, 1998, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, ...
         
     | 
| 
       33 
39 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
            anilibria. 
     | 
| 
      
 40 
     | 
    
         
            +
            title = anilibria.get_title(code: 'steinsgate')
         
     | 
| 
      
 41 
     | 
    
         
            +
            # => #<Anilibria::Api::Types::Title id=8674 code="steinsgate" ...
         
     | 
| 
       35 
42 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
            title 
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
      
 43 
     | 
    
         
            +
            title.names.en
         
     | 
| 
      
 44 
     | 
    
         
            +
            # => "Steins;Gate"
         
     | 
| 
       38 
45 
     | 
    
         
             
            ```
         
     | 
| 
       39 
46 
     | 
    
         | 
| 
       40 
47 
     | 
    
         
             
            `anilibria` object implements [AniLibria API methods](https://github.com/anilibria/docs/blob/master/api_v2.md#method-list) as is. All methods are available in *snake_case* notation. Same with the `title` object - it implements the [Title](https://github.com/anilibria/docs/blob/master/api_v2.md#возвращаемые-значения-при-запросе-информации-о-тайтле) specification.
         
     | 
| 
       41 
48 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 49 
     | 
    
         
            +
            ### Authorization
         
     | 
| 
       43 
50 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
            The  
     | 
| 
      
 51 
     | 
    
         
            +
            The gem supports authorization:
         
     | 
| 
       45 
52 
     | 
    
         | 
| 
       46 
53 
     | 
    
         
             
            ```ruby
         
     | 
| 
       47 
     | 
    
         
            -
            # session = anilibria.auth(' 
     | 
| 
       48 
     | 
    
         
            -
            #  
     | 
| 
       49 
     | 
    
         
            -
            session = anilibria.auth('correctemail@example.com', 'CorrectPassword') # returns the session string
         
     | 
| 
      
 54 
     | 
    
         
            +
            # session = anilibria.auth('wrong@example.com', 'WrongPassword')
         
     | 
| 
      
 55 
     | 
    
         
            +
            # => nil
         
     | 
| 
       50 
56 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
            anilibria. 
     | 
| 
      
 57 
     | 
    
         
            +
            # session = anilibria.auth!('wrong@example.com', 'WrongPassword')
         
     | 
| 
      
 58 
     | 
    
         
            +
            # raises an error Anilibria::Api::Exceptions::AuthError
         
     | 
| 
       52 
59 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
            # =>  
     | 
| 
      
 60 
     | 
    
         
            +
            session = anilibria.auth('correct@example.com', 'CorrectPassword')
         
     | 
| 
      
 61 
     | 
    
         
            +
            # => "VdZnNZRpEl9w2HcKNRyj1BWXLqdynpog"
         
     | 
| 
       55 
62 
     | 
    
         | 
| 
      
 63 
     | 
    
         
            +
            anilibria.add_favorite(title_id: 9114, session: session)
         
     | 
| 
      
 64 
     | 
    
         
            +
            # => true
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            titles = anilibria.get_favorites(filter: 'id,code,names,description', session: session)
         
     | 
| 
      
 67 
     | 
    
         
            +
            # => [#<Anilibria::Api::Types::Title id=9114 code="shingeki-no-kyojin-the-final-season-part-2" ...
         
     | 
| 
       56 
68 
     | 
    
         
             
            ```
         
     | 
| 
       57 
69 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
            ### API Version
         
     | 
| 
       59 
71 
     | 
    
         | 
| 
       60 
72 
     | 
    
         
             
            You can get the currently used version of [AniLibria API](https://github.com/anilibria/docs/blob/master/api_v2.md): 
         
     | 
| 
       61 
73 
     | 
    
         | 
| 
       62 
74 
     | 
    
         
             
            ```ruby
         
     | 
| 
       63 
     | 
    
         
            -
            anilibria.api_version 
     | 
| 
      
 75 
     | 
    
         
            +
            anilibria.api_version
         
     | 
| 
      
 76 
     | 
    
         
            +
            # => "2.13.10"
         
     | 
| 
       64 
77 
     | 
    
         
             
            ```
         
     | 
| 
       65 
78 
     | 
    
         | 
| 
       66 
79 
     | 
    
         
             
            ## Contributing
         
     | 
    
        data/lib/anilibria/api/client.rb
    CHANGED
    
    | 
         @@ -25,6 +25,8 @@ module Anilibria 
     | 
|
| 
       25 
25 
     | 
    
         
             
                    end
         
     | 
| 
       26 
26 
     | 
    
         
             
                  end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
      
 28 
     | 
    
         
            +
                  Faraday::Utils.default_space_encoding = '%20'
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       28 
30 
     | 
    
         
             
                  DryTypes = Types::DryTypes
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
32 
     | 
    
         
             
                  API_VERSION = '2.13'.freeze
         
     | 
| 
         @@ -39,7 +41,10 @@ module Anilibria 
     | 
|
| 
       39 
41 
     | 
    
         
             
                  attr_reader :connection
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
       41 
43 
     | 
    
         
             
                  def initialize(url: ENDPOINT)
         
     | 
| 
       42 
     | 
    
         
            -
                    @connection = Faraday.new( 
     | 
| 
      
 44 
     | 
    
         
            +
                    @connection = Faraday.new(
         
     | 
| 
      
 45 
     | 
    
         
            +
                      url: url,
         
     | 
| 
      
 46 
     | 
    
         
            +
                      headers: { 'User-Agent' => "anilibria-api-ruby/#{VERSION}" }
         
     | 
| 
      
 47 
     | 
    
         
            +
                    ) do |f|
         
     | 
| 
       43 
48 
     | 
    
         
             
                      f.request :url_encoded
         
     | 
| 
       44 
49 
     | 
    
         
             
                      f.response :json, parser_options: { symbolize_names: true }
         
     | 
| 
       45 
50 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -58,7 +63,7 @@ module Anilibria 
     | 
|
| 
       58 
63 
     | 
    
         
             
                  def auth(mail, passwd)
         
     | 
| 
       59 
64 
     | 
    
         
             
                    response = auth_response(mail, passwd)
         
     | 
| 
       60 
65 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                    return unless response 
     | 
| 
      
 66 
     | 
    
         
            +
                    return unless auth_successful?(response)
         
     | 
| 
       62 
67 
     | 
    
         | 
| 
       63 
68 
     | 
    
         
             
                    response[:sessionId]
         
     | 
| 
       64 
69 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -66,34 +71,50 @@ module Anilibria 
     | 
|
| 
       66 
71 
     | 
    
         
             
                  def auth!(mail, passwd)
         
     | 
| 
       67 
72 
     | 
    
         
             
                    response = auth_response(mail, passwd)
         
     | 
| 
       68 
73 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
                     
     | 
| 
      
 74 
     | 
    
         
            +
                    unless auth_successful?(response)
         
     | 
| 
      
 75 
     | 
    
         
            +
                      raise(
         
     | 
| 
      
 76 
     | 
    
         
            +
                        Exceptions::AuthError.new(response),
         
     | 
| 
      
 77 
     | 
    
         
            +
                        'Failed authorization attempt'
         
     | 
| 
      
 78 
     | 
    
         
            +
                      )
         
     | 
| 
      
 79 
     | 
    
         
            +
                    end
         
     | 
| 
       70 
80 
     | 
    
         | 
| 
       71 
81 
     | 
    
         
             
                    response[:sessionId]
         
     | 
| 
       72 
82 
     | 
    
         
             
                  end
         
     | 
| 
       73 
83 
     | 
    
         | 
| 
       74 
84 
     | 
    
         
             
                  def api_version
         
     | 
| 
       75 
     | 
    
         
            -
                    connection. 
     | 
| 
      
 85 
     | 
    
         
            +
                    connection.head.headers['API-Version']
         
     | 
| 
       76 
86 
     | 
    
         
             
                  end
         
     | 
| 
       77 
87 
     | 
    
         | 
| 
       78 
88 
     | 
    
         
             
                  private
         
     | 
| 
       79 
89 
     | 
    
         | 
| 
      
 90 
     | 
    
         
            +
                  def check_response!(response)
         
     | 
| 
      
 91 
     | 
    
         
            +
                    return if response.status == 200
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                    if !response.body.respond_to?(:to_hash) ||
         
     | 
| 
      
 94 
     | 
    
         
            +
                       !response.body[:error].respond_to?(:to_hash)
         
     | 
| 
      
 95 
     | 
    
         
            +
                      raise Exceptions::ResponseError.new(
         
     | 
| 
      
 96 
     | 
    
         
            +
                        'Unexpected response from API', response
         
     | 
| 
      
 97 
     | 
    
         
            +
                      )
         
     | 
| 
      
 98 
     | 
    
         
            +
                    end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                    raise Exceptions::ApiError.new(response), response.body.dig(:error, :message)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
       80 
103 
     | 
    
         
             
                  def auth_response(mail, passwd)
         
     | 
| 
       81 
104 
     | 
    
         
             
                    response = connection.post(
         
     | 
| 
       82 
105 
     | 
    
         
             
                      AUTH_ENDPOINT,
         
     | 
| 
       83 
106 
     | 
    
         
             
                      { mail: mail, passwd: passwd }
         
     | 
| 
       84 
107 
     | 
    
         
             
                    )
         
     | 
| 
       85 
108 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
                     
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
                    return if response.status == 200
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                    if !response.body.respond_to?(:to_hash) || !response.body.key?(:error)
         
     | 
| 
       93 
     | 
    
         
            -
                      raise Exceptions::ResponseError.new('Unexpected response from API', response)
         
     | 
| 
      
 109 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 110 
     | 
    
         
            +
                      JSON.parse(response.body, { symbolize_names: true })
         
     | 
| 
      
 111 
     | 
    
         
            +
                    rescue JSON::ParserError
         
     | 
| 
      
 112 
     | 
    
         
            +
                      {}
         
     | 
| 
       94 
113 
     | 
    
         
             
                    end
         
     | 
| 
      
 114 
     | 
    
         
            +
                  end
         
     | 
| 
       95 
115 
     | 
    
         | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
                  def auth_successful?(response)
         
     | 
| 
      
 117 
     | 
    
         
            +
                    response[:key] == 'success' && response.key?(:sessionId)
         
     | 
| 
       97 
118 
     | 
    
         
             
                  end
         
     | 
| 
       98 
119 
     | 
    
         
             
                end
         
     | 
| 
       99 
120 
     | 
    
         
             
              end
         
     | 
| 
         @@ -2,14 +2,25 @@ module Anilibria 
     | 
|
| 
       2 
2 
     | 
    
         
             
              module Api
         
     | 
| 
       3 
3 
     | 
    
         
             
                module Exceptions
         
     | 
| 
       4 
4 
     | 
    
         
             
                  class AuthError < Base
         
     | 
| 
       5 
     | 
    
         
            -
                    attr_reader : 
     | 
| 
      
 5 
     | 
    
         
            +
                    attr_reader :data
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                    def initialize(data = {})
         
     | 
| 
      
 8 
     | 
    
         
            +
                      @data = data
         
     | 
| 
       6 
9 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
                    def initialize(response_body)
         
     | 
| 
       8 
     | 
    
         
            -
                      @err = response_body[:err]
         
     | 
| 
       9 
     | 
    
         
            -
                      @key = response_body[:key]
         
     | 
| 
       10 
     | 
    
         
            -
                      @mes = response_body[:mes]
         
     | 
| 
       11 
10 
     | 
    
         
             
                      super("#{mes} (#{key})")
         
     | 
| 
       12 
11 
     | 
    
         
             
                    end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                    def err
         
     | 
| 
      
 14 
     | 
    
         
            +
                      data[:err]
         
     | 
| 
      
 15 
     | 
    
         
            +
                    end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    def mes
         
     | 
| 
      
 18 
     | 
    
         
            +
                      data[:mes]
         
     | 
| 
      
 19 
     | 
    
         
            +
                    end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    def key
         
     | 
| 
      
 22 
     | 
    
         
            +
                      data[:key]
         
     | 
| 
      
 23 
     | 
    
         
            +
                    end
         
     | 
| 
       13 
24 
     | 
    
         
             
                  end
         
     | 
| 
       14 
25 
     | 
    
         
             
                end
         
     | 
| 
       15 
26 
     | 
    
         
             
              end
         
     | 
| 
         @@ -8,12 +8,23 @@ module Anilibria 
     | 
|
| 
       8 
8 
     | 
    
         
             
                      attribute? :string, DryTypes::String.optional
         
     | 
| 
       9 
9 
     | 
    
         
             
                    end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
                    class Posters < Base
         
     | 
| 
      
 12 
     | 
    
         
            +
                      class Poster < Base
         
     | 
| 
      
 13 
     | 
    
         
            +
                        attribute? :url, DryTypes::String.optional
         
     | 
| 
      
 14 
     | 
    
         
            +
                        attribute? :raw_base64_file, DryTypes::String.optional
         
     | 
| 
      
 15 
     | 
    
         
            +
                      end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                      %i[small medium original].each do |size|
         
     | 
| 
      
 18 
     | 
    
         
            +
                        attribute? size, Poster
         
     | 
| 
      
 19 
     | 
    
         
            +
                      end
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       11 
22 
     | 
    
         
             
                    class Player < Base
         
     | 
| 
       12 
23 
     | 
    
         
             
                      class Playlist < Base
         
     | 
| 
       13 
24 
     | 
    
         
             
                        attribute? :serie, DryTypes::Strict::Integer
         
     | 
| 
       14 
25 
     | 
    
         
             
                        attribute? :created_timestamp, DryTypes::Timestamp
         
     | 
| 
       15 
26 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                        attribute? :hls do
         
     | 
| 
      
 27 
     | 
    
         
            +
                        attribute? :hls, Base do
         
     | 
| 
       17 
28 
     | 
    
         
             
                          attribute? :fhd, DryTypes::String.optional
         
     | 
| 
       18 
29 
     | 
    
         
             
                          attribute? :hd, DryTypes::String.optional
         
     | 
| 
       19 
30 
     | 
    
         
             
                          attribute? :sd, DryTypes::String.optional
         
     | 
| 
         @@ -47,7 +58,6 @@ module Anilibria 
     | 
|
| 
       47 
58 
     | 
    
         
             
                          attribute? :name, DryTypes::Strict::String
         
     | 
| 
       48 
59 
     | 
    
         
             
                          attribute? :announce, DryTypes::Array.of(DryTypes::Strict::String)
         
     | 
| 
       49 
60 
     | 
    
         
             
                          attribute? :created_timestamp, DryTypes::Timestamp
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
61 
     | 
    
         
             
                          attribute? :files_list, DryTypes::Array.of(FilesList)
         
     | 
| 
       52 
62 
     | 
    
         
             
                        end
         
     | 
| 
       53 
63 
     | 
    
         | 
| 
         @@ -56,7 +66,7 @@ module Anilibria 
     | 
|
| 
       56 
66 
     | 
    
         
             
                        attribute? :torrent_id, DryTypes::Strict::Integer
         
     | 
| 
       57 
67 
     | 
    
         
             
                        attribute? :series, Title::Series
         
     | 
| 
       58 
68 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                        attribute? :quality do
         
     | 
| 
      
 69 
     | 
    
         
            +
                        attribute? :quality, Base do
         
     | 
| 
       60 
70 
     | 
    
         
             
                          attribute? :string, DryTypes::Strict::String
         
     | 
| 
       61 
71 
     | 
    
         
             
                          attribute? :type, DryTypes::Strict::String
         
     | 
| 
       62 
72 
     | 
    
         
             
                          attribute? :resolution, DryTypes::Strict::Integer
         
     | 
| 
         @@ -82,7 +92,7 @@ module Anilibria 
     | 
|
| 
       82 
92 
     | 
    
         
             
                    attribute? :id, DryTypes::Strict::Integer
         
     | 
| 
       83 
93 
     | 
    
         
             
                    attribute? :code, DryTypes::Strict::String
         
     | 
| 
       84 
94 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
                    attribute? :names do
         
     | 
| 
      
 95 
     | 
    
         
            +
                    attribute? :names, Base do
         
     | 
| 
       86 
96 
     | 
    
         
             
                      attribute? :ru, DryTypes::String.optional
         
     | 
| 
       87 
97 
     | 
    
         
             
                      attribute? :en, DryTypes::String.optional
         
     | 
| 
       88 
98 
     | 
    
         
             
                      attribute? :alternative, DryTypes::String.optional
         
     | 
| 
         @@ -90,24 +100,16 @@ module Anilibria 
     | 
|
| 
       90 
100 
     | 
    
         | 
| 
       91 
101 
     | 
    
         
             
                    attribute? :announce, DryTypes::String.optional
         
     | 
| 
       92 
102 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                    attribute? :status do
         
     | 
| 
      
 103 
     | 
    
         
            +
                    attribute? :status, Base do
         
     | 
| 
       94 
104 
     | 
    
         
             
                      attribute? :string, DryTypes::Strict::String
         
     | 
| 
       95 
105 
     | 
    
         
             
                      attribute? :code, DryTypes::Strict::Integer
         
     | 
| 
       96 
106 
     | 
    
         
             
                    end
         
     | 
| 
       97 
107 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
                    attribute? :posters  
     | 
| 
       99 
     | 
    
         
            -
                      %i[small medium original].each do |poster|
         
     | 
| 
       100 
     | 
    
         
            -
                        attribute? poster do
         
     | 
| 
       101 
     | 
    
         
            -
                          attribute? :url, DryTypes::String.optional
         
     | 
| 
       102 
     | 
    
         
            -
                          attribute? :raw_base64_file, DryTypes::String.optional
         
     | 
| 
       103 
     | 
    
         
            -
                        end
         
     | 
| 
       104 
     | 
    
         
            -
                      end
         
     | 
| 
       105 
     | 
    
         
            -
                    end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
                    attribute? :posters, Posters
         
     | 
| 
       107 
109 
     | 
    
         
             
                    attribute? :updated, DryTypes::Timestamp.optional
         
     | 
| 
       108 
110 
     | 
    
         
             
                    attribute? :last_change, DryTypes::Timestamp.optional
         
     | 
| 
       109 
111 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
                    attribute? :type do
         
     | 
| 
      
 112 
     | 
    
         
            +
                    attribute? :type, Base do
         
     | 
| 
       111 
113 
     | 
    
         
             
                      attribute? :full_string, DryTypes::String.optional
         
     | 
| 
       112 
114 
     | 
    
         
             
                      attribute? :string, DryTypes::String.optional
         
     | 
| 
       113 
115 
     | 
    
         
             
                      attribute? :length, DryTypes::String.optional
         
     | 
| 
         @@ -118,7 +120,7 @@ module Anilibria 
     | 
|
| 
       118 
120 
     | 
    
         
             
                    attribute? :genres, DryTypes::Array.of(DryTypes::Strict::String)
         
     | 
| 
       119 
121 
     | 
    
         
             
                    attribute? :team, Types::Team
         
     | 
| 
       120 
122 
     | 
    
         | 
| 
       121 
     | 
    
         
            -
                    attribute? :season do
         
     | 
| 
      
 123 
     | 
    
         
            +
                    attribute? :season, Base do
         
     | 
| 
       122 
124 
     | 
    
         
             
                      attribute? :string, DryTypes::String.optional
         
     | 
| 
       123 
125 
     | 
    
         
             
                      attribute? :code, DryTypes::Integer.optional
         
     | 
| 
       124 
126 
     | 
    
         
             
                      attribute? :year, DryTypes::Integer.optional
         
     | 
| 
         @@ -128,7 +130,7 @@ module Anilibria 
     | 
|
| 
       128 
130 
     | 
    
         
             
                    attribute? :description, DryTypes::String.optional
         
     | 
| 
       129 
131 
     | 
    
         
             
                    attribute? :in_favorites, DryTypes::Integer.optional
         
     | 
| 
       130 
132 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
                    attribute? :blocked do
         
     | 
| 
      
 133 
     | 
    
         
            +
                    attribute? :blocked, Base do
         
     | 
| 
       132 
134 
     | 
    
         
             
                      attribute? :blocked, DryTypes::Strict::Bool
         
     | 
| 
       133 
135 
     | 
    
         
             
                      attribute? :bakanim, DryTypes::Strict::Bool
         
     | 
| 
       134 
136 
     | 
    
         
             
                    end
         
     | 
    
        data/sample/rss.rb
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'anilibria/api'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rss'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            anilibria = Anilibria::Api::Client.new
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            today_ts = Date.today.to_time.to_i
         
     | 
| 
      
 7 
     | 
    
         
            +
            raw_rss = anilibria.get_rss(since: today_ts)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            feed = RSS::Parser.parse(raw_rss)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            puts feed.channel.title
         
     | 
| 
      
 12 
     | 
    
         
            +
            feed.items.each do |item|
         
     | 
| 
      
 13 
     | 
    
         
            +
              puts "#{item.pubDate.strftime('%H:%M:%S')} | #{item.title}"
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
    
        data/sample/schedule.rb
    ADDED
    
    | 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'anilibria/api'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            WEEK_DAYS = %w[
         
     | 
| 
      
 4 
     | 
    
         
            +
              Понедельник
         
     | 
| 
      
 5 
     | 
    
         
            +
              Вторник
         
     | 
| 
      
 6 
     | 
    
         
            +
              Среда
         
     | 
| 
      
 7 
     | 
    
         
            +
              Четверг
         
     | 
| 
      
 8 
     | 
    
         
            +
              Пятница
         
     | 
| 
      
 9 
     | 
    
         
            +
              Суббота
         
     | 
| 
      
 10 
     | 
    
         
            +
              Воскресенье
         
     | 
| 
      
 11 
     | 
    
         
            +
            ].freeze
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            anilibria = Anilibria::Api::Client.new
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            schedules = anilibria.get_schedule(filter: 'names.ru')
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            schedules.each do |schedule|
         
     | 
| 
      
 18 
     | 
    
         
            +
              puts "#{WEEK_DAYS[schedule.day]}:"
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              schedule.list.each do |title|
         
     | 
| 
      
 21 
     | 
    
         
            +
                puts "  #{title.names.ru}"
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              puts
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'anilibria/api'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            anilibria = Anilibria::Api::Client.new
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            limit = 10
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            puts 'Введите поисковый запрос:'
         
     | 
| 
      
 8 
     | 
    
         
            +
            input = $stdin.gets.chomp
         
     | 
| 
      
 9 
     | 
    
         
            +
            puts
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            titles = anilibria.search_titles(
         
     | 
| 
      
 12 
     | 
    
         
            +
              search: input,
         
     | 
| 
      
 13 
     | 
    
         
            +
              filter: 'id,names,season,type,team,genres[0]',
         
     | 
| 
      
 14 
     | 
    
         
            +
              limit: limit
         
     | 
| 
      
 15 
     | 
    
         
            +
            )
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            puts 'Результаты:'
         
     | 
| 
      
 18 
     | 
    
         
            +
            puts
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            titles.each do |title|
         
     | 
| 
      
 21 
     | 
    
         
            +
              puts "  id: #{title.id}"
         
     | 
| 
      
 22 
     | 
    
         
            +
              puts "  #{title.names.ru} / #{title.names.en}"
         
     | 
| 
      
 23 
     | 
    
         
            +
              puts "  Сезон: #{title.season.string} #{title.season.year}"
         
     | 
| 
      
 24 
     | 
    
         
            +
              puts "  Тип: #{title.type.full_string}"
         
     | 
| 
      
 25 
     | 
    
         
            +
              puts "  Жанр: #{title.genres.join(', ')}"
         
     | 
| 
      
 26 
     | 
    
         
            +
              puts
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            puts "Всего найдено #{titles.size}, лимит: #{limit}"
         
     | 
    
        data/sample/title.rb
    ADDED
    
    | 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'anilibria/api'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            anilibria = Anilibria::Api::Client.new
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            title = anilibria.get_random_title(remove: 'posters,player,torrents')
         
     | 
| 
      
 6 
     | 
    
         
            +
            # title = anilibria.get_title(id: 495, remove: 'posters,player,torrents')
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            subtitle_team = title.team.translator + title.team.editing + title.team.decor
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            puts "#{title.names.ru} / #{title.names.en}"
         
     | 
| 
      
 11 
     | 
    
         
            +
            puts
         
     | 
| 
      
 12 
     | 
    
         
            +
            puts "Сезон: #{title.season.year} #{title.season.string}"
         
     | 
| 
      
 13 
     | 
    
         
            +
            puts "Тип: #{title.type.full_string}"
         
     | 
| 
      
 14 
     | 
    
         
            +
            puts "Жанры: #{title.genres.join(', ')}"
         
     | 
| 
      
 15 
     | 
    
         
            +
            puts "Озвучка: #{title.team.voice.join(', ')}"
         
     | 
| 
      
 16 
     | 
    
         
            +
            puts "Тайминг: #{title.team.timing.join(', ')}" if title.team.timing.any?
         
     | 
| 
      
 17 
     | 
    
         
            +
            puts "Работа над субтитрами: #{subtitle_team.join(', ')}" if subtitle_team.any?
         
     | 
| 
      
 18 
     | 
    
         
            +
            puts
         
     | 
| 
      
 19 
     | 
    
         
            +
            puts title.description
         
     | 
| 
      
 20 
     | 
    
         
            +
            puts
         
     | 
| 
      
 21 
     | 
    
         
            +
            puts format('https://www.anilibria.tv/release/%<code>s.html', code: title.code)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: anilibria-api-ruby
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Roman Kozachenko
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-02- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-02-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: dry-struct
         
     | 
| 
         @@ -71,6 +71,10 @@ files: 
     | 
|
| 
       71 
71 
     | 
    
         
             
            - lib/anilibria/api/types/title.rb
         
     | 
| 
       72 
72 
     | 
    
         
             
            - lib/anilibria/api/types/youtube.rb
         
     | 
| 
       73 
73 
     | 
    
         
             
            - lib/anilibria/api/version.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - sample/rss.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - sample/schedule.rb
         
     | 
| 
      
 76 
     | 
    
         
            +
            - sample/search_titles.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - sample/title.rb
         
     | 
| 
       74 
78 
     | 
    
         
             
            homepage: https://github.com/psychosocial88/anilibria-api-ruby
         
     | 
| 
       75 
79 
     | 
    
         
             
            licenses:
         
     | 
| 
       76 
80 
     | 
    
         
             
            - MIT
         
     |