massive-scrobbler 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ {.I?V���:g��LY�� �b,�������z[5� �z38}�wf)�nMh�V,�VB�J�1�TX..WdR
@@ -0,0 +1,8 @@
1
+ Manifest
2
+ README.rdoc
3
+ Rakefile
4
+ bin/massive-scrobbler
5
+ lib/massive_scrobbler.rb
6
+ lib/massive_scrobbler/songs.rb
7
+ lib/massive_scrobbler/user.rb
8
+ massive-scrobbler.gemspec
@@ -0,0 +1,32 @@
1
+ = Massive Scrobbler
2
+ === Hack your LastFM account with hundreds of scrobblings in just few minutes :)
3
+
4
+
5
+ == Requirements
6
+ * a LastFM account
7
+ * Ruby
8
+ * RubyGem
9
+
10
+
11
+ == Installation
12
+ gem install massive-scrobbler
13
+
14
+
15
+ == Usage
16
+ Just type in a shell
17
+ massive-scrobbler
18
+ The script scans your current folder searching for audio files, and
19
+ submits them to your LastFM account at high speed (tipically ~0,5 seconds).
20
+
21
+ To manually choose the delay between each submission:
22
+ massive-scrobbler -d [number]
23
+ To simulate a realtime listening:
24
+ massive-scrobbler -d real
25
+
26
+ For other options and help:
27
+ massive-scrobbler --help
28
+
29
+
30
+ == ToDo:
31
+ * more features
32
+ * upgrade to Scrobbler-ng # lastfm API 2.0
@@ -0,0 +1,13 @@
1
+ require 'rubygems' if RUBY_VERSION < '1.9'
2
+ require 'rake'
3
+ require 'echoe'
4
+ $:.unshift( File.dirname( __FILE__ ) + '/lib' )
5
+ require 'massive_scrobbler'
6
+
7
+ Echoe.new('massive-scrobbler', MassiveScrobbler::VERSION) do |p|
8
+ p.description = "Hack your LastFM account with hundreds of scrobblings in just few minutes :)"
9
+ p.url = "http://github.com/nebirhos/massive-scrobbler"
10
+ p.author = 'nebirhos'
11
+ p.email = "nebirhos@aol.com"
12
+ p.extra_deps = [['rockstar', '>=0.4.2'], ['ruby-mp3info', '>=0.6.13'], ['choice', '>=0.1.4']]
13
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems' if RUBY_VERSION < '1.9'
4
+ require 'choice'
5
+
6
+ ROOT_PATH = File.dirname( File.expand_path( File.dirname( __FILE__ ) ) )
7
+ LIB_PATH = File.join( ROOT_PATH, 'lib' )
8
+ $:.unshift( LIB_PATH )
9
+
10
+ require 'massive_scrobbler'
11
+
12
+
13
+ Choice.options do
14
+ header ''
15
+ header 'MassiveScrobbler options:'
16
+
17
+ option :path do
18
+ short '-p'
19
+ long '--path'
20
+ desc 'Path where to search the audio files [default: current directory].'
21
+ default './'
22
+ end
23
+
24
+ option :delay do
25
+ short '-d'
26
+ long '--delay'
27
+ desc 'Delay between each song submission. Choose a # of seconds [default: 0.3]'
28
+ desc "Choose 'real' to scrobble songs like a realtime listening."
29
+ default '0.3'
30
+ end
31
+
32
+ option :verbose do
33
+ short '-v'
34
+ desc "Verbose mode. Print what's going on during its progress."
35
+ end
36
+
37
+ option :help do
38
+ long '--help'
39
+ desc 'Show this message.'
40
+ end
41
+
42
+ option :version do
43
+ long '--version'
44
+ desc 'Show version.'
45
+ action do
46
+ puts "MassiveScrobbler #{MassiveScrobbler::VERSION}"
47
+ exit
48
+ end
49
+ end
50
+ end
51
+
52
+
53
+ MassiveScrobbler.go!( :path => Choice.choices.path,
54
+ :verbose => Choice.choices.verbose,
55
+ :delay => Choice.choices.delay )
@@ -0,0 +1,44 @@
1
+ $: << File.expand_path(File.dirname(__FILE__))
2
+
3
+ require 'massive_scrobbler/songs'
4
+ require 'massive_scrobbler/user'
5
+
6
+ module MassiveScrobbler
7
+
8
+ VERSION = "0.0.2" #:nodoc:
9
+ CONFIG_PATH = File.expand_path '~/.massive-scrobbler'
10
+
11
+
12
+ def MassiveScrobbler.go!(args)
13
+ s = MassiveScrobbler::Songs.new(args[:path])
14
+ u = MassiveScrobbler::User.new(args[:verbose])
15
+ delay = begin
16
+ Float args[:delay]
17
+ rescue
18
+ 0.0
19
+ end
20
+
21
+ s.each_song_with_index do |song, i|
22
+ i += 1
23
+ if song[:artist].nil?
24
+ MassiveScrobbler.puts_status("Skipped song #{song[:path]}", true)
25
+ else
26
+ new_line = (i == s.length || args[:verbose])
27
+ u.scrobble(song)
28
+ MassiveScrobbler.puts_status("Scrobbled #{i} of #{s.length}", new_line)
29
+ delay = song[:length] if args[:delay] == 'real'
30
+ sleep(delay)
31
+ end
32
+ end
33
+
34
+ MassiveScrobbler.puts_status("Done!", true)
35
+ end
36
+
37
+ def MassiveScrobbler.puts_status(string, new_line=nil)
38
+ eol = "\r"
39
+ eol = "\n" if new_line
40
+ STDERR.print(string + eol)
41
+ STDERR.flush
42
+ end
43
+
44
+ end
@@ -0,0 +1,47 @@
1
+ require 'mp3info'
2
+
3
+ module MassiveScrobbler
4
+
5
+ class Songs
6
+ KNOWN_TYPES = ['mp3']
7
+ attr_reader :songs, :path, :length
8
+
9
+ def initialize(path)
10
+ @path = File.expand_path(path)
11
+ @songs = song_search
12
+ @length = @songs.length
13
+ end
14
+
15
+ def song_search(path=@path)
16
+ Dir.entries(path).collect do |entry|
17
+ full_path = File.expand_path(entry, path)
18
+ next if entry == '.'
19
+ next if entry == '..'
20
+ if File.directory? full_path
21
+ song_search(full_path)
22
+ else
23
+ types = KNOWN_TYPES.collect{|t| "\\.#{t}"}.join('|')
24
+ next unless entry =~ /(#{types})$/i
25
+ full_path
26
+ end
27
+ end.flatten.compact
28
+ end
29
+
30
+ def each_song_with_index
31
+ @songs.each_with_index do |song, i|
32
+ mp3info = Mp3Info.open(song) do |mp3|
33
+ { :length => mp3.length.to_i,
34
+ :artist => mp3.tag.artist,
35
+ :title => mp3.tag.title,
36
+ :album => mp3.tag.album,
37
+ :trackn => mp3.tag.tracknum }
38
+ end
39
+ mp3info[:length] = 31 if mp3info[:length] <= 30
40
+ mp3info[:title] ||= File.basename(song)
41
+ mp3info[:path] = song
42
+ yield mp3info, i
43
+ end
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,81 @@
1
+ require 'yaml'
2
+ require 'rockstar'
3
+
4
+ module MassiveScrobbler
5
+
6
+ class User
7
+ attr_reader :user
8
+
9
+ def initialize(verbose=false)
10
+ @verbose = verbose
11
+ if File.exists?(CONFIG_PATH)
12
+ load
13
+ authenticate
14
+ else
15
+ puts "Hey! This seems the first time you launch this script."
16
+ puts "In order to submit your tracks to LastFM, you have to login."
17
+ puts "Please type your username and password (these will be stored in ~/.massive-scrobbler)."
18
+ prompt_for_credentials
19
+ while @user.empty? or @password.empty? or !authenticate
20
+ puts "Invalid login! Retry"
21
+ prompt_for_credentials
22
+ end
23
+ save
24
+ end
25
+ end
26
+
27
+ def prompt_for_credentials
28
+ puts "Username:"
29
+ @user = gets.chomp
30
+ puts "Password:"
31
+ @password = gets.chomp
32
+ end
33
+
34
+ def save
35
+ info = {:user => @user, :password => @password}
36
+ File.open(CONFIG_PATH, 'w') do |conf|
37
+ conf.write info.to_yaml
38
+ end
39
+ end
40
+
41
+ def load
42
+ info = {}
43
+ File.open(CONFIG_PATH) do |conf|
44
+ info = YAML::load(conf.read)
45
+ end
46
+ @user, @password = info[:user], info[:password]
47
+ end
48
+
49
+ def authenticate
50
+ begin
51
+ @auth = Rockstar::SimpleAuth.new(:user => @user, :password => @password)
52
+ @auth.handshake!
53
+ if @verbose
54
+ puts "Auth Status: #{@auth.status}"
55
+ puts "Session ID: #{@auth.session_id}"
56
+ puts "Now Playing URL: #{@auth.now_playing_url}"
57
+ puts "Submission URL: #{@auth.submission_url}"
58
+ end
59
+ true
60
+ rescue BadAuthError
61
+ nil
62
+ end
63
+ end
64
+
65
+ def scrobble(song)
66
+ scrobble = Rockstar::Scrobble.new(:session_id => @auth.session_id,
67
+ :submission_url => @auth.submission_url,
68
+ :artist => song[:artist],
69
+ :track => song[:title],
70
+ :album => song[:album],
71
+ :time => Time.new,
72
+ :length => song[:length],
73
+ :track_number => song[:trackn])
74
+ scrobble.submit!
75
+ if @verbose
76
+ puts "#{song[:artist]} - #{song[:title]}: #{scrobble.status}"
77
+ end
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{massive-scrobbler}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["nebirhos"]
9
+ s.cert_chain = ["/home/istvan/Interzona/Dropbox/Doc/gemcert/gem-public_cert.pem"]
10
+ s.date = %q{2010-10-05}
11
+ s.default_executable = %q{massive-scrobbler}
12
+ s.description = %q{Hack your LastFM account with hundreds of scrobblings in just few minutes :)}
13
+ s.email = %q{nebirhos@aol.com}
14
+ s.executables = ["massive-scrobbler"]
15
+ s.extra_rdoc_files = ["README.rdoc", "bin/massive-scrobbler", "lib/massive_scrobbler.rb", "lib/massive_scrobbler/songs.rb", "lib/massive_scrobbler/user.rb"]
16
+ s.files = ["Manifest", "README.rdoc", "Rakefile", "bin/massive-scrobbler", "lib/massive_scrobbler.rb", "lib/massive_scrobbler/songs.rb", "lib/massive_scrobbler/user.rb", "massive-scrobbler.gemspec"]
17
+ s.homepage = %q{http://github.com/nebirhos/massive-scrobbler}
18
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Massive-scrobbler", "--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{massive-scrobbler}
21
+ s.rubygems_version = %q{1.3.7}
22
+ s.signing_key = %q{/home/istvan/Interzona/Dropbox/Doc/gemcert/gem-private_key.pem}
23
+ s.summary = %q{Hack your LastFM account with hundreds of scrobblings in just few minutes :)}
24
+
25
+ if s.respond_to? :specification_version then
26
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
+ s.specification_version = 3
28
+
29
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
30
+ s.add_runtime_dependency(%q<rockstar>, [">= 0.4.2"])
31
+ s.add_runtime_dependency(%q<ruby-mp3info>, [">= 0.6.13"])
32
+ s.add_runtime_dependency(%q<choice>, [">= 0.1.4"])
33
+ else
34
+ s.add_dependency(%q<rockstar>, [">= 0.4.2"])
35
+ s.add_dependency(%q<ruby-mp3info>, [">= 0.6.13"])
36
+ s.add_dependency(%q<choice>, [">= 0.1.4"])
37
+ end
38
+ else
39
+ s.add_dependency(%q<rockstar>, [">= 0.4.2"])
40
+ s.add_dependency(%q<ruby-mp3info>, [">= 0.6.13"])
41
+ s.add_dependency(%q<choice>, [">= 0.1.4"])
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: massive-scrobbler
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - nebirhos
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MREwDwYDVQQDDAhuZWJp
20
+ cmhvczETMBEGCgmSJomT8ixkARkWA2FvbDETMBEGCgmSJomT8ixkARkWA2NvbTAe
21
+ Fw0xMDEwMDExNjU5MTlaFw0xMTEwMDExNjU5MTlaMD0xETAPBgNVBAMMCG5lYmly
22
+ aG9zMRMwEQYKCZImiZPyLGQBGRYDYW9sMRMwEQYKCZImiZPyLGQBGRYDY29tMIIB
23
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3ladh5V9Db6/jo0khMugQ5jw
24
+ pA4sgTs8fMLDRVkL6Em8dVVShFz78BNNMnmfb8TVoFLUMSwhnu3wsr7CqXCdOugm
25
+ Y8V5oh4N0TILH3MhPIx7OeA8rOYkoDIOJTbzbTHgFtcnxqRoTJkfbsR2cb2aRyqt
26
+ YkP+QJixJFdJhQaiL6z7LC5bGGrPmUOLRDj0keXZ0t+hxm0jJnJ5083yls8GZJSL
27
+ 9KP7koZpG+EmN7GkTizFHk0Xsu8QJnjhwb4hv9W6lNaiBCdOjcrzUPA/wToOJ/R6
28
+ SdOOMU0jEY7/M+4Yr1zxbO/i8UaUzShLmbb2PROfj6t8A6NbYOg3+iM3/RkCPQID
29
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUSvLYE+2W
30
+ GloaoX52pUWU54mojwAwDQYJKoZIhvcNAQEFBQADggEBACRIvS8LsKidDDq2A3FQ
31
+ 77wjk2kE4FMjrCP4oQiNMZlbJI7d1vxuFhnNm3KsQiu26ORx3N96pqVUaLVtma9a
32
+ TmxOzC6hOTeoPrT0MUsksODBeLiudfI1n8dOx6dzHpQ4B294cA2JR4eA0Lh1vDT5
33
+ q/R5D3KYqFgJJWC/NfcWuFzcPlkY3DhNjMRNsyrVo9M6OZxNwlFcVf9eNWeaO52E
34
+ 3GNxRE4pLYdg5KyxDELh2jvgwNcVgOe1iJvgi1qo+H/1i87WSY5vXlShhHPxDpU4
35
+ HZt49vNh/iimoAHCu/s7nBfYQ/WFMzlqPlIuJt1C6/zHk/XCkAr1RK9lA1dxDao8
36
+ z7A=
37
+ -----END CERTIFICATE-----
38
+
39
+ date: 2010-10-05 00:00:00 +02:00
40
+ default_executable:
41
+ dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: rockstar
44
+ prerelease: false
45
+ requirement: &id001 !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 11
51
+ segments:
52
+ - 0
53
+ - 4
54
+ - 2
55
+ version: 0.4.2
56
+ type: :runtime
57
+ version_requirements: *id001
58
+ - !ruby/object:Gem::Dependency
59
+ name: ruby-mp3info
60
+ prerelease: false
61
+ requirement: &id002 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 29
67
+ segments:
68
+ - 0
69
+ - 6
70
+ - 13
71
+ version: 0.6.13
72
+ type: :runtime
73
+ version_requirements: *id002
74
+ - !ruby/object:Gem::Dependency
75
+ name: choice
76
+ prerelease: false
77
+ requirement: &id003 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ hash: 19
83
+ segments:
84
+ - 0
85
+ - 1
86
+ - 4
87
+ version: 0.1.4
88
+ type: :runtime
89
+ version_requirements: *id003
90
+ description: Hack your LastFM account with hundreds of scrobblings in just few minutes :)
91
+ email: nebirhos@aol.com
92
+ executables:
93
+ - massive-scrobbler
94
+ extensions: []
95
+
96
+ extra_rdoc_files:
97
+ - README.rdoc
98
+ - bin/massive-scrobbler
99
+ - lib/massive_scrobbler.rb
100
+ - lib/massive_scrobbler/songs.rb
101
+ - lib/massive_scrobbler/user.rb
102
+ files:
103
+ - Manifest
104
+ - README.rdoc
105
+ - Rakefile
106
+ - bin/massive-scrobbler
107
+ - lib/massive_scrobbler.rb
108
+ - lib/massive_scrobbler/songs.rb
109
+ - lib/massive_scrobbler/user.rb
110
+ - massive-scrobbler.gemspec
111
+ has_rdoc: true
112
+ homepage: http://github.com/nebirhos/massive-scrobbler
113
+ licenses: []
114
+
115
+ post_install_message:
116
+ rdoc_options:
117
+ - --line-numbers
118
+ - --inline-source
119
+ - --title
120
+ - Massive-scrobbler
121
+ - --main
122
+ - README.rdoc
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 3
131
+ segments:
132
+ - 0
133
+ version: "0"
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ hash: 11
140
+ segments:
141
+ - 1
142
+ - 2
143
+ version: "1.2"
144
+ requirements: []
145
+
146
+ rubyforge_project: massive-scrobbler
147
+ rubygems_version: 1.3.7
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: Hack your LastFM account with hundreds of scrobblings in just few minutes :)
151
+ test_files: []
152
+
Binary file