File tree Expand file tree Collapse file tree 4 files changed +23
-10
lines changed
spec/plugins/subscription Expand file tree Collapse file tree 4 files changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ SubscriptionGGuide
188188[Syntax]
189189 - module: SubscriptionGGuide
190190 config:
191- keyword: 'anime' # search word
191+ keyword: 'anime,shogi ' # search word (',' dividing and coming out two or more search)
192192 station: '地上波' # (It means terrestrial broadcasting in Japanese.)
193193 interval: INTERVAL_FOR_SCRAPING (in seconds.)
194194 retry: RETRY_COUNT
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ SubscriptionGGuide
190190[レシピ記法]
191191 - module: SubscriptionGGuide
192192 config:
193- keyword: 'アニメ' # 検索ワード
193+ keyword: 'アニメ,将棋 ' # 検索ワード(','区切りで複数検索)
194194 station: '地上波' # 衛星放送の区域(現在は地上波のみ対応)
195195 interval: スクレイピングの間隔 (秒数, 省略可)
196196 retry: エラー時のリトライ回数 (回数, 省略時 0)
@@ -208,7 +208,7 @@ SubscriptionChanToru
208208[レシピ記法]
209209 - module: SubscriptionChanToru
210210 config:
211- keyword: 'アニメ' # 検索ワード
211+ keyword: 'アニメ,将棋 ' # 検索ワード(','区切りで複数検索)
212212 station: '地上波' # 衛星放送の区域(現在は地上波のみ対応)
213213 interval: スクレイピングの間隔 (秒数, 省略可)
214214 retry: エラー時のリトライ回数 (回数, 省略時 0)
Original file line number Diff line number Diff line change @@ -13,12 +13,19 @@ class SubscriptionGGuide
1313 def initialize ( config , pipeline = [ ] )
1414 @config = config
1515 @pipeline = pipeline
16+ unless @config [ 'keyword' ] . nil? || @config [ 'keyword' ] . index ( ',' ) . nil?
17+ @keywords = @config [ 'keyword' ] . split ( ',' )
18+ else
19+ @keywords = [ @config [ 'keyword' ] ]
20+ end
1621 end
1722
1823 def run
1924 retries = 0
2025 begin
21- @pipeline << Automatic ::FeedParser . get ( feed_url )
26+ @keywords . each { |keyword |
27+ @pipeline << Automatic ::FeedParser . get ( feed_url keyword )
28+ }
2229 rescue
2330 retries += 1
2431 Automatic ::Log . puts ( "error" , "ErrorCount: #{ retries } , Fault in parsing: #{ retries } " )
@@ -28,10 +35,10 @@ def run
2835 @pipeline
2936 end
3037
31- def feed_url
38+ def feed_url keyword = nil
3239 feed = G_GUIDE_RSS
33- unless @config [ ' keyword' ] . nil?
34- feed += "condition.keyword=#{ @config [ ' keyword' ] } &"
40+ unless keyword . nil?
41+ feed += "condition.keyword=#{ keyword } &"
3542 end
3643 feed += station_param
3744 URI . encode ( feed )
Original file line number Diff line number Diff line change @@ -28,12 +28,12 @@ def g_guide(config = {}, pipeline = [])
2828 config = { 'keyword' => 'anime' }
2929 subject { g_guide ( config ) }
3030
31- its ( : feed_url) {
32- should == URI . encode (
31+ it ' feed_url' do
32+ subject . feed_url ( config [ 'keyword' ] ) . should == URI . encode (
3333 Automatic ::Plugin ::SubscriptionGGuide ::G_GUIDE_RSS +
3434 "condition.keyword=#{ config [ 'keyword' ] } &" +
3535 'stationPlatformId=0&' )
36- }
36+ end
3737 end
3838 describe 'station is 地上波' do
3939 config = { 'station' => '地上波' }
@@ -72,5 +72,11 @@ def g_guide(config = {}, pipeline = [])
7272 subject { g_guide ( config ) }
7373 its ( :run ) { should have ( 1 ) . feed }
7474 end
75+
76+ describe 'config keyword ","' do
77+ config = { 'keyword' => 'おじゃる丸,忍たま' , 'station' => '地上波' }
78+ subject { g_guide ( config ) }
79+ its ( :run ) { should have ( 2 ) . feed }
80+ end
7581 end
7682end
You can’t perform that action at this time.
0 commit comments