organo 0.3.0 → 0.3.2
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 +5 -5
- data/lib/organo/commands/anime/anime_add_sequel.rb +4 -4
- 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: 8691436aa9cdcb12c5de1da33b147103bcfa5d2459a3ad6b0ad868b4b49b2b44
|
4
|
+
data.tar.gz: 3f1b7419aaee87053d5b74f0227e6b9c5e4c36d783b672dafebbd6f3d1c07091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e3e5e6c5e8898ab4552bd2b9cf108aef4de0075f13e5e1731cf4bda3917534cc19c88ecfc545ac41396d7f33e01311408d600b33e2331bbbfcd28a2f4decdad
|
7
|
+
data.tar.gz: 14046ec16b3a0986312e78567e226089346d1bba28a0d05b0c10996d7916e7c5a9787f9312ce567dcbf0f588f43485b17a57df2d0b526eb4ddacde29b9810bb7
|
@@ -9,17 +9,17 @@ 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)
|
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']}
|
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) :
|
22
|
-
if
|
21
|
+
show_list = File.exist?(file_path) ? Reader.read_file(file_path) : []
|
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
|
@@ -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
|
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'
|
@@ -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.2
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|