lastgroov 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # lastgroov: Scrobble recently played tracks from Grooveshark to Last.fm
2
+
3
+ ## Installing
4
+
5
+ $ gem install lastgroov
6
+
7
+
8
+ ## Configuring
9
+
10
+ Create last.yml containing:
11
+ username : lastfm_username
12
+ password : lastfm_password
13
+
14
+ ## Executing
15
+
16
+ $ ./lastgroov
17
+
18
+ ## Author
19
+
20
+ Himanshu Chhetri : http://nepcoder.com
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/bin/lastgroov ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'rubygems'
6
+ require 'lastgroov'
7
+ require 'highline'
8
+ require 'highline/import'
9
+
10
+ groov_user = ask("Enter Grooveshark username: ") { |q| q.echo = true }
11
+ user = ask("Enter Last.fm username: ") { |q| q.echo = true }
12
+ password = ask("Enter Last.fm password: ") { |q| q.echo = false }
13
+ tracks = ask("How many tracks to scrobble (1-100): ", Integer) { |q| q.in = 1..100 }
14
+
15
+ Lastgroov.new(groov_user, user, password, tracks).scrobble!
data/lastgroov.gemspec CHANGED
@@ -5,22 +5,24 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lastgroov}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Himanshu Chhetri"]
12
- s.date = %q{2010-01-06}
12
+ s.date = %q{2010-01-14}
13
+ s.default_executable = %q{lastgroov}
13
14
  s.description = %q{Now you can scrobble Grooveshark music!}
14
15
  s.email = %q{himanshuchhetri@gmail.com}
16
+ s.executables = ["lastgroov"]
15
17
  s.extra_rdoc_files = [
16
- "README"
18
+ "README.md"
17
19
  ]
18
20
  s.files = [
19
21
  ".gitignore",
20
- "README",
22
+ "README.md",
21
23
  "Rakefile",
22
24
  "VERSION",
23
- "lastgroov",
25
+ "bin/lastgroov",
24
26
  "lastgroov.gemspec",
25
27
  "lib/lastgroov.rb"
26
28
  ]
data/lib/lastgroov.rb CHANGED
@@ -1,32 +1,37 @@
1
- # Scrobble recently played tracks from Grooveshark
2
-
3
1
  require 'rubygems'
4
2
  require 'scrobbler'
5
3
  require 'feedzirra'
6
- require 'yaml'
7
4
 
8
5
  class Lastgroov
9
6
 
10
- def initialize(groov_user, scrobbles = 100 )
11
- @scrobbles = scrobbles - 1
12
- $stderr.puts "Invalid number of scrobbles!" if @scrobbles < 0
13
- groov_url = "http://api.grooveshark.com/feeds/1.0/users/"
14
- groov_url << groov_user
15
- groov_url << "/recent_listens.rss"
7
+ attr_accessor :tracks, :groov_user, :feed, :auth
16
8
 
17
- @feed = Feedzirra::Feed.fetch_and_parse(groov_url)
9
+ def initialize(groov_user, user, password, tracks)
10
+ @tracks = tracks - 1
11
+ @groov_user = groov_user
12
+ @auth = Scrobbler::SimpleAuth.new(:user => user,
13
+ :password => password)
14
+ end
18
15
 
19
- config = YAML::load(File.read("last.yml"))
20
- @auth = Scrobbler::SimpleAuth.new(:user => config['username'],
21
- :password => config['password'])
16
+ def parse_rss
17
+ url = "http://api.grooveshark.com/feeds/1.0/users/"
18
+ url << @groov_user
19
+ url << "/recent_listens.rss"
20
+ @feed = Feedzirra::Feed.fetch_and_parse(url)
22
21
  end
23
22
 
24
- def scrobble!
23
+ def authenticate
25
24
  @auth.handshake!
26
- 0.upto(@scrobbles) do |n|
25
+ end
26
+
27
+ def scrobble!
28
+ parse_rss
29
+ authenticate
30
+
31
+ 0.upto(@tracks) do |n|
27
32
  track, artist = @feed.entries[n].title.split(" - ")
28
33
  time = @feed.entries[n].published
29
- scrobble = Scrobbler::Scrobble.new(
34
+ scrobbles = Scrobbler::Scrobble.new(
30
35
  :session_id => @auth.session_id,
31
36
  :submission_url => @auth.submission_url,
32
37
  :artist => artist,
@@ -36,9 +41,11 @@ class Lastgroov
36
41
  :length=> 300,
37
42
  :track_number => n + 1
38
43
  )
39
- scrobble.submit!
44
+
45
+ scrobbles.submit!
46
+
40
47
  puts "#{@feed.entries[n].title}"
41
- puts "Scrobbler Submission Status: #{scrobble.status}"
48
+ puts "Scrobbler Submission Status: #{scrobbles.status}"
42
49
  end
43
50
  end
44
51
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lastgroov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Himanshu Chhetri
@@ -9,24 +9,24 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-06 00:00:00 -06:00
13
- default_executable:
12
+ date: 2010-01-14 00:00:00 -06:00
13
+ default_executable: lastgroov
14
14
  dependencies: []
15
15
 
16
16
  description: Now you can scrobble Grooveshark music!
17
17
  email: himanshuchhetri@gmail.com
18
- executables: []
19
-
18
+ executables:
19
+ - lastgroov
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - README
23
+ - README.md
24
24
  files:
25
25
  - .gitignore
26
- - README
26
+ - README.md
27
27
  - Rakefile
28
28
  - VERSION
29
- - lastgroov
29
+ - bin/lastgroov
30
30
  - lastgroov.gemspec
31
31
  - lib/lastgroov.rb
32
32
  has_rdoc: true
data/README DELETED
@@ -1,19 +0,0 @@
1
- Scrobble recently played tracks from Grooveshark to last.fm
2
-
3
- Installing
4
- ----------
5
- $ gem install lastgroov
6
-
7
- Executing
8
- ---------
9
- Create last.yml containing your last.fm login credentials and then execute 'lastgroov'
10
-
11
- $ cat > last.yml
12
- username : lastfm_username
13
- password : lastfm_password
14
-
15
- $ ./lastgroov
16
-
17
- Author
18
- ------
19
- Himanshu Chhetri : http://nepcoder.com
data/lastgroov DELETED
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'lib/lastgroov'
4
- require 'rubygems'
5
-
6
- print "Enter grooveshark username: "
7
- username = gets.strip
8
-
9
- print "Number of recently played tracks to scrobble(upto 100): "
10
- scrobbles = gets.to_i
11
-
12
- Lastgroov.new(username, scrobbles).scrobble!