organo 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce74a150b3bd7be118c17318edaf064c0a3a7e49b7a71775f347123279d7bfcb
4
- data.tar.gz: 05d621c3fe3e5adefb79abd9bfe8f26a8ba4579967f914360ef56e40323f984f
3
+ metadata.gz: 16bba44699065f0d0afb4bd22c4c877243dbeeb11c5d3568d146a957f00cfb69
4
+ data.tar.gz: 4825637f9a142536d395f859d2309f5741f5fba336ad48eed68822c1c336f29e
5
5
  SHA512:
6
- metadata.gz: b369b8ba6b07283b6843614b17739fe6601760251d4abaa5f01ffdd54ddbccbe1adb0bdcd26c52a70165c19c33893d530a1580a94f122c7cbb74dfea77d8458b
7
- data.tar.gz: ec68ad34f619d0e003f2d1910c1706ba643f837a3b09b3295822ebf811a8aecd82dc9b7563755e5e71287eb4a9e7d32fbc2ca9f143c27a24e5ddab78a0f7a113
6
+ metadata.gz: 6144b9c1d789c2618a18e1dcf2ce9eac84c25d5e534fdc3d444102db216657cb4bee82186170bee45f6b5346dd6d0ac0ed6a9781b3137947cd61d1eed3f2a66d
7
+ data.tar.gz: f3fc2a18ceb87932457bb11de19cdf3a88f15fa6a1b1665e5a19dbc8bc92459387e9fd293fa985efeabbb78909c40a4754a707c34519c4c889f40499aad2a023
data/README.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  Organo is named after the mafia group that runs the city of Lux in the anime [Texhnolyze](https://myanimelist.net/anime/26/Texhnolyze).
4
4
 
5
- This tool has been made to manage data that is shown on the DKB Anime Community website. It uses to the [JikanAPI](https://jikan.moe), an unofficial MyAnimeList API, to get data.
5
+ ## Description
6
6
 
7
- **This tool is still under construction. Documentation is coming soon.**
7
+ This tool has been made to manage data that is shown on the DKB Anime Community website. It uses to the [JikanAPI](https://jikan.moe), an unofficial MyAnimeList API, and [AnimeSchedule](https://animeschedule.net) to get data.
8
+
9
+ **This tool is still under construction.**
10
+
11
+ ## Requirements
12
+
13
+ - Ruby 3.0+
14
+
15
+ Earlier versions of ruby might work, but the tool will not be tested against them.
16
+
17
+ ## Installation
18
+
19
+ The tool is available through [Rubygems](https://rubygems.org)
20
+ ```shell
21
+ gem install organo
22
+ ```
23
+
24
+ ## Documentation
25
+
26
+ **Documentation is still incomplete.**
27
+
28
+ The documentation is available in the `doc/` directory. Follow this [link](doc/readme.md).
data/doc/anime.md ADDED
@@ -0,0 +1,28 @@
1
+ # Anime
2
+
3
+ ## add
4
+
5
+ Add anime entry to files.
6
+ ```shell
7
+ organo anime add MAL_ID
8
+ ```
9
+
10
+ ## add sequel
11
+
12
+ Add anime sequel entry to anime in file.
13
+ ```shell
14
+ organo anime add sequel ANIME_MAL_ID SEQUEL_MAL_ID
15
+ ```
16
+
17
+ ## get broken_links
18
+
19
+ Get list of anime IDs that have broken links.
20
+ ```shell
21
+ organo anime get broken_links
22
+ ```
23
+
24
+ ## remove
25
+ ## search
26
+ ## show
27
+ ## update image
28
+ ## update query
data/doc/api.md ADDED
@@ -0,0 +1,6 @@
1
+ # API
2
+
3
+ ## get anime
4
+ ## get season
5
+ ## get sequels
6
+ ## search anime
data/doc/readme.md ADDED
@@ -0,0 +1,12 @@
1
+ # Organo documentation
2
+
3
+ The tool is broken into 4 main subcommands.
4
+
5
+ - [Anime](anime.md)
6
+ - Manage and browse the local data files.
7
+ - [API](api.md)
8
+ - Get data from Jikan API.
9
+ - [Remote](remote.md)
10
+ - Add FTP remote information to push the data to the website.
11
+ - [Schedule](schedule.md)
12
+ - Manage the weekly schedule.
data/doc/remote.md ADDED
@@ -0,0 +1,6 @@
1
+ # Remote
2
+
3
+ ## add
4
+ ## download
5
+ ## remove
6
+ ## upload
data/doc/schedule.md ADDED
@@ -0,0 +1,3 @@
1
+ # Schedule
2
+
3
+ ## create
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Organo
4
+ class AnimeScheduleAPI
5
+ BASE_URL = 'https://animeschedule.net/api/'
6
+
7
+ def self.get_url(endpoint, api_version = 'v3', key = '')
8
+ "#{BASE_URL}#{api_version}/#{endpoint}"
9
+ end
10
+ end
11
+ end
@@ -16,9 +16,9 @@ module Organo
16
16
  json_obj = Query.get_anime_by_id(mal_id)
17
17
  show = SearchShow.new(json_obj['mal_id'], json_obj['title'], json_obj['images']['jpg']['image_url'])
18
18
  show_type = json_obj['type']
19
- file_name = (show_type == 'TV' ? "#{json_obj['year']}-#{json_obj['season']}" : show_type.downcase)
19
+ file_name = (show_type == 'TV' ? "#{json_obj['year']}_#{json_obj['season']}" : show_type.downcase)
20
20
  file_path = "#{Config::DEFAULT_DIR}/#{file_name}.json"
21
- show_list = File.exist?(file_path) ? Reader.read_file(file_path) : Array.new
21
+ show_list = File.exist?(file_path) ? Reader.read_file(file_path) : []
22
22
  if show_list.find_index { |s| s.id.to_s == mal_id.to_s }.nil?
23
23
  Writer.to_file(show_list.push(show).sort_by(&:title), file_path)
24
24
  puts "Added anime \"#{show.title}\" (#{mal_id})"
@@ -9,7 +9,7 @@ module Organo
9
9
  module Add
10
10
 
11
11
  class SequelEntry < Dry::CLI::Command
12
- desc 'Add anime entry to files'
12
+ desc 'Add anime sequel entry to anime in file'
13
13
  argument :anime_mal_id, type: :integer, required: true, desc: 'Anime MyAnimeList ID'
14
14
  argument :sequel_mal_id, type: :integer, required: true, desc: 'Sequel MyAnimeList ID'
15
15
  argument :season_num, type: :integer, required: false, default: 0, desc: 'Season number'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../../config'
2
4
 
3
5
  module Organo
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../config'
4
+ require_relative '../../animeschedule_api'
5
+
6
+ module Organo
7
+ module CLI
8
+ module Commands
9
+ module API
10
+ module Get
11
+
12
+ class Schedule < Dry::CLI::Command
13
+ desc 'Get anime release schedule of a specified season'
14
+ argument :season, type: :string, required: true, desc: 'Winter, Spring, Summer or Fall'
15
+ argument :year, type: :integer, required: true, desc: 'Year'
16
+
17
+ def call(season:, year:, **)
18
+ # Get the list of anime mal_id
19
+ # show_list = Reader.read_file("#{Config::DEFAULT_DIR}/#{year}-#{season.downcase}.json")
20
+
21
+ config = JSON.parse(File.read(Config::DEFAULT_FILE))
22
+ section = config.find { |option| option['section'] == 'api' }
23
+ key = (section['entries'].find { |entry| entry['name'] == 'AnimeSchedule' })['key']
24
+
25
+ count = 0
26
+ page = 1
27
+ total = 0
28
+ anime_list = []
29
+ loop do
30
+ data = JSON.parse(
31
+ RestClient.get(
32
+ "#{AnimeScheduleAPI.get_url('anime', 'v3')}?mt=all&years=#{year}&seasons=#{season}&media-types=tv&page=#{page}",
33
+ { Authorization: "Bearer #{key}" }
34
+ )
35
+ )
36
+ total = data['totalAmount'].to_i
37
+ page += 1
38
+ count += data['anime'].size
39
+ anime_list.concat(data['anime'])
40
+ break if count >= total
41
+ end
42
+
43
+ draft_schedule = []
44
+ anime_list.each do |anime|
45
+ air_time = DateTime.parse(anime['premier'])
46
+ draft_schedule.push(
47
+ {
48
+ slug: anime['route'],
49
+ title: anime['title'],
50
+ weekday: air_time.strftime('%A').downcase
51
+ }
52
+ )
53
+ end
54
+
55
+ file = File.read('schedule.json')
56
+ schedule = JSON.parse(file)
57
+ schedule.each do |weekday|
58
+ draft_schedule.each do |anime|
59
+ next unless anime[:weekday].eql? weekday['weekday']
60
+
61
+ weekday['shows'].push(
62
+ { slug: anime[:slug], title: anime[:title], time: '' }
63
+ )
64
+ end
65
+ end
66
+ Writer.to_file(schedule, 'schedule.json')
67
+ end
68
+ end
69
+
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -6,10 +6,10 @@ module Organo
6
6
  module Schedule
7
7
 
8
8
  class Create < Dry::CLI::Command
9
- desc "Initialize directory with default files and directories"
9
+ desc 'Initialize directory with default files and directories'
10
10
 
11
11
  def call(*)
12
- content = Array.new
12
+ content = []
13
13
  Date::DAYNAMES.each do |dname|
14
14
  content.push({ 'weekday' => dname.downcase, 'shows' => [] } )
15
15
  end
data/lib/organo/config.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Organo
2
4
  class Config
3
5
  DEFAULT_FILE = './.organo/config.json'
4
6
  DEFAULT_DIR = './.organo/datafiles'
5
7
  end
6
- end
8
+ end
@@ -8,4 +8,4 @@ module Organo
8
8
  "#{BASE_URL}#{api_version}/#{endpoint}"
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Organo
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.3'
5
5
  end
data/lib/organo.rb CHANGED
@@ -13,6 +13,7 @@ require_relative 'organo/commands/api/api_get_anime'
13
13
  require_relative 'organo/commands/api/api_get_sequels'
14
14
  require_relative 'organo/commands/api/api_get_season'
15
15
  require_relative 'organo/commands/api/api_search_anime'
16
+ require_relative 'organo/commands/api/api_get_schedule'
16
17
  require_relative 'organo/commands/remote/remote_add'
17
18
  require_relative 'organo/commands/remote/remote_remove'
18
19
  require_relative 'organo/commands/remote/remote_download'
@@ -46,6 +47,7 @@ module Organo
46
47
  prefix.register 'get season', API::Get::Season
47
48
  prefix.register 'get sequels', API::Get::Sequels
48
49
  prefix.register 'search anime', API::Search::Anime
50
+ prefix.register 'get schedule', API::Get::Schedule
49
51
  end
50
52
  register 'merge', Merge
51
53
  register 'statistics', Statistics
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: organo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Fortin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -78,8 +78,14 @@ files:
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - README.md
81
+ - doc/anime.md
82
+ - doc/api.md
83
+ - doc/readme.md
84
+ - doc/remote.md
85
+ - doc/schedule.md
81
86
  - exe/organo
82
87
  - lib/organo.rb
88
+ - lib/organo/animeschedule_api.rb
83
89
  - lib/organo/commands/anime/anime_add.rb
84
90
  - lib/organo/commands/anime/anime_add_sequel.rb
85
91
  - lib/organo/commands/anime/anime_get_broken_links.rb
@@ -89,6 +95,7 @@ files:
89
95
  - lib/organo/commands/anime/anime_update_image.rb
90
96
  - lib/organo/commands/anime/anime_update_query.rb
91
97
  - lib/organo/commands/api/api_get_anime.rb
98
+ - lib/organo/commands/api/api_get_schedule.rb
92
99
  - lib/organo/commands/api/api_get_season.rb
93
100
  - lib/organo/commands/api/api_get_sequels.rb
94
101
  - lib/organo/commands/api/api_search_anime.rb