top_100 2.1.1 → 3.0.0
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/lib/top_100/artist.rb +1 -1
- data/lib/top_100/billboard_scraper.rb +11 -9
- data/lib/top_100/song.rb +9 -7
- data/lib/top_100/version.rb +1 -1
- data/lib/top_100.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fe32f7a0fab14ff549576f8d75ff1c06c8e0a83
|
4
|
+
data.tar.gz: ec46bebc741cb4276bbede3ff8bb9e48ebdb72d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13c94798d79400eba455a74c85f55153c0e5dfa63d1ef58ed8adeff494b17c7f359f8a6cbc461ae20ccf8c0e9821a7c77648b0de2b4f37c42d6a5c431cbb07d2
|
7
|
+
data.tar.gz: ec2ee9e2c5a2cd7bf452d028630dad6c1a5091c0c63cc6c93785257626de9535701c0c3ab0e6a27510cc30582f73980f62dcff0faf573d8e32c221c71e4fa576
|
data/lib/top_100/artist.rb
CHANGED
@@ -8,7 +8,7 @@ class Artist
|
|
8
8
|
if @songs.empty?
|
9
9
|
self.name = nil
|
10
10
|
else
|
11
|
-
BillboardScraper.scrape_from_artist_bio_page(@songs[0].
|
11
|
+
BillboardScraper.scrape_from_artist_bio_page(@songs[0].artist_url).each {|key, value| self.send("#{key}=", value)}
|
12
12
|
@@artists << self
|
13
13
|
end
|
14
14
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
class BillboardScraper
|
2
2
|
|
3
|
-
|
4
3
|
# will only use class methods, no need to create instances as there's nothing unique between these scrapers and we only need one.
|
5
|
-
|
6
4
|
def self.scrape_from_chart_page
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
billboard_page = Nokogiri::HTML(open('http://www.billboard.com/charts/hot-100'))
|
6
|
+
rss = RSS::Parser.parse(open('http://www.billboard.com/rss/charts/hot-100'))
|
7
|
+
rss.items.each_with_index do |song, index|
|
8
|
+
#account for any song titles that might happen to have ': ' in their title.
|
9
|
+
name = song.title.split(": ")[1..-1].join(": ")
|
10
|
+
rank = song.title.split(": ")[0]
|
10
11
|
song_hash = {
|
11
|
-
rank:
|
12
|
-
name:
|
13
|
-
|
14
|
-
artist_name: song.
|
12
|
+
rank: rank,
|
13
|
+
name: name,
|
14
|
+
#feed doesn't seem to offer an artist value, requiring us to extract artist name from description instead.
|
15
|
+
artist_name: song.description.split("#{name} by ")[1].split(" ranks ##{rank}")[0],
|
16
|
+
artist_url: billboard_page.css('h3.chart-row__artist a.chart-row__link')[index].attribute('href').value + '/biography',
|
15
17
|
}
|
16
18
|
Song.new(song_hash)
|
17
19
|
end
|
data/lib/top_100/song.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Song
|
2
|
-
attr_accessor :rank, :name, :artist_name, :
|
2
|
+
attr_accessor :rank, :name, :artist_name, :artist_url, :url
|
3
3
|
@@songs = []
|
4
4
|
|
5
5
|
def initialize(song_hash)
|
@@ -33,15 +33,17 @@ class Song
|
|
33
33
|
|
34
34
|
def self.play(rank)
|
35
35
|
song = Song.all.find {|song| song.rank == rank }
|
36
|
-
song.url = song.spotify_link
|
37
36
|
if song.nil?
|
38
37
|
puts "You've entered an invalid chart name."
|
39
|
-
#check if song has a valid url, copyright issues with certain songs
|
40
|
-
elsif !!song.url
|
41
|
-
puts "Playing song..."
|
42
|
-
`open #{song.url}`
|
43
38
|
else
|
44
|
-
|
39
|
+
song.url = song.spotify_link
|
40
|
+
#check if song has a valid url, copyright issues with certain songs
|
41
|
+
if !!song.url
|
42
|
+
puts "Playing song..."
|
43
|
+
`open #{song.url}`
|
44
|
+
else
|
45
|
+
puts "Sorry, that artist does not have their song on Spotify."
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
data/lib/top_100/version.rb
CHANGED
data/lib/top_100.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: top_100
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- viparthasarathy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|