tinyscrobbler 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/example.rb +7 -3
- data/lib/parser.rb +7 -2
- data/lib/tinyscrobbler.rb +0 -1
- metadata +1 -1
data/example.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'tinyscrobbler
|
2
|
+
require 'tinyscrobbler'
|
3
3
|
|
4
4
|
ls = Tinyscrobbler::Client.new(lastfm_username, lastfm_password)
|
5
5
|
|
6
6
|
# Currently listening to...
|
7
7
|
|
8
8
|
current_track = {'artistname' => 'Moonspell', 'track' => 'Alma Mater',
|
9
|
-
'time' =>
|
9
|
+
'time' => Time.now.to_s, 'source' => 'P', 'rating' => '',
|
10
10
|
'secs' => '337', 'album' => 'Wolfheart', 'tracknumber' => '8', 'mbtrackid' => ''}
|
11
11
|
|
12
|
+
# now playing notification
|
12
13
|
ls.now_playing(current_track)
|
13
14
|
|
14
|
-
#
|
15
|
+
# lastfm does not submit the track if
|
16
|
+
# half track length has not passed
|
17
|
+
sleep 170
|
15
18
|
|
19
|
+
# after track played, lets submit
|
16
20
|
ls.played(current_track)
|
17
21
|
|
18
22
|
|
data/lib/parser.rb
CHANGED
@@ -7,8 +7,6 @@ module Tinyscrobbler
|
|
7
7
|
# It currently supports only mp3 files.
|
8
8
|
|
9
9
|
class Parser
|
10
|
-
|
11
|
-
attr_accessor :metadata
|
12
10
|
|
13
11
|
# Checks if given file exists and if is supported,
|
14
12
|
# and calls the parser method, if not
|
@@ -23,6 +21,13 @@ module Tinyscrobbler
|
|
23
21
|
@metadata = parse_metadata
|
24
22
|
end
|
25
23
|
|
24
|
+
# Returns the metadata but updates the time param
|
25
|
+
|
26
|
+
def metadata
|
27
|
+
@metadata['time'] = Time.now.to_s
|
28
|
+
@metadata
|
29
|
+
end
|
30
|
+
|
26
31
|
private
|
27
32
|
|
28
33
|
# Returns the file metadata in a hash
|
data/lib/tinyscrobbler.rb
CHANGED