syobocal 0.10.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +174 -7
- data/Rakefile +9 -1
- data/data/.gitkeep +0 -0
- data/lib/syobocal/calchk.rb +5 -5
- data/lib/syobocal/comment/cast.rb +15 -0
- data/lib/syobocal/comment/element/blank.rb +25 -0
- data/lib/syobocal/comment/element/header1.rb +27 -0
- data/lib/syobocal/comment/element/header2.rb +27 -0
- data/lib/syobocal/comment/element/link.rb +30 -0
- data/lib/syobocal/comment/element/list.rb +27 -0
- data/lib/syobocal/comment/element/root.rb +17 -0
- data/lib/syobocal/comment/element/row.rb +36 -0
- data/lib/syobocal/comment/element/text.rb +21 -0
- data/lib/syobocal/comment/element/text_node.rb +55 -0
- data/lib/syobocal/comment/helper/fragment.rb +80 -0
- data/lib/syobocal/comment/music.rb +15 -0
- data/lib/syobocal/comment/music_data.rb +15 -0
- data/lib/syobocal/comment/parser.rb +103 -0
- data/lib/syobocal/comment/person.rb +33 -0
- data/lib/syobocal/comment/section.rb +136 -0
- data/lib/syobocal/comment/staff.rb +15 -0
- data/lib/syobocal/db.rb +38 -38
- data/lib/syobocal/json.rb +18 -18
- data/lib/syobocal/rss.rb +19 -19
- data/lib/syobocal/rss2.rb +13 -13
- data/lib/syobocal/sub_titles/parser.rb +21 -0
- data/lib/syobocal/sub_titles/sub_title.rb +15 -0
- data/lib/syobocal/util.rb +6 -6
- data/lib/syobocal/version.rb +1 -1
- data/lib/syobocal.rb +30 -11
- data/scripts/download_db_title_lookup.rb +15 -0
- data/scripts/parse_comment.rb +20 -0
- data/syobocal.gemspec +19 -12
- metadata +101 -9
data/lib/syobocal/rss2.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Syobocal
|
2
2
|
module RSS2
|
3
3
|
def get(params = {})
|
4
|
-
parse(open(url(params)))
|
4
|
+
parse(URI.open(url(params)))
|
5
5
|
end
|
6
6
|
|
7
7
|
def url(params = {})
|
8
|
-
|
8
|
+
"http://cal.syoboi.jp/rss2.php" + Syobocal::Util.format_params(params)
|
9
9
|
end
|
10
10
|
|
11
11
|
def parse(rss)
|
@@ -13,18 +13,18 @@ module Syobocal
|
|
13
13
|
|
14
14
|
result = Result.new
|
15
15
|
|
16
|
-
channel = rss.elements[
|
17
|
-
result.title = channel.elements[
|
18
|
-
result.link = channel.elements[
|
19
|
-
result.dc_language = channel.elements[
|
20
|
-
result.pub_date = Time.parse(channel.elements[
|
21
|
-
|
22
|
-
rss.elements.each(
|
16
|
+
channel = rss.elements["rss/channel"]
|
17
|
+
result.title = channel.elements["title"].text
|
18
|
+
result.link = channel.elements["link"].text
|
19
|
+
result.dc_language = channel.elements["dc:language"].text
|
20
|
+
result.pub_date = Time.parse(channel.elements["pubDate"].text)
|
21
|
+
|
22
|
+
rss.elements.each("rss/channel/item") { |item|
|
23
23
|
result << {
|
24
|
-
:title => item.elements[
|
25
|
-
:link => item.elements[
|
26
|
-
:description => item.elements[
|
27
|
-
:pub_date => Time.parse(item.elements[
|
24
|
+
:title => item.elements["title"].text,
|
25
|
+
:link => item.elements["link"].text,
|
26
|
+
:description => item.elements["description"].text,
|
27
|
+
:pub_date => Time.parse(item.elements["pubDate"].text),
|
28
28
|
}
|
29
29
|
}
|
30
30
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Syobocal
|
2
|
+
module SubTitles
|
3
|
+
class Parser
|
4
|
+
FORMAT_REGEXP = /\A\*(.*?)\*(.*)\Z/
|
5
|
+
|
6
|
+
def initialize(sub_titles)
|
7
|
+
@sub_titles = sub_titles
|
8
|
+
end
|
9
|
+
|
10
|
+
def parse
|
11
|
+
return @parse if defined? @parse
|
12
|
+
|
13
|
+
@sub_titles.each_line.each_with_object([]){|line, array|
|
14
|
+
m = FORMAT_REGEXP.match(line)
|
15
|
+
|
16
|
+
array << SubTitle.new(m[1], m[2]) if m
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Syobocal
|
2
|
+
module SubTitles
|
3
|
+
class SubTitle
|
4
|
+
attr_reader :episode, :title
|
5
|
+
|
6
|
+
def initialize(episode, title)
|
7
|
+
@episode, @title = episode, title
|
8
|
+
end
|
9
|
+
|
10
|
+
def ==(other)
|
11
|
+
other.instance_of?(self.class) && other.episode == episode && other.title == title
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/syobocal/util.rb
CHANGED
@@ -3,17 +3,17 @@ module Syobocal
|
|
3
3
|
def self.format_params(params)
|
4
4
|
return "" if params.length == 0
|
5
5
|
|
6
|
-
|
7
|
-
tuple[0].to_s +
|
8
|
-
}.join(
|
6
|
+
"?" + params.to_a.map { |tuple|
|
7
|
+
tuple[0].to_s + "=" + tuple[1].to_s
|
8
|
+
}.join("&")
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.format_params_amp(params)
|
12
12
|
return "" if params.length == 0
|
13
13
|
|
14
|
-
"&" + params.to_a.map{|tuple|
|
15
|
-
tuple[0].to_s +
|
16
|
-
}.join(
|
14
|
+
"&" + params.to_a.map { |tuple|
|
15
|
+
tuple[0].to_s + "=" + tuple[1].to_s
|
16
|
+
}.join("&")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/syobocal/version.rb
CHANGED
data/lib/syobocal.rb
CHANGED
@@ -1,15 +1,34 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "open-uri"
|
2
|
+
require "rexml/document"
|
3
|
+
require "delegate"
|
4
|
+
require "json"
|
5
|
+
require "rss"
|
6
6
|
require "syobocal/version"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
8
|
+
require "syobocal/util"
|
9
|
+
require "syobocal/calchk"
|
10
|
+
require "syobocal/db"
|
11
|
+
require "syobocal/json"
|
12
|
+
require "syobocal/rss"
|
13
|
+
require "syobocal/rss2"
|
14
|
+
require "syobocal/comment/element/blank"
|
15
|
+
require "syobocal/comment/element/header1"
|
16
|
+
require "syobocal/comment/element/header2"
|
17
|
+
require "syobocal/comment/element/link"
|
18
|
+
require "syobocal/comment/element/list"
|
19
|
+
require "syobocal/comment/element/row"
|
20
|
+
require "syobocal/comment/element/text"
|
21
|
+
require "syobocal/comment/element/text_node"
|
22
|
+
require "syobocal/comment/element/root"
|
23
|
+
require "syobocal/comment/helper/fragment"
|
24
|
+
require "syobocal/comment/parser"
|
25
|
+
require "syobocal/comment/staff"
|
26
|
+
require "syobocal/comment/cast"
|
27
|
+
require "syobocal/comment/person"
|
28
|
+
require "syobocal/comment/music"
|
29
|
+
require "syobocal/comment/music_data"
|
30
|
+
require "syobocal/comment/section"
|
31
|
+
require "syobocal/sub_titles/sub_title"
|
32
|
+
require "syobocal/sub_titles/parser"
|
14
33
|
|
15
34
|
module Syobocal; end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "syobocal"
|
2
|
+
|
3
|
+
path = "data/db_title_lookup.json"
|
4
|
+
|
5
|
+
if File.exist? path
|
6
|
+
puts "Nothing to do. '#{path}' already exists."
|
7
|
+
else
|
8
|
+
puts "Downloading to '#{path}'."
|
9
|
+
|
10
|
+
open(path, "w") do |f|
|
11
|
+
f.print JSON.pretty_generate(Syobocal::DB::TitleLookup.get({ "TID" => "*" }))
|
12
|
+
end
|
13
|
+
|
14
|
+
puts "Completed."
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "syobocal"
|
2
|
+
require "pp"
|
3
|
+
|
4
|
+
path = "data/db_title_lookup.json"
|
5
|
+
|
6
|
+
json = JSON.parse(File.read(path))
|
7
|
+
|
8
|
+
sections = []
|
9
|
+
|
10
|
+
json.each do |title|
|
11
|
+
puts title["tid"]
|
12
|
+
|
13
|
+
parser = Syobocal::Comment::Parser.new(title["comment"])
|
14
|
+
|
15
|
+
pp parser.parse
|
16
|
+
pp parser.staffs
|
17
|
+
pp parser.casts
|
18
|
+
pp parser.musics
|
19
|
+
pp parser.links
|
20
|
+
end
|
data/syobocal.gemspec
CHANGED
@@ -4,25 +4,32 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require "syobocal/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
7
|
+
spec.name = "syobocal"
|
8
|
+
spec.version = Syobocal::VERSION
|
9
|
+
spec.authors = ["xmisao"]
|
10
|
+
spec.email = ["mail@xmisao.com"]
|
11
11
|
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
12
|
+
spec.summary = "Simple gem for Syoboi Calendar"
|
13
|
+
spec.description = "Syoboi Calendar is the oldest and biggest ANIME information site, supported and hosted by anime fans in Japan. This gem make it easy to download information using web APIs of this site."
|
14
|
+
spec.homepage = "https://github.com/xmisao/syobocal"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Specify which files should be added to the gem when it is released.
|
18
18
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
-
spec.files
|
19
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
21
|
end
|
22
|
-
spec.bindir
|
23
|
-
spec.executables
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
-
spec.add_development_dependency "rake", "
|
27
|
+
spec.add_development_dependency "rake", ">= 13.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "rufo", "~> 0.7"
|
30
|
+
spec.add_dependency "open-uri", "~> 0.2"
|
31
|
+
spec.add_dependency "rexml", "~> 3.2"
|
32
|
+
spec.add_dependency "rss", "~> 0.2"
|
33
|
+
|
34
|
+
spec.required_ruby_version = ">= 3.0.0"
|
28
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syobocal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xmisao
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -26,18 +26,88 @@ dependencies:
|
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rufo
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - "~>"
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
61
|
+
version: '0.7'
|
34
62
|
type: :development
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
68
|
+
version: '0.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: open-uri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rexml
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rss
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.2'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.2'
|
41
111
|
description: Syoboi Calendar is the oldest and biggest ANIME information site, supported
|
42
112
|
and hosted by anime fans in Japan. This gem make it easy to download information
|
43
113
|
using web APIs of this site.
|
@@ -57,22 +127,44 @@ files:
|
|
57
127
|
- Rakefile
|
58
128
|
- bin/console
|
59
129
|
- bin/setup
|
130
|
+
- data/.gitkeep
|
60
131
|
- exe/syobocal
|
61
132
|
- exe/syobocal-anime
|
62
133
|
- lib/syobocal.rb
|
63
134
|
- lib/syobocal/calchk.rb
|
135
|
+
- lib/syobocal/comment/cast.rb
|
136
|
+
- lib/syobocal/comment/element/blank.rb
|
137
|
+
- lib/syobocal/comment/element/header1.rb
|
138
|
+
- lib/syobocal/comment/element/header2.rb
|
139
|
+
- lib/syobocal/comment/element/link.rb
|
140
|
+
- lib/syobocal/comment/element/list.rb
|
141
|
+
- lib/syobocal/comment/element/root.rb
|
142
|
+
- lib/syobocal/comment/element/row.rb
|
143
|
+
- lib/syobocal/comment/element/text.rb
|
144
|
+
- lib/syobocal/comment/element/text_node.rb
|
145
|
+
- lib/syobocal/comment/helper/fragment.rb
|
146
|
+
- lib/syobocal/comment/music.rb
|
147
|
+
- lib/syobocal/comment/music_data.rb
|
148
|
+
- lib/syobocal/comment/parser.rb
|
149
|
+
- lib/syobocal/comment/person.rb
|
150
|
+
- lib/syobocal/comment/section.rb
|
151
|
+
- lib/syobocal/comment/staff.rb
|
64
152
|
- lib/syobocal/db.rb
|
65
153
|
- lib/syobocal/json.rb
|
66
154
|
- lib/syobocal/rss.rb
|
67
155
|
- lib/syobocal/rss2.rb
|
156
|
+
- lib/syobocal/sub_titles/parser.rb
|
157
|
+
- lib/syobocal/sub_titles/sub_title.rb
|
68
158
|
- lib/syobocal/util.rb
|
69
159
|
- lib/syobocal/version.rb
|
160
|
+
- scripts/download_db_title_lookup.rb
|
161
|
+
- scripts/parse_comment.rb
|
70
162
|
- syobocal.gemspec
|
71
163
|
homepage: https://github.com/xmisao/syobocal
|
72
164
|
licenses:
|
73
165
|
- MIT
|
74
166
|
metadata: {}
|
75
|
-
post_install_message:
|
167
|
+
post_install_message:
|
76
168
|
rdoc_options: []
|
77
169
|
require_paths:
|
78
170
|
- lib
|
@@ -80,15 +172,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
80
172
|
requirements:
|
81
173
|
- - ">="
|
82
174
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
175
|
+
version: 3.0.0
|
84
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
177
|
requirements:
|
86
178
|
- - ">="
|
87
179
|
- !ruby/object:Gem::Version
|
88
180
|
version: '0'
|
89
181
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
182
|
+
rubygems_version: 3.2.3
|
183
|
+
signing_key:
|
92
184
|
specification_version: 4
|
93
185
|
summary: Simple gem for Syoboi Calendar
|
94
186
|
test_files: []
|