organo 0.3.4 → 0.4.1
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/doc/anime.md +30 -8
- data/doc/readme.md +2 -2
- data/lib/organo/commands/anime/anime_add.rb +27 -22
- data/lib/organo/commands/anime/anime_find_broken_links.rb +31 -0
- data/lib/organo/commands/anime/anime_remove.rb +12 -12
- data/lib/organo/commands/anime/anime_set_sequel.rb +49 -0
- data/lib/organo/commands/anime/anime_show.rb +11 -13
- data/lib/organo/commands/anime/anime_update_image.rb +18 -33
- data/lib/organo/commands/anime/anime_update_query.rb +18 -19
- data/lib/organo/commands/api/api_get_anime.rb +5 -6
- data/lib/organo/commands/api/api_get_season.rb +6 -7
- data/lib/organo/commands/api/api_get_sequels.rb +5 -5
- data/lib/organo/commands/init.rb +32 -8
- data/lib/organo/commands/remote/remote_add.rb +14 -14
- data/lib/organo/commands/remote/remote_download.rb +10 -7
- data/lib/organo/commands/remote/remote_remove.rb +6 -4
- data/lib/organo/commands/remote/remote_upload.rb +6 -3
- data/lib/organo/commands/statistics.rb +8 -12
- data/lib/organo/commands/version.rb +3 -1
- data/lib/organo/query.rb +0 -1
- data/lib/organo/tools/string_utils.rb +28 -0
- data/lib/organo/{writer.rb → tools/writer.rb} +0 -5
- data/lib/organo/version.rb +1 -1
- data/lib/organo.rb +33 -47
- metadata +37 -17
- data/lib/organo/commands/anime/anime_add_sequel.rb +0 -50
- data/lib/organo/commands/anime/anime_get_broken_links.rb +0 -30
- data/lib/organo/commands/anime/anime_search.rb +0 -23
- data/lib/organo/commands/api/api_search_anime.rb +0 -27
- data/lib/organo/commands/merge.rb +0 -20
- data/lib/organo/reader.rb +0 -38
- data/lib/organo/search_show.rb +0 -58
- data/lib/organo/sequel.rb +0 -39
- data/lib/organo/show.rb +0 -36
- data/lib/organo/show_list.rb +0 -32
- data/lib/organo/tools/local_search.rb +0 -49
data/lib/organo/show.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
class Show
|
6
|
-
attr_accessor :id, :slug, :title, :image_url, :search_query, :sequels
|
7
|
-
|
8
|
-
def initialize(id, slug, title, image_url, search_query, links = [], sequels = [])
|
9
|
-
@id = id
|
10
|
-
@slug = slug
|
11
|
-
@title = title.to_s
|
12
|
-
@image_url = image_url
|
13
|
-
@search_query = search_query.empty? ? title : search_query
|
14
|
-
@links = links.nil? ? [] : links
|
15
|
-
@sequels = sequels.nil? ? [] : sequels
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
"id: #{@id}, title: #{@title}, image_url: #{@image_url}"
|
20
|
-
end
|
21
|
-
|
22
|
-
def as_json(_options = {})
|
23
|
-
{
|
24
|
-
id: @id,
|
25
|
-
slug: @slug,
|
26
|
-
title: @title,
|
27
|
-
image_url: @image_url,
|
28
|
-
sequels: @sequels,
|
29
|
-
search_query: @search_query
|
30
|
-
}
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_json(*options)
|
34
|
-
as_json(*options).to_json(*options)
|
35
|
-
end
|
36
|
-
end
|
data/lib/organo/show_list.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require_relative 'search_show'
|
5
|
-
require_relative 'sequel'
|
6
|
-
require_relative 'query'
|
7
|
-
|
8
|
-
module Organo
|
9
|
-
class ShowList
|
10
|
-
def self.create_search_show_list(json_obj)
|
11
|
-
show_list = []
|
12
|
-
json_obj.each do |entry|
|
13
|
-
show = SearchShow.new(entry['mal_id'], entry['title'], entry['images']['jpg']['image_url'])
|
14
|
-
show_list.push show
|
15
|
-
end
|
16
|
-
show_list.sort_by(&:title)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.create_search_sequel_list(json_obj)
|
20
|
-
sequel_list = []
|
21
|
-
json_obj.each do |relations|
|
22
|
-
next unless relations['relation'] == 'Sequel'
|
23
|
-
|
24
|
-
relations['entry'].each do |entry|
|
25
|
-
image_url = Query.get_anime_image(entry['mal_id'])
|
26
|
-
sequel_list.push Sequel.new(entry['mal_id'], entry['name'], image_url)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
sequel_list.sort_by(&:title)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,49 +0,0 @@
|
|
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
|