acme-smileage 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/.travis.yml +3 -3
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +215 -215
- data/Rakefile +9 -9
- data/acme-smileage.gemspec +29 -29
- data/bin/smileage +3 -3
- data/lib/acme/smileage.rb +55 -55
- data/lib/acme/smileage/blog/ameblo.rb +49 -49
- data/lib/acme/smileage/blog/ameblo_downloader.rb +171 -171
- data/lib/acme/smileage/blog/entry.rb +51 -51
- data/lib/acme/smileage/commands.rb +16 -16
- data/lib/acme/smileage/commands/base.rb +10 -10
- data/lib/acme/smileage/commands/oricon.rb +47 -47
- data/lib/acme/smileage/commands/soundscan.rb +18 -18
- data/lib/acme/smileage/discography.rb +101 -101
- data/lib/acme/smileage/discography/albums.rb +28 -28
- data/lib/acme/smileage/discography/albums/2009/I001_amanojaku.rb +35 -35
- data/lib/acme/smileage/discography/albums/2009/I002_asuha_date_nanoni_imasugu_koe_ga_kikitai.rb +35 -35
- data/lib/acme/smileage/discography/albums/2009/I003_sukichan.rb +35 -35
- data/lib/acme/smileage/discography/albums/2010/A001_waru_gaki_(1).rb +50 -50
- data/lib/acme/smileage/discography/albums/2010/D001_yumemiru_15sai_(pax_japonica_groove_remix).rb +35 -35
- data/lib/acme/smileage/discography/albums/2010/D002_gambaranakutemo_eenende_(topnude_remix_version_01).rb +35 -35
- data/lib/acme/smileage/discography/albums/2010/D003_onaji_jikyuu_de_hataraku_tomodachi_no_bijin_mama_(remix_type1).rb +35 -35
- data/lib/acme/smileage/discography/albums/2010/I004_otona_ni_narutte_muzukashii.rb +35 -35
- data/lib/acme/smileage/discography/albums/2010/S001_yumemiru_15sai.rb +42 -42
- data/lib/acme/smileage/discography/albums/2010/S002_gambaranakutemo_eenende.rb +47 -47
- data/lib/acme/smileage/discography/albums/2010/S003_onaji_jikyuu_de_hataraku_tomodachi_no_bijin_mama.rb +46 -46
- data/lib/acme/smileage/discography/albums/2011/D004_shortcut_(remixver).rb +35 -35
- data/lib/acme/smileage/discography/albums/2011/D005_uchouten_love_rocketman_mix.rb +35 -35
- data/lib/acme/smileage/discography/albums/2011/S004_shortcut.rb +51 -51
- data/lib/acme/smileage/discography/albums/2011/S005_koi_ni_booing_boo.rb +51 -51
- data/lib/acme/smileage/discography/albums/2011/S006_uchouten_love.rb +51 -51
- data/lib/acme/smileage/discography/albums/2011/S007_tachiagirl.rb +56 -56
- data/lib/acme/smileage/discography/albums/2011/S008_please_minisuka_post_woman.rb +52 -52
- data/lib/acme/smileage/discography/albums/2012/A002_smleage_best_album_complete_(1).rb +54 -54
- data/lib/acme/smileage/discography/albums/2012/S009_choto_mate_kudasai.rb +52 -52
- data/lib/acme/smileage/discography/albums/2012/S010_dotbikini.rb +51 -51
- data/lib/acme/smileage/discography/albums/2012/S011_sukiyo_junjou_hankouki.rb +50 -50
- data/lib/acme/smileage/discography/albums/2012/S012_samuine.rb +50 -50
- data/lib/acme/smileage/discography/albums/2013/A003_(2)_smile_sensation.rb +48 -48
- data/lib/acme/smileage/discography/albums/2013/S013_tabidachi_no_haru_ga_kita.rb +50 -50
- data/lib/acme/smileage/discography/albums/2013/S014_atarashii_watashini_nare_yattaruchan.rb +50 -50
- data/lib/acme/smileage/discography/albums/2013/S015_eeka_iiyatsu.rb +50 -50
- data/lib/acme/smileage/discography/albums/2014/S016_mystery_night_eighteen_emotion.rb +56 -54
- data/lib/acme/smileage/discography/albums/base.rb +37 -37
- data/lib/acme/smileage/discography/hello_project_music_award.rb +22 -22
- data/lib/acme/smileage/discography/lyrics_downloader.rb +48 -48
- data/lib/acme/smileage/discography/sales.rb +43 -43
- data/lib/acme/smileage/discography/tracks.rb +65 -65
- data/lib/acme/smileage/discography/tracks/2009/001_amanojaku.rb +57 -57
- data/lib/acme/smileage/discography/tracks/2009/002_asuha_date_nanoni_imasugu_koe_ga_kikitai.rb +57 -57
- data/lib/acme/smileage/discography/tracks/2009/003_sukichan.rb +57 -57
- data/lib/acme/smileage/discography/tracks/2010/004_otona_ni_narutte_muzukashii.rb +57 -57
- data/lib/acme/smileage/discography/tracks/2010/005_yumemiru_15sai.rb +77 -77
- data/lib/acme/smileage/discography/tracks/2010/006_thank_you_creme_brulee_no_yuujou.rb +37 -37
- data/lib/acme/smileage/discography/tracks/2010/007_yumemiru_15sai_(pax_japonica_groove_remix).rb +38 -38
- data/lib/acme/smileage/discography/tracks/2010/008_gambaranakutemo_eenende.rb +85 -85
- data/lib/acme/smileage/discography/tracks/2010/009_gambaranakutemo_iindayo.rb +44 -44
- data/lib/acme/smileage/discography/tracks/2010/010_smile_bijin.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2010/011_gambaranakutemo_eenende_(topnude_remix_version_01).rb +38 -38
- data/lib/acme/smileage/discography/tracks/2010/012_onaji_jikyuu_de_hataraku_tomodachi_no_bijin_mama.rb +85 -85
- data/lib/acme/smileage/discography/tracks/2010/013_chokotto_love.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2010/014_onaji_jikyuu_de_hataraku_tomodachi_no_bijin_mama_(remix_type1).rb +38 -38
- data/lib/acme/smileage/discography/tracks/2010/015_odorouyo.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2010/016_onna_bakari_no_nichiyoubi.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2010/017_shooting_star.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2010/018_gakkyuu_iinchou.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2010/019_shikkari_shiteyo_mou.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2011/020_shortcut.rb +69 -69
- data/lib/acme/smileage/discography/tracks/2011/021_panyasan_no_arbeit.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2011/022_otome_pasta_ni_kandou.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2011/023_koi_ni_booing_boo.rb +69 -69
- data/lib/acme/smileage/discography/tracks/2011/024_hatukoi_no_anatahe.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2011/025_koi_wo_shichaimashita.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2011/026_uchouten_love.rb +77 -77
- data/lib/acme/smileage/discography/tracks/2011/027_jitensha_chiririn.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2011/028_chu_natsu_party.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2011/029_shortcut_(remixver).rb +37 -37
- data/lib/acme/smileage/discography/tracks/2011/030_uchouten_love_rocketman_mix.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2011/031_tachiagirl.rb +73 -73
- data/lib/acme/smileage/discography/tracks/2011/032_smile_ondon.rb +35 -35
- data/lib/acme/smileage/discography/tracks/2011/033_boogie_train11.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2011/034_smileage_singles_gekimoe_remix.rb +35 -35
- data/lib/acme/smileage/discography/tracks/2011/035_please_minisuka_post_woman.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2011/036_konnichiwa_konbanwa.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2011/037_smileage_singles_gekiyaba_remix.rb +35 -35
- data/lib/acme/smileage/discography/tracks/2011/038_tewo_nigitte_arukitai.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2012/039_choto_mate_kudasai.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2012/040_chance_tourai.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2012/041_smileage_singles_gekiatsu_remix.rb +35 -35
- data/lib/acme/smileage/discography/tracks/2012/042_namida_girl.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2012/043_dotbikini.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2012/044_smile_blues.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2012/045_koibito_ha_kokoro_no_ouendan.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2012/046_kiiroi_jitensha_to_sandwich.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2012/047_sukiyo_junjou_hankouki.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2012/048_kimi_ha_jitensha_watasi_ha_densya_de_kitaku.rb +38 -38
- data/lib/acme/smileage/discography/tracks/2012/049_samuine.rb +49 -49
- data/lib/acme/smileage/discography/tracks/2012/050_watashi_choito_kawaii_urabancho.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/051_tabidachi_no_haru_ga_kita.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2013/052_doushiyou.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/053_shin_nihon_no_susume.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/054_otona_no_tochuu.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/055_tenshin_ramman.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/056_watashi_no_kokoro.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/057_yuugure_koi_no_jikan.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/058_nee_sempai.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/059_sayonara_sayonara_sayonara.rb +36 -36
- data/lib/acme/smileage/discography/tracks/2013/060_atarashii_watashini_nare.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2013/061_yattaruchan.rb +45 -45
- data/lib/acme/smileage/discography/tracks/2013/062_eeka.rb +44 -44
- data/lib/acme/smileage/discography/tracks/2013/063_iiyatsu.rb +44 -44
- data/lib/acme/smileage/discography/tracks/2014/064_mystery_night.rb +44 -44
- data/lib/acme/smileage/discography/tracks/2014/065_eighteen_emotion.rb +44 -44
- data/lib/acme/smileage/discography/tracks/base.rb +39 -39
- data/lib/acme/smileage/members.rb +40 -40
- data/lib/acme/smileage/members/base.rb +56 -56
- data/lib/acme/smileage/members/fukuda_kanon.rb +29 -29
- data/lib/acme/smileage/members/katsuta_rina.rb +29 -29
- data/lib/acme/smileage/members/kosuga_fuyuka.rb +29 -29
- data/lib/acme/smileage/members/maeda_yuuka.rb +29 -29
- data/lib/acme/smileage/members/nakanishi_kana.rb +29 -29
- data/lib/acme/smileage/members/ogawa_saki.rb +29 -29
- data/lib/acme/smileage/members/takeuchi_akari.rb +29 -29
- data/lib/acme/smileage/members/tamura_meimi.rb +29 -29
- data/lib/acme/smileage/members/wada_ayaka.rb +29 -29
- data/lib/acme/smileage/utils/base_downloader.rb +38 -38
- data/lib/acme/smileage/utils/matcher.rb +64 -64
- data/lib/acme/smileage/version.rb +5 -5
- data/lib/acme/smileage/version.rb~ +5 -5
- data/test/acme/test_album.rb +204 -204
- data/test/acme/test_member.rb +45 -45
- data/test/acme/test_smileage.rb +144 -144
- data/test/acme/test_track.rb +57 -57
- data/test/minitest_helper.rb +5 -5
- metadata +20 -20
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.pattern = "test/**/test_*.rb"
|
7
|
-
end
|
8
|
-
|
9
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.pattern = "test/**/test_*.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
task :default => :test
|
data/acme-smileage.gemspec
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'acme/smileage/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "acme-smileage"
|
8
|
-
spec.version = Acme::Smileage::VERSION
|
9
|
-
spec.authors = ["nicochan99"]
|
10
|
-
spec.email = ["nicochan990@yahoo.co.jp"]
|
11
|
-
spec.summary = %q{All about Japanese pop star "S/mileage"}
|
12
|
-
spec.description = %q{"S/mileage" is one of highly famous Japanese pop stars.
|
13
|
-
This module, acme-smileage, provides an easy method to catch up with S/mileage.}
|
14
|
-
spec.homepage = "https://github.com/nicochan99/acme-smileage"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
-
spec.add_development_dependency "rake", "~> 10.2"
|
24
|
-
spec.add_development_dependency "minitest", "~> 5.3"
|
25
|
-
spec.add_runtime_dependency "amatch", '~> 0.3'
|
26
|
-
spec.add_runtime_dependency "moji", '~> 1.6'
|
27
|
-
spec.add_runtime_dependency "nokogiri", '~> 1.6'
|
28
|
-
spec.add_runtime_dependency "thor", '~> 0.19'
|
29
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'acme/smileage/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "acme-smileage"
|
8
|
+
spec.version = Acme::Smileage::VERSION
|
9
|
+
spec.authors = ["nicochan99"]
|
10
|
+
spec.email = ["nicochan990@yahoo.co.jp"]
|
11
|
+
spec.summary = %q{All about Japanese pop star "S/mileage"}
|
12
|
+
spec.description = %q{"S/mileage" is one of highly famous Japanese pop stars.
|
13
|
+
This module, acme-smileage, provides an easy method to catch up with S/mileage.}
|
14
|
+
spec.homepage = "https://github.com/nicochan99/acme-smileage"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.2"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.3"
|
25
|
+
spec.add_runtime_dependency "amatch", '~> 0.3'
|
26
|
+
spec.add_runtime_dependency "moji", '~> 1.6'
|
27
|
+
spec.add_runtime_dependency "nokogiri", '~> 1.6'
|
28
|
+
spec.add_runtime_dependency "thor", '~> 0.19'
|
29
|
+
end
|
data/bin/smileage
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require "acme/smileage/commands"
|
3
|
-
Acme::Smileage::Commands::Main.start
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "acme/smileage/commands"
|
3
|
+
Acme::Smileage::Commands::Main.start
|
data/lib/acme/smileage.rb
CHANGED
@@ -1,55 +1,55 @@
|
|
1
|
-
require "date"
|
2
|
-
|
3
|
-
require "acme/smileage/members"
|
4
|
-
require "acme/smileage/discography"
|
5
|
-
require "acme/smileage/version"
|
6
|
-
|
7
|
-
module Acme
|
8
|
-
class Smileage
|
9
|
-
attr_reader :birthday, :homepage_link
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@birthday = Date.new(2009, 4, 4)
|
13
|
-
@homepage_link = "http://s-mileage.jp"
|
14
|
-
|
15
|
-
@members = Acme::Smileage::Members.new
|
16
|
-
@discography = Acme::Smileage::Discography.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def members(&block)
|
20
|
-
if block
|
21
|
-
@members.members.select(&block)
|
22
|
-
else
|
23
|
-
@members.members.dup
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def discography(&block)
|
28
|
-
@discography.discography(&block)
|
29
|
-
end
|
30
|
-
|
31
|
-
def tracks(&block)
|
32
|
-
@discography.tracks(&block)
|
33
|
-
end
|
34
|
-
|
35
|
-
def blogs(&block)
|
36
|
-
members = block ? @members.select(&block) : @members
|
37
|
-
members = members.select {|e| e.active? }
|
38
|
-
members.map{|e| e.blog_link }.compact.uniq.map {|blog_link|
|
39
|
-
Acme::Smileage::Blog::Ameblo.new(blog_link)
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def find_discography(name)
|
44
|
-
@discography.find_discography(name)
|
45
|
-
end
|
46
|
-
|
47
|
-
def find_track(name)
|
48
|
-
@discography.find_track(name)
|
49
|
-
end
|
50
|
-
|
51
|
-
def oricon_total_sales(&block)
|
52
|
-
@discography.oricon_total_sales(&block)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
require "date"
|
2
|
+
|
3
|
+
require "acme/smileage/members"
|
4
|
+
require "acme/smileage/discography"
|
5
|
+
require "acme/smileage/version"
|
6
|
+
|
7
|
+
module Acme
|
8
|
+
class Smileage
|
9
|
+
attr_reader :birthday, :homepage_link
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@birthday = Date.new(2009, 4, 4)
|
13
|
+
@homepage_link = "http://s-mileage.jp"
|
14
|
+
|
15
|
+
@members = Acme::Smileage::Members.new
|
16
|
+
@discography = Acme::Smileage::Discography.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def members(&block)
|
20
|
+
if block
|
21
|
+
@members.members.select(&block)
|
22
|
+
else
|
23
|
+
@members.members.dup
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def discography(&block)
|
28
|
+
@discography.discography(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def tracks(&block)
|
32
|
+
@discography.tracks(&block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def blogs(&block)
|
36
|
+
members = block ? @members.select(&block) : @members
|
37
|
+
members = members.select {|e| e.active? }
|
38
|
+
members.map{|e| e.blog_link }.compact.uniq.map {|blog_link|
|
39
|
+
Acme::Smileage::Blog::Ameblo.new(blog_link)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def find_discography(name)
|
44
|
+
@discography.find_discography(name)
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_track(name)
|
48
|
+
@discography.find_track(name)
|
49
|
+
end
|
50
|
+
|
51
|
+
def oricon_total_sales(&block)
|
52
|
+
@discography.oricon_total_sales(&block)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "acme/smileage/blog/ameblo_downloader"
|
4
|
-
|
5
|
-
module Acme
|
6
|
-
class Smileage
|
7
|
-
module Blog
|
8
|
-
class Ameblo
|
9
|
-
@@cache = {}
|
10
|
-
|
11
|
-
attr_reader :blog_link, :author
|
12
|
-
|
13
|
-
def initialize(blog_link, author = nil)
|
14
|
-
@blog_link = blog_link
|
15
|
-
@author = author
|
16
|
-
@downloader = Acme::Smileage::Blog::AmebloDownloader.new
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_entry_list(page = 1)
|
20
|
-
c = (@@cache[[self.blog_link, page]] ||= @downloader.get_entry_list(self, self.blog_link, page))
|
21
|
-
|
22
|
-
r = c.dup
|
23
|
-
if self.author
|
24
|
-
r.entries = r.entries.select {|e| e.author == self.author }
|
25
|
-
end
|
26
|
-
r
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_entry_body(entry_header)
|
30
|
-
entry_link = coerce_entry_link(entry_header)
|
31
|
-
@@cache[entry_link] ||= @downloader.get_entry_body(entry_link)
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def coerce_entry_link(x)
|
37
|
-
case x
|
38
|
-
when String, URI
|
39
|
-
x
|
40
|
-
when Acme::Smileage::Blog::Entry::Header
|
41
|
-
x.link
|
42
|
-
else
|
43
|
-
raise ArgumentError, "Invalid entry link: #{x}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require "acme/smileage/blog/ameblo_downloader"
|
4
|
+
|
5
|
+
module Acme
|
6
|
+
class Smileage
|
7
|
+
module Blog
|
8
|
+
class Ameblo
|
9
|
+
@@cache = {}
|
10
|
+
|
11
|
+
attr_reader :blog_link, :author
|
12
|
+
|
13
|
+
def initialize(blog_link, author = nil)
|
14
|
+
@blog_link = blog_link
|
15
|
+
@author = author
|
16
|
+
@downloader = Acme::Smileage::Blog::AmebloDownloader.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_entry_list(page = 1)
|
20
|
+
c = (@@cache[[self.blog_link, page]] ||= @downloader.get_entry_list(self, self.blog_link, page))
|
21
|
+
|
22
|
+
r = c.dup
|
23
|
+
if self.author
|
24
|
+
r.entries = r.entries.select {|e| e.author == self.author }
|
25
|
+
end
|
26
|
+
r
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_entry_body(entry_header)
|
30
|
+
entry_link = coerce_entry_link(entry_header)
|
31
|
+
@@cache[entry_link] ||= @downloader.get_entry_body(entry_link)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def coerce_entry_link(x)
|
37
|
+
case x
|
38
|
+
when String, URI
|
39
|
+
x
|
40
|
+
when Acme::Smileage::Blog::Entry::Header
|
41
|
+
x.link
|
42
|
+
else
|
43
|
+
raise ArgumentError, "Invalid entry link: #{x}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,171 +1,171 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "cgi"
|
4
|
-
|
5
|
-
require "acme/smileage/blog/entry"
|
6
|
-
require "acme/smileage/utils/base_downloader"
|
7
|
-
|
8
|
-
module Acme
|
9
|
-
class Smileage
|
10
|
-
module Blog
|
11
|
-
class AmebloDownloader < Acme::Smileage::Utils::BaseDownloader
|
12
|
-
def get_entry_list(blog, blog_link, page=1)
|
13
|
-
unless blog_link
|
14
|
-
Acme::Smileage::Blog::Entry::List.new
|
15
|
-
end
|
16
|
-
|
17
|
-
with_nokogiri(blog_link, "entrylist-#{page}.html") do |doc, uri|
|
18
|
-
Acme::Smileage::Blog::Entry::List.new {|e|
|
19
|
-
e.link = uri.to_s
|
20
|
-
e.entries = parse_entry_list(blog, doc)
|
21
|
-
e.next_page = parse_next_page(doc)
|
22
|
-
}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_entry_body(entry_link)
|
27
|
-
with_nokogiri(entry_link) do |doc|
|
28
|
-
Acme::Smileage::Blog::Entry::Body.new {|e|
|
29
|
-
e.text = parse_text(doc, ".articleText")
|
30
|
-
e.comment_link = parse_attr(doc, ".commentLink", :href)
|
31
|
-
e.next_entry_link = parse_attr(doc, ".pagingNext", :href)
|
32
|
-
e.prev_entry_link = parse_attr(doc, ".pagingPrev", :href)
|
33
|
-
e.image_links = parse_image_list(doc)
|
34
|
-
e.comments = parse_comment_list(entry_link, doc)
|
35
|
-
}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def parse_entry_list(blog, doc)
|
42
|
-
doc.css(".contentsList li").map {|li|
|
43
|
-
Acme::Smileage::Blog::Entry::Header.new(blog) {|e|
|
44
|
-
e.link = parse_attr(li, ".contentTitle", :href)
|
45
|
-
e.title = parse_text(li, ".contentTitle")
|
46
|
-
e.datetime = parse_text(li, ".contentTime")
|
47
|
-
e.comment_count = parse_number(li, ".contentComment")
|
48
|
-
e.good_count = parse_number(li, "a.skinWeakColor")
|
49
|
-
e.author = guess_author(e.link, e.title)
|
50
|
-
|
51
|
-
e.define_singleton_method(:get_body, Proc.new {
|
52
|
-
blog.get_entry_body(e)
|
53
|
-
})
|
54
|
-
}
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
def parse_next_page(doc)
|
59
|
-
parse_attr(doc, ".listPagePaging .pagingNext", :href) {|href|
|
60
|
-
href[/entrylist-(\d+)/, 1].to_i if href
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
def parse_image_list(doc)
|
65
|
-
doc.css(".articleText a img").map{|e|
|
66
|
-
src = e[:src]
|
67
|
-
if src.sub!(/t[0-9]+_([0-9]+)/) { "o#{$1}" }
|
68
|
-
src
|
69
|
-
end
|
70
|
-
}.compact
|
71
|
-
end
|
72
|
-
|
73
|
-
def parse_comment_list(entry_link, doc)
|
74
|
-
doc.css(".commentList li").map {|li|
|
75
|
-
Acme::Smileage::Blog::Entry::Comment.new {|e|
|
76
|
-
e.link = "%s#%s" % [entry_link, li.css("a")[0][:id]]
|
77
|
-
e.title = parse_text(li, ".commentHeader")
|
78
|
-
e.text = parse_text(li, ".commentBody")
|
79
|
-
e.author = parse_text(li, ".commentAuthor")
|
80
|
-
e.author_link = parse_attr(li, ".commentAuthor", :href)
|
81
|
-
e.datetime = parse_text(li, ".commentTime > time")
|
82
|
-
}
|
83
|
-
}
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
BLOG_ENTRY_AUTHOR_MAPPING = {
|
88
|
-
"http://ameblo.jp/smileage-submember/entry-11018609295.html" => "Katsuta",
|
89
|
-
"http://ameblo.jp/smileage-submember/entry-11039125372.html" => "Nakanishi",
|
90
|
-
"http://ameblo.jp/smileage-submember/entry-11063872434.html" => "Katsuta",
|
91
|
-
"http://ameblo.jp/smileage-submember/entry-11073466463.html" => "Tamura",
|
92
|
-
"http://ameblo.jp/smileage-submember/entry-11155617406.html" => nil, # スタッフ
|
93
|
-
"http://ameblo.jp/smileage-submember/entry-11215252589.html" => "Tamura",
|
94
|
-
"http://ameblo.jp/smileage-submember/entry-11217726959.html" => "Takeuchi",
|
95
|
-
"http://ameblo.jp/smileage-submember/entry-11453335643.html" => "Tamura",
|
96
|
-
"http://ameblo.jp/smileage-submember/entry-11529821236.html" => "Tamura",
|
97
|
-
"http://ameblo.jp/smileage-submember/entry-11545517618.html" => "Takeuchi",
|
98
|
-
"http://ameblo.jp/smileage-submember/entry-11545630723.html" => "Takeuchi",
|
99
|
-
"http://ameblo.jp/smileage-submember/entry-11614497735.html" => nil, # スタッフ
|
100
|
-
"http://ameblo.jp/smileage-submember/entry-11623987909.html" => "Takeuchi",
|
101
|
-
"http://ameblo.jp/smileage-submember/entry-11821080105.html" => "Nakanishi"
|
102
|
-
}
|
103
|
-
|
104
|
-
def guess_author(link, title)
|
105
|
-
if author = BLOG_ENTRY_AUTHOR_MAPPING[link]
|
106
|
-
return author
|
107
|
-
end
|
108
|
-
|
109
|
-
case link
|
110
|
-
when /wadaayaka/
|
111
|
-
"Wada"
|
112
|
-
when /kanon-fukuda/
|
113
|
-
"Fukuda"
|
114
|
-
when /smileage-submember/
|
115
|
-
case title
|
116
|
-
when /中西香菜/, /中西/
|
117
|
-
"Nakanishi"
|
118
|
-
when /竹内朱莉/, /竹内/, /朱莉/
|
119
|
-
"Takeuchi"
|
120
|
-
when /勝田里奈/, /R.?I.?N.?A/i
|
121
|
-
"Katsuta"
|
122
|
-
when /田村芽実/, /田村/, /芽実/
|
123
|
-
"Tamura"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def parse_text(doc, css)
|
129
|
-
e = doc.css(css)
|
130
|
-
return nil if not e
|
131
|
-
|
132
|
-
# これだと改行がうまく変換できない場合があるので自前で処理
|
133
|
-
# e.css("br").each {|ee| ee.replace("\n") }
|
134
|
-
# e.text.strip
|
135
|
-
|
136
|
-
v = e.to_s
|
137
|
-
v.gsub!(/<br\/?>/i, "\n")
|
138
|
-
v.gsub!(%r{<img.*?src="(http://stat\.ameba\.jp/user_images/.*?/)t[0-9]+_([0-9]+\.jpg)".*?>}) { "%so%s" % [$1, $2] }
|
139
|
-
v.gsub!(/<.*?>/, "")
|
140
|
-
v.gsub!(/\r/, "")
|
141
|
-
v.gsub!(/\u00a0/, "")
|
142
|
-
CGI.unescapeHTML(v.strip) if v
|
143
|
-
end
|
144
|
-
|
145
|
-
def parse_number(doc, css)
|
146
|
-
v = parse_text(doc, css)
|
147
|
-
return nil if not v
|
148
|
-
|
149
|
-
vv = v[/\d+/, 0]
|
150
|
-
return nil if not vv
|
151
|
-
|
152
|
-
vv.to_i
|
153
|
-
end
|
154
|
-
|
155
|
-
def parse_attr(doc, css, attr)
|
156
|
-
e = doc.css(css)
|
157
|
-
return nil if not e or e.empty?
|
158
|
-
|
159
|
-
v = e[0][attr]
|
160
|
-
v.strip! if v
|
161
|
-
|
162
|
-
if block_given?
|
163
|
-
yield v
|
164
|
-
else
|
165
|
-
v
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
|
5
|
+
require "acme/smileage/blog/entry"
|
6
|
+
require "acme/smileage/utils/base_downloader"
|
7
|
+
|
8
|
+
module Acme
|
9
|
+
class Smileage
|
10
|
+
module Blog
|
11
|
+
class AmebloDownloader < Acme::Smileage::Utils::BaseDownloader
|
12
|
+
def get_entry_list(blog, blog_link, page=1)
|
13
|
+
unless blog_link
|
14
|
+
Acme::Smileage::Blog::Entry::List.new
|
15
|
+
end
|
16
|
+
|
17
|
+
with_nokogiri(blog_link, "entrylist-#{page}.html") do |doc, uri|
|
18
|
+
Acme::Smileage::Blog::Entry::List.new {|e|
|
19
|
+
e.link = uri.to_s
|
20
|
+
e.entries = parse_entry_list(blog, doc)
|
21
|
+
e.next_page = parse_next_page(doc)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_entry_body(entry_link)
|
27
|
+
with_nokogiri(entry_link) do |doc|
|
28
|
+
Acme::Smileage::Blog::Entry::Body.new {|e|
|
29
|
+
e.text = parse_text(doc, ".articleText")
|
30
|
+
e.comment_link = parse_attr(doc, ".commentLink", :href)
|
31
|
+
e.next_entry_link = parse_attr(doc, ".pagingNext", :href)
|
32
|
+
e.prev_entry_link = parse_attr(doc, ".pagingPrev", :href)
|
33
|
+
e.image_links = parse_image_list(doc)
|
34
|
+
e.comments = parse_comment_list(entry_link, doc)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def parse_entry_list(blog, doc)
|
42
|
+
doc.css(".contentsList li").map {|li|
|
43
|
+
Acme::Smileage::Blog::Entry::Header.new(blog) {|e|
|
44
|
+
e.link = parse_attr(li, ".contentTitle", :href)
|
45
|
+
e.title = parse_text(li, ".contentTitle")
|
46
|
+
e.datetime = parse_text(li, ".contentTime")
|
47
|
+
e.comment_count = parse_number(li, ".contentComment")
|
48
|
+
e.good_count = parse_number(li, "a.skinWeakColor")
|
49
|
+
e.author = guess_author(e.link, e.title)
|
50
|
+
|
51
|
+
e.define_singleton_method(:get_body, Proc.new {
|
52
|
+
blog.get_entry_body(e)
|
53
|
+
})
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
def parse_next_page(doc)
|
59
|
+
parse_attr(doc, ".listPagePaging .pagingNext", :href) {|href|
|
60
|
+
href[/entrylist-(\d+)/, 1].to_i if href
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
def parse_image_list(doc)
|
65
|
+
doc.css(".articleText a img").map{|e|
|
66
|
+
src = e[:src]
|
67
|
+
if src.sub!(/t[0-9]+_([0-9]+)/) { "o#{$1}" }
|
68
|
+
src
|
69
|
+
end
|
70
|
+
}.compact
|
71
|
+
end
|
72
|
+
|
73
|
+
def parse_comment_list(entry_link, doc)
|
74
|
+
doc.css(".commentList li").map {|li|
|
75
|
+
Acme::Smileage::Blog::Entry::Comment.new {|e|
|
76
|
+
e.link = "%s#%s" % [entry_link, li.css("a")[0][:id]]
|
77
|
+
e.title = parse_text(li, ".commentHeader")
|
78
|
+
e.text = parse_text(li, ".commentBody")
|
79
|
+
e.author = parse_text(li, ".commentAuthor")
|
80
|
+
e.author_link = parse_attr(li, ".commentAuthor", :href)
|
81
|
+
e.datetime = parse_text(li, ".commentTime > time")
|
82
|
+
}
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
|
87
|
+
BLOG_ENTRY_AUTHOR_MAPPING = {
|
88
|
+
"http://ameblo.jp/smileage-submember/entry-11018609295.html" => "Katsuta",
|
89
|
+
"http://ameblo.jp/smileage-submember/entry-11039125372.html" => "Nakanishi",
|
90
|
+
"http://ameblo.jp/smileage-submember/entry-11063872434.html" => "Katsuta",
|
91
|
+
"http://ameblo.jp/smileage-submember/entry-11073466463.html" => "Tamura",
|
92
|
+
"http://ameblo.jp/smileage-submember/entry-11155617406.html" => nil, # スタッフ
|
93
|
+
"http://ameblo.jp/smileage-submember/entry-11215252589.html" => "Tamura",
|
94
|
+
"http://ameblo.jp/smileage-submember/entry-11217726959.html" => "Takeuchi",
|
95
|
+
"http://ameblo.jp/smileage-submember/entry-11453335643.html" => "Tamura",
|
96
|
+
"http://ameblo.jp/smileage-submember/entry-11529821236.html" => "Tamura",
|
97
|
+
"http://ameblo.jp/smileage-submember/entry-11545517618.html" => "Takeuchi",
|
98
|
+
"http://ameblo.jp/smileage-submember/entry-11545630723.html" => "Takeuchi",
|
99
|
+
"http://ameblo.jp/smileage-submember/entry-11614497735.html" => nil, # スタッフ
|
100
|
+
"http://ameblo.jp/smileage-submember/entry-11623987909.html" => "Takeuchi",
|
101
|
+
"http://ameblo.jp/smileage-submember/entry-11821080105.html" => "Nakanishi"
|
102
|
+
}
|
103
|
+
|
104
|
+
def guess_author(link, title)
|
105
|
+
if author = BLOG_ENTRY_AUTHOR_MAPPING[link]
|
106
|
+
return author
|
107
|
+
end
|
108
|
+
|
109
|
+
case link
|
110
|
+
when /wadaayaka/
|
111
|
+
"Wada"
|
112
|
+
when /kanon-fukuda/
|
113
|
+
"Fukuda"
|
114
|
+
when /smileage-submember/
|
115
|
+
case title
|
116
|
+
when /中西香菜/, /中西/
|
117
|
+
"Nakanishi"
|
118
|
+
when /竹内朱莉/, /竹内/, /朱莉/
|
119
|
+
"Takeuchi"
|
120
|
+
when /勝田里奈/, /R.?I.?N.?A/i
|
121
|
+
"Katsuta"
|
122
|
+
when /田村芽実/, /田村/, /芽実/
|
123
|
+
"Tamura"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def parse_text(doc, css)
|
129
|
+
e = doc.css(css)
|
130
|
+
return nil if not e
|
131
|
+
|
132
|
+
# これだと改行がうまく変換できない場合があるので自前で処理
|
133
|
+
# e.css("br").each {|ee| ee.replace("\n") }
|
134
|
+
# e.text.strip
|
135
|
+
|
136
|
+
v = e.to_s
|
137
|
+
v.gsub!(/<br\/?>/i, "\n")
|
138
|
+
v.gsub!(%r{<img.*?src="(http://stat\.ameba\.jp/user_images/.*?/)t[0-9]+_([0-9]+\.jpg)".*?>}) { "%so%s" % [$1, $2] }
|
139
|
+
v.gsub!(/<.*?>/, "")
|
140
|
+
v.gsub!(/\r/, "")
|
141
|
+
v.gsub!(/\u00a0/, "")
|
142
|
+
CGI.unescapeHTML(v.strip) if v
|
143
|
+
end
|
144
|
+
|
145
|
+
def parse_number(doc, css)
|
146
|
+
v = parse_text(doc, css)
|
147
|
+
return nil if not v
|
148
|
+
|
149
|
+
vv = v[/\d+/, 0]
|
150
|
+
return nil if not vv
|
151
|
+
|
152
|
+
vv.to_i
|
153
|
+
end
|
154
|
+
|
155
|
+
def parse_attr(doc, css, attr)
|
156
|
+
e = doc.css(css)
|
157
|
+
return nil if not e or e.empty?
|
158
|
+
|
159
|
+
v = e[0][attr]
|
160
|
+
v.strip! if v
|
161
|
+
|
162
|
+
if block_given?
|
163
|
+
yield v
|
164
|
+
else
|
165
|
+
v
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|