consolefm 0.1
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.
- data/lib/consolefm.rb +27 -0
- metadata +54 -0
data/lib/consolefm.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'hpricot'
|
3
|
+
|
4
|
+
class ConsoleFM
|
5
|
+
GENRES = ["breaks", "chill-out", "deep-house", "drum-and-bass", "dubstep", "electro-house", "electronica", "funk-r-and-b",
|
6
|
+
"glitch-hop", "hard-dance", "hardcore-hard-techno", "hip-hop", "house", "indie-dance-nu-disco", "minimal", "pop-rock",
|
7
|
+
"progressive-house", "psy-trance", "reggae-dub", "tech-house", "techno", "top", "trance"]
|
8
|
+
|
9
|
+
def self.genres
|
10
|
+
return GENRES
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.valid_genre? genre
|
14
|
+
return GENRES.include? genre
|
15
|
+
end
|
16
|
+
|
17
|
+
# returns an array full of arrays that look like:
|
18
|
+
# [title,artist, href]
|
19
|
+
def self.tracks genre
|
20
|
+
raise 'no such genre' if !(valid_genre? genre)
|
21
|
+
tracks = []
|
22
|
+
(open("http://console.fm/electro-house") { |html| Hpricot(html) }).search("a[@href*=media.console.fm/tracks]").each do |a|
|
23
|
+
tracks << [a.inner_html.match(/(.*?) by (.*?)$/)[1..2], a.get_attribute('href')].flatten
|
24
|
+
end
|
25
|
+
return tracks
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: consolefm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: "0.1"
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Artem Titoulenko
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-10 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: A gem that communicates with console.fm and returns information on all the popular songs on the site for any sub-genre of electronic music
|
17
|
+
email: artem.titoulenko@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/consolefm.rb
|
26
|
+
homepage: https://github.com/ArtemTitoulenko/consolefm
|
27
|
+
licenses: []
|
28
|
+
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: "0"
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
requirements: []
|
47
|
+
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.8
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Grab track info from any genre on console.fm
|
53
|
+
test_files: []
|
54
|
+
|