dutch_top40 0.1.2 → 0.1.3
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/Gemfile.lock +1 -1
- data/lib/dutch_top40.rb +1 -1
- data/lib/dutch_top40/cli.rb +1 -2
- data/lib/dutch_top40/scraper.rb +19 -0
- data/lib/dutch_top40/songs.rb +1 -12
- data/lib/dutch_top40/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cac142781191f70c98ade529228eb77889f100e01d56a921b77235e074fdb58e
|
|
4
|
+
data.tar.gz: c421ad5174499a51e8ae83bf76ecda996a0bff229a1af0b5a1b83e524ed56de4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee146cc1375899512f759fdf27c25447fd3ba938b48627efd29e95629f85c619d0984ed2e972074f3cb2466e35a4a779d0299f852711369a16ff2a2e8db5ad55
|
|
7
|
+
data.tar.gz: 7d2db0fbeef8fdf06e3cbbbbf76b962969367af7a017cc006ba3bee3e61ab2b50b84e1d0ce2e93955a8c01f2179c9b6746828d4d9ae85478e8898082cf9d7671
|
data/Gemfile.lock
CHANGED
data/lib/dutch_top40.rb
CHANGED
data/lib/dutch_top40/cli.rb
CHANGED
|
@@ -5,7 +5,6 @@ class DutchTop40::CLI
|
|
|
5
5
|
puts "Dutch Top40 - week #{Time.now.strftime("%U")}", ""
|
|
6
6
|
puts "One moment, acquiring data."
|
|
7
7
|
list_songs
|
|
8
|
-
sleep(5)
|
|
9
8
|
menu
|
|
10
9
|
end
|
|
11
10
|
|
|
@@ -30,7 +29,7 @@ class DutchTop40::CLI
|
|
|
30
29
|
when 1..@songs.size
|
|
31
30
|
puts "Current rank #{input}."
|
|
32
31
|
puts "#{@songs[input.to_i-1].title} - performing artist(s): #{@songs[input.to_i-1].name}"
|
|
33
|
-
puts "weeks
|
|
32
|
+
puts "weeks in Top40: #{@songs[input.to_i-1].listed} - last weeks rank: #{@songs[input.to_i-1].last_weeks_rank}",""
|
|
34
33
|
else
|
|
35
34
|
puts "Invalid input!" unless input == 'exit' || input == 'list'
|
|
36
35
|
if input == 'list'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class DutchTop40::Scraper
|
|
2
|
+
|
|
3
|
+
attr_accessor :title, :name, :listed, :last_weeks_rank
|
|
4
|
+
|
|
5
|
+
def self.scrape_songs
|
|
6
|
+
doc = Nokogiri::HTML(open("http://top40.nl"))
|
|
7
|
+
doc.search('.listScroller').search('.top40List').each do |song|
|
|
8
|
+
title = song.search('.songtitle').text.strip
|
|
9
|
+
name = song.search('.artist').text
|
|
10
|
+
listed = song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip
|
|
11
|
+
if song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip == '-'
|
|
12
|
+
last_weeks_rank = 'new entry'
|
|
13
|
+
else
|
|
14
|
+
last_weeks_rank = song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
|
|
15
|
+
end
|
|
16
|
+
DutchTop40::Songs.new(title, name, listed, last_weeks_rank)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/dutch_top40/songs.rb
CHANGED
|
@@ -14,18 +14,7 @@ class DutchTop40::Songs
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def self.list
|
|
17
|
-
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.scrape_songs
|
|
21
|
-
doc = Nokogiri::HTML(open("http://top40.nl"))
|
|
22
|
-
doc.search('.listScroller').search('.top40List').each do |song|
|
|
23
|
-
title = song.search('.songtitle').text.strip
|
|
24
|
-
name = song.search('.artist').text
|
|
25
|
-
listed = song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip
|
|
26
|
-
last_weeks_rank = song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
|
|
27
|
-
self.new(title, name, listed, last_weeks_rank)
|
|
28
|
-
end
|
|
17
|
+
DutchTop40::Scraper.scrape_songs
|
|
29
18
|
@@songs
|
|
30
19
|
end
|
|
31
20
|
|
data/lib/dutch_top40/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dutch_top40
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- raspimeteo
|
|
@@ -61,6 +61,7 @@ files:
|
|
|
61
61
|
- dutch_top40.gemspec
|
|
62
62
|
- lib/dutch_top40.rb
|
|
63
63
|
- lib/dutch_top40/cli.rb
|
|
64
|
+
- lib/dutch_top40/scraper.rb
|
|
64
65
|
- lib/dutch_top40/songs.rb
|
|
65
66
|
- lib/dutch_top40/version.rb
|
|
66
67
|
homepage: https://github.com/raspimeteo/dutch_top40
|