shroom 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README +25 -3
- data/Rakefile +1 -1
- data/lib/sh_actions.rb +146 -0
- data/lib/sh_album.rb +1 -7
- data/lib/sh_browse.rb +41 -95
- data/lib/sh_cover_art.rb +16 -23
- data/lib/sh_cover_browse.rb +54 -0
- data/lib/sh_database.rb +4 -4
- data/lib/sh_global.rb +39 -22
- data/lib/sh_log.rb +78 -0
- data/lib/sh_lyrics.rb +2 -55
- data/lib/sh_main.rb +10 -6
- data/lib/sh_player.rb +2 -4
- data/lib/sh_playlist.rb +91 -6
- data/lib/sh_plugin.rb +31 -7
- data/lib/sh_song.rb +13 -10
- data/lib/sh_tagreader.rb +59 -32
- data/lib/sh_util.rb +33 -68
- data/lib/sh_view.rb +106 -76
- data/lib/shroom-res/plugins/lastfm_scrobbler.rb +65 -21
- data/lib/shroom-res/shroom.glade +1 -95
- metadata +5 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'scrobbler'
|
1
3
|
require 'ping'
|
2
4
|
require 'thread'
|
3
5
|
|
@@ -5,27 +7,69 @@ Sh::Plugin.define "lastfm_scrobbler" do
|
|
5
7
|
name "Last.fm Scrobbler"
|
6
8
|
description "This plugin submits listening data to Last.fm (http://last.fm/)."
|
7
9
|
author "Aiden Nibali"
|
8
|
-
version "0.0.
|
10
|
+
version "0.0.2"
|
9
11
|
|
10
|
-
|
12
|
+
def init prefs
|
13
|
+
prefs ||= {}
|
14
|
+
@scrobble_queue = []
|
15
|
+
@user = prefs[:lastfm_user]
|
16
|
+
@password = prefs[:lastfm_password]
|
17
|
+
end
|
18
|
+
|
19
|
+
def preferences
|
20
|
+
prefs = {
|
21
|
+
:lastfm_user => @user,
|
22
|
+
:lastfm_password => @password
|
23
|
+
}
|
24
|
+
return prefs
|
25
|
+
end
|
26
|
+
|
27
|
+
def edit_preferences
|
28
|
+
dialog = Dialog.new("Last.fm Details",
|
29
|
+
nil,
|
30
|
+
nil,
|
31
|
+
[Stock::OK, Dialog::RESPONSE_NONE])
|
32
|
+
vbox = dialog.vbox
|
33
|
+
hbox = HBox.new
|
34
|
+
lbl_user = Label.new "Username:"
|
35
|
+
txt_user = Entry.new
|
36
|
+
txt_user.text = @user || ""
|
37
|
+
hbox.add lbl_user
|
38
|
+
hbox.add txt_user
|
39
|
+
vbox.add hbox
|
40
|
+
hbox = HBox.new
|
41
|
+
lbl_pass = Label.new "Password:"
|
42
|
+
txt_pass = Entry.new
|
43
|
+
txt_pass.visibility = false
|
44
|
+
txt_pass.text = @password || ""
|
45
|
+
hbox.add lbl_pass
|
46
|
+
hbox.add txt_pass
|
47
|
+
vbox.add hbox
|
48
|
+
vbox.show_all
|
49
|
+
dialog.signal_connect('response') do
|
50
|
+
@user = txt_user.text
|
51
|
+
@password = txt_pass.text
|
52
|
+
dialog.destroy
|
53
|
+
end
|
54
|
+
dialog.run
|
55
|
+
return preferences
|
56
|
+
end
|
11
57
|
|
12
58
|
# This method is called when a song stops playing (not paused, but stopped)
|
13
59
|
def on_player_stopped player
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
60
|
+
song, play_time, duration = player.song, player.play_time, player.duration
|
61
|
+
if play_time > 240 or (play_time > duration.to_f / 2 and duration > 30)
|
62
|
+
@scrobble_queue.insert 0, {
|
63
|
+
:artist => song.artist.name,
|
64
|
+
:track => song.title,
|
65
|
+
:album => song.album.title,
|
66
|
+
:time => Time.new,
|
67
|
+
:length => duration,
|
68
|
+
:track_number => song.track_num
|
69
|
+
}
|
25
70
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
71
|
+
# Scrobble if Audioscrobbler is reachable
|
72
|
+
submit_scrobbles! if Ping.pingecho("post.audioscrobbler.com", 10)
|
29
73
|
end
|
30
74
|
end
|
31
75
|
|
@@ -33,11 +77,11 @@ Sh::Plugin.define "lastfm_scrobbler" do
|
|
33
77
|
(@mutex ||= Mutex.new).synchronize do
|
34
78
|
auth = @scrobble_auth
|
35
79
|
if not auth or auth.status.strip.upcase != 'OK'
|
36
|
-
user, pass = Sh::Global.prefs[:lastfm_user], Sh::Global.prefs[:lastfm_password]
|
37
80
|
begin
|
38
|
-
|
81
|
+
details = {:user => @user, :password => @password}
|
82
|
+
auth = @scrobble_auth = Scrobbler::SimpleAuth.new(details)
|
39
83
|
auth.handshake!
|
40
|
-
|
84
|
+
Sh::Log.debug "Last.fm authentication status is \"#{auth.status}\""
|
41
85
|
rescue
|
42
86
|
end
|
43
87
|
end
|
@@ -58,9 +102,9 @@ Sh::Plugin.define "lastfm_scrobbler" do
|
|
58
102
|
end
|
59
103
|
|
60
104
|
if scrobble and scrobble.status.strip.upcase == 'OK'
|
61
|
-
|
105
|
+
Sh::Log.debug "Scrobble for \"#{scrobble.track}\" succeeded"
|
62
106
|
else
|
63
|
-
|
107
|
+
Sh::Log.info "Failed to scrobble for \"#{scrobble.track}\""
|
64
108
|
failed_scrobbles.insert 0, hash
|
65
109
|
end
|
66
110
|
end
|
data/lib/shroom-res/shroom.glade
CHANGED
@@ -49,101 +49,7 @@
|
|
49
49
|
</packing>
|
50
50
|
</child>
|
51
51
|
<child>
|
52
|
-
<
|
53
|
-
<property name="visible">True</property>
|
54
|
-
<property name="label_xalign">0</property>
|
55
|
-
<property name="shadow_type">none</property>
|
56
|
-
<child>
|
57
|
-
<widget class="GtkAlignment" id="alignment1">
|
58
|
-
<property name="visible">True</property>
|
59
|
-
<property name="left_padding">12</property>
|
60
|
-
<child>
|
61
|
-
<widget class="GtkVBox" id="vbox2">
|
62
|
-
<property name="visible">True</property>
|
63
|
-
<property name="orientation">vertical</property>
|
64
|
-
<child>
|
65
|
-
<widget class="GtkCheckButton" id="chk_lastfm">
|
66
|
-
<property name="label" translatable="yes">Scrobble to Last.fm</property>
|
67
|
-
<property name="visible">True</property>
|
68
|
-
<property name="can_focus">True</property>
|
69
|
-
<property name="receives_default">False</property>
|
70
|
-
<property name="draw_indicator">True</property>
|
71
|
-
</widget>
|
72
|
-
<packing>
|
73
|
-
<property name="position">0</property>
|
74
|
-
</packing>
|
75
|
-
</child>
|
76
|
-
<child>
|
77
|
-
<widget class="GtkTable" id="table1">
|
78
|
-
<property name="visible">True</property>
|
79
|
-
<property name="n_rows">2</property>
|
80
|
-
<property name="n_columns">2</property>
|
81
|
-
<child>
|
82
|
-
<widget class="GtkEntry" id="txt_lastfm_user">
|
83
|
-
<property name="visible">True</property>
|
84
|
-
<property name="can_focus">True</property>
|
85
|
-
<property name="invisible_char">●</property>
|
86
|
-
</widget>
|
87
|
-
<packing>
|
88
|
-
<property name="left_attach">1</property>
|
89
|
-
<property name="right_attach">2</property>
|
90
|
-
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
|
91
|
-
</packing>
|
92
|
-
</child>
|
93
|
-
<child>
|
94
|
-
<widget class="GtkEntry" id="txt_lastfm_pass">
|
95
|
-
<property name="visible">True</property>
|
96
|
-
<property name="can_focus">True</property>
|
97
|
-
<property name="visibility">False</property>
|
98
|
-
<property name="invisible_char">●</property>
|
99
|
-
</widget>
|
100
|
-
<packing>
|
101
|
-
<property name="left_attach">1</property>
|
102
|
-
<property name="right_attach">2</property>
|
103
|
-
<property name="top_attach">1</property>
|
104
|
-
<property name="bottom_attach">2</property>
|
105
|
-
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
|
106
|
-
</packing>
|
107
|
-
</child>
|
108
|
-
<child>
|
109
|
-
<widget class="GtkLabel" id="label1">
|
110
|
-
<property name="visible">True</property>
|
111
|
-
<property name="label" translatable="yes">Username: </property>
|
112
|
-
</widget>
|
113
|
-
</child>
|
114
|
-
<child>
|
115
|
-
<widget class="GtkLabel" id="label2">
|
116
|
-
<property name="visible">True</property>
|
117
|
-
<property name="label" translatable="yes">Password: </property>
|
118
|
-
</widget>
|
119
|
-
<packing>
|
120
|
-
<property name="top_attach">1</property>
|
121
|
-
<property name="bottom_attach">2</property>
|
122
|
-
</packing>
|
123
|
-
</child>
|
124
|
-
</widget>
|
125
|
-
<packing>
|
126
|
-
<property name="position">1</property>
|
127
|
-
</packing>
|
128
|
-
</child>
|
129
|
-
</widget>
|
130
|
-
</child>
|
131
|
-
</widget>
|
132
|
-
</child>
|
133
|
-
<child>
|
134
|
-
<widget class="GtkLabel" id="lbl_lastfm">
|
135
|
-
<property name="visible">True</property>
|
136
|
-
<property name="label" translatable="yes"><b>Last.fm</b></property>
|
137
|
-
<property name="use_markup">True</property>
|
138
|
-
</widget>
|
139
|
-
<packing>
|
140
|
-
<property name="type">label_item</property>
|
141
|
-
</packing>
|
142
|
-
</child>
|
143
|
-
</widget>
|
144
|
-
<packing>
|
145
|
-
<property name="position">1</property>
|
146
|
-
</packing>
|
52
|
+
<placeholder/>
|
147
53
|
</child>
|
148
54
|
</widget>
|
149
55
|
<packing>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shroom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aiden Nibali
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-02 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -132,9 +132,12 @@ files:
|
|
132
132
|
- lib/sh_queue.rb
|
133
133
|
- lib/sh_album.rb
|
134
134
|
- lib/sh_playlist.rb
|
135
|
+
- lib/sh_cover_browse.rb
|
135
136
|
- lib/sh_song.rb
|
136
137
|
- lib/sh_artist.rb
|
138
|
+
- lib/sh_actions.rb
|
137
139
|
- lib/sh_plugin.rb
|
140
|
+
- lib/sh_log.rb
|
138
141
|
- lib/sh_cover_art.rb
|
139
142
|
- lib/sh_tagreader.rb
|
140
143
|
- lib/sh_plasma.rb
|