buapi 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/buapi.rb +67 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9eae50ef05e032c307fbb717c3809fdba11e310
|
4
|
+
data.tar.gz: 35de0dc18f77ac1b0613eee9a83a4522fb009444
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b183f4e7860cc6f51a8123771a23486c05c123d8aa3b1808cac5ec3d9c3c138bc3d40885524ce4eef7114bd7fd3cc5de162500b0e87b7360298685473c77071
|
7
|
+
data.tar.gz: 1d32cd3fb21e1767dea7a6303169f0c6b618ff23ada5bd0ea59738b8e57418f9737ab58daabb253b5a0197239a0c04e02a815e864c3d2d1266f2037b77ff6bdd
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 John Hager
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/buapi.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module BU
|
5
|
+
class Api
|
6
|
+
def initialize
|
7
|
+
@root = 'http://www.mangaupdates.com'
|
8
|
+
@conn = Faraday.new(url: @root) do |f|
|
9
|
+
f.request(:url_encoded)
|
10
|
+
f.response(:logger)
|
11
|
+
f.adapter(Faraday.default_adapter)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def doc(url)
|
16
|
+
Nokogiri::HTML(@conn.get(url).body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def search(target, post_options)
|
20
|
+
Nokogiri::HTML(
|
21
|
+
@conn.post(target, post_options).body
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def releases(term)
|
26
|
+
search('/search.html', {search: term})
|
27
|
+
end
|
28
|
+
|
29
|
+
def manga(term, type: 'title')
|
30
|
+
search('/series.html', {stype: type, search: term})
|
31
|
+
end
|
32
|
+
|
33
|
+
def series_url(manga)
|
34
|
+
doc = manga(manga)
|
35
|
+
link = doc.css('a').find do |a|
|
36
|
+
a[:alt] == "Series Info" && a.text.downcase == manga.downcase
|
37
|
+
end
|
38
|
+
link ? link[:href].sub(@root, '') : :no_match
|
39
|
+
end
|
40
|
+
|
41
|
+
def series_description(info)
|
42
|
+
info[0].text
|
43
|
+
end
|
44
|
+
|
45
|
+
def series_genres(info)
|
46
|
+
info[14].css('a')[0..-2].map {|a| a.text}
|
47
|
+
end
|
48
|
+
|
49
|
+
def series_scanlators(info)
|
50
|
+
info[4].css('a')
|
51
|
+
.select {|a| a.text != "Less..." && a.text != "More..." }
|
52
|
+
.map {|a| {uri: a[:href], name: a.text} }
|
53
|
+
end
|
54
|
+
|
55
|
+
def series_dashboard(manga)
|
56
|
+
url = series_url(manga)
|
57
|
+
info = doc(url).css('.sMember div.sContent')
|
58
|
+
{
|
59
|
+
id: Integer(url.sub(/.+id=/, '')),
|
60
|
+
description: series_description(info),
|
61
|
+
genres: series_genres(info),
|
62
|
+
scanlators: series_scanlators(info),
|
63
|
+
}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: buapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jphager2
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Useful interface BakaUpdates
|
14
|
+
email: jphager2@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- LICENSE
|
20
|
+
- buapi.rb
|
21
|
+
homepage: https://github.com/jphager2/bakaupdatesapi
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.2.2
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Useful interface BakaUpdates
|
45
|
+
test_files: []
|