organo 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/organo/commands/anime/anime_add.rb +3 -3
- data/lib/organo/commands/anime/anime_add_sequel.rb +3 -3
- data/lib/organo/commands/anime/anime_get_broken_links.rb +2 -2
- data/lib/organo/commands/anime/anime_remove.rb +8 -8
- data/lib/organo/commands/anime/anime_search.rb +3 -3
- data/lib/organo/commands/anime/anime_show.rb +6 -2
- data/lib/organo/commands/anime/anime_update_image.rb +19 -6
- data/lib/organo/commands/anime/anime_update_query.rb +4 -4
- data/lib/organo/version.rb +1 -1
- data/lib/organo.rb +31 -26
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce74a150b3bd7be118c17318edaf064c0a3a7e49b7a71775f347123279d7bfcb
|
4
|
+
data.tar.gz: 05d621c3fe3e5adefb79abd9bfe8f26a8ba4579967f914360ef56e40323f984f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b369b8ba6b07283b6843614b17739fe6601760251d4abaa5f01ffdd54ddbccbe1adb0bdcd26c52a70165c19c33893d530a1580a94f122c7cbb74dfea77d8458b
|
7
|
+
data.tar.gz: ec68ad34f619d0e003f2d1910c1706ba643f837a3b09b3295822ebf811a8aecd82dc9b7563755e5e71287eb4a9e7d32fbc2ca9f143c27a24e5ddab78a0f7a113
|
@@ -9,8 +9,8 @@ module Organo
|
|
9
9
|
module Add
|
10
10
|
|
11
11
|
class AnimeEntry < Dry::CLI::Command
|
12
|
-
desc
|
13
|
-
argument :mal_id, type: :integer, required: true, desc:
|
12
|
+
desc 'Add anime entry to files'
|
13
|
+
argument :mal_id, type: :integer, required: true, desc: 'MyAnimeList ID'
|
14
14
|
|
15
15
|
def call(mal_id:, **)
|
16
16
|
json_obj = Query.get_anime_by_id(mal_id)
|
@@ -19,7 +19,7 @@ module Organo
|
|
19
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
21
|
show_list = File.exist?(file_path) ? Reader.read_file(file_path) : Array.new
|
22
|
-
if
|
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})"
|
25
25
|
else
|
@@ -23,13 +23,13 @@ module Organo
|
|
23
23
|
show = shows_list.find { |s| s.id.to_s == anime_mal_id.to_s }
|
24
24
|
next if show.nil?
|
25
25
|
|
26
|
-
|
26
|
+
if show.sequels.find { |s| s['id'].to_s == sequel_mal_id.to_s }
|
27
|
+
puts 'Cannot add an already existing sequel.'
|
28
|
+
else
|
27
29
|
sequel = Sequel.new(json_obj['mal_id'], json_obj['title'], json_obj['images']['jpg']['image_url'], season_num, type, type_num)
|
28
30
|
show.sequels.push(sequel)
|
29
31
|
Writer.to_file(shows_list, file_path)
|
30
32
|
puts "Added sequel \"#{sequel.title}\" (#{sequel.id}) to anime."
|
31
|
-
else
|
32
|
-
puts 'Cannot add an already existing sequel.'
|
33
33
|
end
|
34
34
|
break
|
35
35
|
end
|
@@ -8,11 +8,11 @@ module Organo
|
|
8
8
|
module Get
|
9
9
|
|
10
10
|
class BrokenLinks < Dry::CLI::Command
|
11
|
-
desc
|
11
|
+
desc 'Get list of anime IDs that have broken links'
|
12
12
|
|
13
13
|
def call(*)
|
14
14
|
show_list = Reader.read_all_files
|
15
|
-
broken_list =
|
15
|
+
broken_list = []
|
16
16
|
show_list.each do |show|
|
17
17
|
response = HTTParty.get(show.image_url)
|
18
18
|
next unless response.code == 404
|
@@ -6,19 +6,19 @@ module Organo
|
|
6
6
|
module Anime
|
7
7
|
|
8
8
|
class Remove < Dry::CLI::Command
|
9
|
-
desc
|
10
|
-
argument :mal_id, type: :integer, required: true, desc:
|
9
|
+
desc 'Remove anime entry from files'
|
10
|
+
argument :mal_id, type: :integer, required: true, desc: 'MyAnimeList ID'
|
11
11
|
|
12
12
|
def call(mal_id:, **)
|
13
13
|
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
14
14
|
shows_list = Reader.read_file(file_path)
|
15
15
|
show_index = shows_list.find_index { |s| s.id.to_s == mal_id.to_s }
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
next unless show_index >= 0
|
17
|
+
|
18
|
+
show = shows_list.delete_at(show_index)
|
19
|
+
Writer.to_file(shows_list, file_path)
|
20
|
+
puts "Removed anime \"#{show.title}\" (#{mal_id})"
|
21
|
+
break
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -6,11 +6,11 @@ module Organo
|
|
6
6
|
module Anime
|
7
7
|
|
8
8
|
class Search < Dry::CLI::Command
|
9
|
-
desc
|
10
|
-
argument :query, type: :string, required: true, desc:
|
9
|
+
desc 'Search anime by query from files'
|
10
|
+
argument :query, type: :string, required: true, desc: 'Search query'
|
11
11
|
|
12
12
|
def call(query:, **)
|
13
|
-
found_list =
|
13
|
+
found_list = []
|
14
14
|
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
15
15
|
shows_list = Reader.read_file(file_path)
|
16
16
|
show = shows_list.find { |s| s.title.downcase.include? query }
|
@@ -6,17 +6,21 @@ module Organo
|
|
6
6
|
module Anime
|
7
7
|
|
8
8
|
class Show < Dry::CLI::Command
|
9
|
-
desc
|
10
|
-
argument :mal_id, type: :integer, required: true, desc:
|
9
|
+
desc 'Show anime entry from files'
|
10
|
+
argument :mal_id, type: :integer, required: true, desc: 'MyAnimeList ID'
|
11
11
|
|
12
12
|
def call(mal_id:, **)
|
13
|
+
found = false
|
13
14
|
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
14
15
|
shows_list = Reader.read_file(file_path)
|
15
16
|
show = shows_list.find { |s| s.id.to_s == mal_id.to_s }
|
16
17
|
next if show.nil?
|
17
18
|
|
19
|
+
found = true
|
18
20
|
puts show.to_json
|
21
|
+
break
|
19
22
|
end
|
23
|
+
puts 'Entry not found.' unless found
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -10,22 +10,35 @@ module Organo
|
|
10
10
|
module Update
|
11
11
|
|
12
12
|
class Image < Dry::CLI::Command
|
13
|
-
desc
|
14
|
-
argument :mal_id_list, type: :array, required: true, desc:
|
13
|
+
desc 'Update cover image for the specified anime'
|
14
|
+
argument :mal_id_list, type: :array, required: true, desc: 'MyAnimeList ID list'
|
15
15
|
|
16
16
|
def call(mal_id_list:, **)
|
17
|
+
found = false
|
17
18
|
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
18
19
|
shows_list = Reader.read_file(file_path)
|
19
|
-
mal_id_list.
|
20
|
+
mal_id_list.each_with_index do |mal_id, index|
|
20
21
|
show = shows_list.find { |s| s.id.to_s == mal_id.to_s }
|
22
|
+
if show.nil?
|
23
|
+
shows_list.each do |s|
|
24
|
+
show = s.sequels.find { |ss| ss['id'].to_s == mal_id.to_s }
|
25
|
+
end
|
26
|
+
end
|
21
27
|
next if show.nil?
|
22
28
|
|
23
|
-
|
29
|
+
found = true
|
30
|
+
if show.is_a?(Hash)
|
31
|
+
show['image_url'] = Query.get_anime_image(show['id'])
|
32
|
+
# puts show['image_url']
|
33
|
+
else
|
34
|
+
show.image_url = Query.get_anime_image(show.id)
|
35
|
+
# puts show.image_url
|
36
|
+
end
|
24
37
|
Writer.to_file(shows_list, file_path)
|
25
|
-
|
38
|
+
sleep(1) if mal_id_list.size > 1 && index < (mal_id.size - 1)
|
26
39
|
end
|
27
40
|
end
|
28
|
-
puts 'Cover image(s) has been updated.'
|
41
|
+
puts found ? 'Cover image(s) has been updated.' : 'Entry not found.'
|
29
42
|
end
|
30
43
|
end
|
31
44
|
|
@@ -9,9 +9,9 @@ module Organo
|
|
9
9
|
module Update
|
10
10
|
|
11
11
|
class SearchQuery < Dry::CLI::Command
|
12
|
-
desc
|
13
|
-
argument :mal_id, type: :integer, required: true, desc:
|
14
|
-
argument :search_query, type: :string, required: true, desc:
|
12
|
+
desc 'Update search query for the specified anime'
|
13
|
+
argument :mal_id, type: :integer, required: true, desc: 'MyAnimeList ID'
|
14
|
+
argument :search_query, type: :string, required: true, desc: 'String query for Nyaa Torrents search'
|
15
15
|
|
16
16
|
def call(mal_id:, search_query:, **)
|
17
17
|
Dir["#{Config::DEFAULT_DIR}/*.json"].each do |file_path|
|
@@ -21,7 +21,7 @@ module Organo
|
|
21
21
|
|
22
22
|
show.search_query = search_query
|
23
23
|
Writer.to_file(shows_list, file_path)
|
24
|
-
puts
|
24
|
+
puts 'Search query has been updated.'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/organo/version.rb
CHANGED
data/lib/organo.rb
CHANGED
@@ -29,32 +29,37 @@ module Organo
|
|
29
29
|
|
30
30
|
register 'version', Version, aliases: %w[v -v --version]
|
31
31
|
register 'init', Init
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
32
|
+
|
33
|
+
if Dir.exist?('.organo')
|
34
|
+
register 'anime' do |prefix|
|
35
|
+
prefix.register 'add', Anime::Add::AnimeEntry
|
36
|
+
prefix.register 'add sequel', Anime::Add::SequelEntry
|
37
|
+
prefix.register 'remove', Anime::Remove
|
38
|
+
prefix.register 'show', Anime::Show
|
39
|
+
prefix.register 'search', Anime::Search
|
40
|
+
prefix.register 'update image', Anime::Update::Image
|
41
|
+
prefix.register 'update search_query', Anime::Update::SearchQuery
|
42
|
+
prefix.register 'get broken_links', Anime::Get::BrokenLinks
|
43
|
+
end
|
44
|
+
register 'api' do |prefix|
|
45
|
+
prefix.register 'get anime', API::Get::Anime
|
46
|
+
prefix.register 'get season', API::Get::Season
|
47
|
+
prefix.register 'get sequels', API::Get::Sequels
|
48
|
+
prefix.register 'search anime', API::Search::Anime
|
49
|
+
end
|
50
|
+
register 'merge', Merge
|
51
|
+
register 'statistics', Statistics
|
52
|
+
register 'remote' do |prefix|
|
53
|
+
prefix.register 'add', Remote::Add
|
54
|
+
prefix.register 'remove', Remote::Remove
|
55
|
+
prefix.register 'download', Remote::Download
|
56
|
+
prefix.register 'upload', Remote::Upload
|
57
|
+
end
|
58
|
+
register 'schedule' do |prefix|
|
59
|
+
prefix.register 'create', Schedule::Create
|
60
|
+
end
|
61
|
+
else
|
62
|
+
puts 'This directory has not been initialized.'
|
58
63
|
end
|
59
64
|
end
|
60
65
|
end
|
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.1
|
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-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|