organo 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -2
- data/doc/anime.md +28 -0
- data/doc/api.md +6 -0
- data/doc/readme.md +12 -0
- data/doc/remote.md +6 -0
- data/doc/schedule.md +3 -0
- data/lib/organo/animeschedule_api.rb +11 -0
- data/lib/organo/commands/anime/anime_add.rb +9 -8
- data/lib/organo/commands/anime/anime_add_sequel.rb +21 -14
- data/lib/organo/commands/anime/anime_search.rb +4 -7
- data/lib/organo/commands/api/api_get_schedule.rb +74 -0
- data/lib/organo/commands/schedule/schedule_create.rb +2 -2
- data/lib/organo/config.rb +3 -1
- data/lib/organo/jikan_api.rb +1 -1
- data/lib/organo/tools/local_search.rb +49 -0
- data/lib/organo/version.rb +1 -1
- data/lib/organo.rb +2 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7145d1efb8ac5804c2c0d786c2854dd9d92b209fceb33ca02192ae86fe0e65a
|
4
|
+
data.tar.gz: 77ff5845dd17c7ec583cbe5dace3833e52c3ca02e3d36b1b479d2140a97d908e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03c4f273847259ab1af9319ec390df5badfdcf448a9208bb20992b5e1b3d8d06bd7a22580a1c54bdd7268e0595825d560ae9269bf8556b1c9178967e03aa9a26
|
7
|
+
data.tar.gz: 5003d8cbac8a154dbcb57c2698504b86faef172a705d20b9d070f786a70c0ac53013e7ac5e24dac9699fec73808bcc244e1721531a43a47d5364459f3560213e
|
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
|
-
|
5
|
+
## Description
|
6
6
|
|
7
|
-
|
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
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
data/doc/schedule.md
ADDED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative '../../config'
|
2
2
|
require_relative '../../writer'
|
3
3
|
require_relative '../../reader'
|
4
|
+
require_relative '../../tools/local_search'
|
4
5
|
|
5
6
|
module Organo
|
6
7
|
module CLI
|
@@ -13,15 +14,15 @@ module Organo
|
|
13
14
|
argument :mal_id, type: :integer, required: true, desc: 'MyAnimeList ID'
|
14
15
|
|
15
16
|
def call(mal_id:, **)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
if LocalSearch.find_anime_by_id(mal_id).nil?
|
18
|
+
json_obj = Query.get_anime_by_id(mal_id)
|
19
|
+
show = SearchShow.new(json_obj['mal_id'], json_obj['title'], json_obj['images']['jpg']['image_url'])
|
20
|
+
show_type = json_obj['type']
|
21
|
+
file_name = (show_type == 'TV' ? "#{json_obj['year']}_#{json_obj['season']}" : show_type.downcase)
|
22
|
+
file_path = "#{Config::DEFAULT_DIR}/#{file_name}.json"
|
23
|
+
show_list = File.exist?(file_path) ? Reader.read_file(file_path) : []
|
23
24
|
Writer.to_file(show_list.push(show).sort_by(&:title), file_path)
|
24
|
-
puts "Added anime \"#{show.title}\" (#{mal_id})"
|
25
|
+
puts "Added anime \"#{show.title}\" (#{mal_id}) in #{file_path}"
|
25
26
|
else
|
26
27
|
puts 'Cannot add an already existing anime'
|
27
28
|
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../config'
|
2
4
|
require_relative '../../writer'
|
3
5
|
require_relative '../../reader'
|
6
|
+
require_relative '../../tools/local_search'
|
4
7
|
|
5
8
|
module Organo
|
6
9
|
module CLI
|
@@ -17,21 +20,25 @@ module Organo
|
|
17
20
|
argument :type_num, type: :integer, required: false, default: 0, desc: 'The sequel type number'
|
18
21
|
|
19
22
|
def call(anime_mal_id:, sequel_mal_id:, season_num:, type:, type_num:, **)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
if LocalSearch.find_anime_by_id(sequel_mal_id).nil?
|
24
|
+
json_obj = Query.get_anime_by_id(sequel_mal_id)
|
25
|
+
sequel = Sequel.new(
|
26
|
+
json_obj['mal_id'],
|
27
|
+
json_obj['title'],
|
28
|
+
json_obj['images']['jpg']['image_url'],
|
29
|
+
season_num,
|
30
|
+
type,
|
31
|
+
type_num
|
32
|
+
)
|
33
|
+
file_path = LocalSearch.find_file_by_anime_id(anime_mal_id)
|
34
|
+
show_list = Reader.read_file(file_path).each do |show|
|
35
|
+
show.sequels.push(sequel) if show.id == anime_mal_id.to_i
|
33
36
|
end
|
34
|
-
|
37
|
+
show_info = show_list.find { |show| show.id == anime_mal_id.to_i }
|
38
|
+
Writer.to_file(show_list, file_path)
|
39
|
+
puts "Added sequel \"#{sequel.title}\" (#{sequel.id}) to anime \"#{show_info.title}\" (#{anime_mal_id}) in #{file_path}."
|
40
|
+
else
|
41
|
+
puts 'This sequel already exists.'
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative '../../config'
|
4
|
+
require_relative '../../tools/local_search'
|
2
5
|
|
3
6
|
module Organo
|
4
7
|
module CLI
|
@@ -10,13 +13,7 @@ module Organo
|
|
10
13
|
argument :query, type: :string, required: true, desc: 'Search query'
|
11
14
|
|
12
15
|
def call(query:, **)
|
13
|
-
|
14
|
-
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
15
|
-
shows_list = Reader.read_file(file_path)
|
16
|
-
show = shows_list.find { |s| s.title.downcase.include? query }
|
17
|
-
found_list.push(show) unless show.nil?
|
18
|
-
end
|
19
|
-
puts found_list.to_json
|
16
|
+
puts (LocalSearch.find_anime_by_query(query).map{ |anime| anime.to_json })
|
20
17
|
end
|
21
18
|
end
|
22
19
|
|
@@ -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
|
9
|
+
desc 'Initialize directory with default files and directories'
|
10
10
|
|
11
11
|
def call(*)
|
12
|
-
content =
|
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
data/lib/organo/jikan_api.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require_relative '../reader'
|
5
|
+
|
6
|
+
module Organo
|
7
|
+
class LocalSearch
|
8
|
+
|
9
|
+
def self.find_anime_by_id(mal_id)
|
10
|
+
anime_list = Reader.read_all_files
|
11
|
+
get_anime_obj(mal_id, anime_list)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get_anime_obj(mal_id, anime_list)
|
15
|
+
return_value = nil
|
16
|
+
anime_list.each do |anime|
|
17
|
+
if anime.id == mal_id.to_i || anime.sequels.find { |sequel| sequel['id'] == mal_id.to_i }
|
18
|
+
return_value = anime
|
19
|
+
break
|
20
|
+
end
|
21
|
+
end
|
22
|
+
return_value
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.find_file_by_anime_id(mal_id)
|
26
|
+
return_value = nil
|
27
|
+
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
28
|
+
anime_list = Reader.read_file(file_path)
|
29
|
+
unless get_anime_obj(mal_id, anime_list).nil?
|
30
|
+
return_value = file_path
|
31
|
+
break
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return_value
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.find_anime_by_query(query)
|
38
|
+
anime_list = Reader.read_all_files
|
39
|
+
return_value = []
|
40
|
+
anime_list.each do |anime|
|
41
|
+
if (anime.title.downcase.include? query.downcase) ||
|
42
|
+
(anime.sequels.find { |sequel| sequel['title'].downcase.include? query.downcase })
|
43
|
+
return_value.push(anime)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return_value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/organo/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.4
|
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-
|
11
|
+
date: 2023-08-26 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
|
@@ -110,6 +117,7 @@ files:
|
|
110
117
|
- lib/organo/sequel.rb
|
111
118
|
- lib/organo/show.rb
|
112
119
|
- lib/organo/show_list.rb
|
120
|
+
- lib/organo/tools/local_search.rb
|
113
121
|
- lib/organo/version.rb
|
114
122
|
- lib/organo/writer.rb
|
115
123
|
homepage: https://gitlab.com/dkb-weeblets/organo
|