Merge lp:~mikeycgto/nuvola-player/8tracks-2-0 into lp:nuvola-player/2.5.x

Proposed by mikeycgto
Status: Merged
Approved by: Jiří Janoušek
Approved revision: no longer in the source branch.
Merged at revision: 648
Proposed branch: lp:~mikeycgto/nuvola-player/8tracks-2-0
Merge into: lp:nuvola-player/2.5.x
Diff against target: 236 lines (+80/-101)
2 files modified
data/nuvolaplayer/services/eighttracks/integration.js (+76/-98)
data/nuvolaplayer/services/eighttracks/metadata.conf (+4/-3)
To merge this branch: bzr merge lp:~mikeycgto/nuvola-player/8tracks-2-0
Reviewer Review Type Date Requested Status
Jiří Janoušek Approve
Review via email: mp+148889@code.launchpad.net

Description of the change

Updated 8tracks integration to 2.0 of API.

To post a comment you must log in.
Revision history for this message
Jiří Janoušek (fenryxo) wrote :

Hi. Thanks for fixing and adopting 8tracks service integration. Could you please create a bug report[1] for the issue you have fixed so the fix can be backported to the stable series?

[1] https://bugs.launchpad.net/nuvola-player/+filebug

=== data/nuvolaplayer/services/eighttracks/integration.js

Please add yourself to the list of copyright holders at the beginning of the file.

---

61 - var can_favorite = $("#profile_link").length != 0;

You removed and didn't re-implemented functionality to mark a mix as favorite. Is there any reason for this?

---

126 + // TODO implement NEXT_SONG properly
127 + Nuvola.updateAction(Nuvola.ACTION_NEXT_SONG, true);

Could you elaborate more what do you mean by "implement NEXT_SONG properly"?

=== data/nuvolaplayer/services/eighttracks/metadata.conf
212 +maintainer_link = https://about.me/mikeycgto

"If you want to have your service integration shipped with Nuvola Player, you must use link to your Launchpad profile." [2]

[2] http://nuvolaplayer.fenryxo.cz/contribute/development/service_integration.html

review: Needs Fixing
Revision history for this message
mikeycgto (mikeycgto) wrote :

Just filed the bug (was caused by $j no longer being defined by 8tracks).

Regarding the favorite functionality, I just forgot to re-implement it. I can fix this no problem.

For the updating the NEXT_SONG state, you only have to certain amount of skips on 8tracks (per-mix). There are somethings in the DOM I can use to determine if you can skip the song. I need to just double check a few things and make sure this logic is sound.

Should be able to get these things fixed up and submitted sometime tomorrow. Really love nuvola and will try and help out with service integrations where possible!

Revision history for this message
Jiří Janoušek (fenryxo) wrote :

It's been a while since your last change. Is the branch ready for a review?

Revision history for this message
mikeycgto (mikeycgto) wrote :

Yes, it's ready for review.

On Mon, Feb 25, 2013 at 6:26 AM, Jiří Janoušek <email address hidden>wrote:

> It's been a while since your last change. Is the branch ready for a review?
> --
>
> https://code.launchpad.net/~mikeycgto/nuvola-player/8tracks-2-0/+merge/148889
> You are the owner of lp:~mikeycgto/nuvola-player/8tracks-2-0.
>

--
http://about.me/mikeycgto

Revision history for this message
Jiří Janoušek (fenryxo) wrote :

>Yes, it's ready for review.

Next time, you can comment on the review to get me know the review is ready.

=== file 'data/nuvolaplayer/services/eighttracks/integration.js'

8 + * Copyright 2011-2012 Michael J Coyne <email address hidden>

It should be "Copyright 2013 Michael J Coyne <email address hidden>".

=== file 'data/nuvolaplayer/services/eighttracks/metadata.conf'

231 +maintainer_name = Michael J Coyne
232 +maintainer_link = https://about.me/mikeycgto

Please use your Launchpad profile URL (https://launchpad.net/~mikeycgto) as a maintainer_link.

"If you want to have your service integration shipped with Nuvola Player, you must use link to your Launchpad profile." [2]

[2] http://nuvolaplayer.fenryxo.cz/contribute/development/service_integration.html

review: Needs Fixing
Revision history for this message
mikeycgto (mikeycgto) wrote :

Should be set

Revision history for this message
Jiří Janoušek (fenryxo) wrote :

Great. Will merge on the weekend. Thanks for your work.

review: Approve
647. By Jiří Janoušek

googleplay 3.15: Fixed resolving of a name and an artist of the current song.

Bugs: LP:1138576

648. By mikeycgto

eighttracks 4.0: Adopted. Fixed breakage.

 * Service integration was adopted by Michael J Coyne.

 * Fixed breakage (alert loop) caused by a change in 8tracks web interface.

 * Ported to NP JS API 2.0.

Bugs: LP:1035490, LP:1127488.

Reviewed by: Jiří Janoušek <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/nuvolaplayer/services/eighttracks/integration.js'
2--- data/nuvolaplayer/services/eighttracks/integration.js 2012-08-28 15:42:51 +0000
3+++ data/nuvolaplayer/services/eighttracks/integration.js 2013-02-26 15:23:23 +0000
4@@ -1,6 +1,7 @@
5 /*
6 * Copyright 2011-2012 Janez Troha <janez.troha@gmail.com>
7 * Copyright 2011-2012 Jiří Janoušek <janousek.jiri@gmail.com>
8+ * Copyright 2013 Michael J Coyne <mikeycgto@gmail.com>
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12@@ -24,14 +25,21 @@
13 */
14
15 /* Anonymous function is used not to pollute environment */
16-(function(Nuvola){
17-
18- var get_play_button = function(){
19+(function(Nuvola, $j){
20+ if (!$j) return alert("Unable to find window.jQuery");
21+
22+ function get_play_button(){
23 var play_button = $j('#player_play_button');
24- if(play_button.length == 0) play_button = $j('#play_page span');
25- if(play_button.length == 0) play_button = null;
26+
27+ if (play_button.length == 0) play_button = $j('#play_page span');
28+ if (play_button.length == 0) play_button = null;
29+
30 return play_button;
31 }
32+
33+ function get_favorite_button(){
34+ return $('#like_button');
35+ }
36
37 /**
38 * Creates 8tracks integration binded to Nuvola JS API
39@@ -39,117 +47,87 @@
40 */
41 var Integration = function(){
42 /* Overwrite default commnad function */
43- Nuvola.command = Nuvola.bind(this, this.command);
44-
45- /* For debug output */
46+ Nuvola.onMessageReceived = Nuvola.bind(this, this.messageHandler);
47+
48+ // We can never go back in 8tracks
49+ Nuvola.updateAction(Nuvola.ACTION_PREV_SONG, false);
50+
51 this.name = "8tracks";
52-
53- /* Let's run */
54 this.state = Nuvola.STATE_NONE;
55+
56 this.update();
57- // Periodically update state
58- this.timeout = setInterval(Nuvola.bind(this, this.update), 500);
59 };
60
61 /**
62 * Updates current playback state
63 */
64 Integration.prototype.update = function(){
65-
66- var album = null;
67- var album_art = null;
68- var artist = null;
69- var song = null;
70- var state = Nuvola.STATE_NONE;
71- var can_prev = false;
72- var can_next = false;
73- var can_thumbs_up = false;
74- var can_thumbs_down = false;
75- var can_favorite = $("#profile_link").length != 0;
76-
77- try{
78- song = $(".track.now_playing .t").text();
79- album = $(".track.now_playing .album .detail").text();
80- artist = $(".track.now_playing .a").text();
81- album_art = $("#play_area .cover")[0].src;
82- can_next = true; // FIXME
83-
84- }
85- catch(e){
86- //alert("Unable to grab info:" + e.message);
87- }
88- try{
89- var play_button = $j('#player_play_button');
90- play_button = play_button.length == 0
91- ? null : play_button[0];
92-
93- //~ if(! play_button){
94- //~ play_button = $j('#play_page');
95- //~ play_button = play_button.length == 0
96- //~ ? null : play_button[0];
97- //~ }
98-
99- var pause_button = $j('#player_pause_button');
100- pause_button = pause_button.length == 0
101- ? null : pause_button[0];
102-
103- if(play_button && play_button.style.display != "none"){
104- state = Nuvola.STATE_PAUSED;
105- }
106- else if(pause_button && pause_button.style.display != "none"){
107- state = Nuvola.STATE_PLAYING;
108- }
109- }
110- catch(e){
111- alert("Unable to grab state: " + e.message);
112- }
113-
114- this.state = state;
115- Nuvola.dataChanged(
116- song, artist, album, album_art,
117- state, can_prev, can_next,
118- can_thumbs_up, can_thumbs_down, can_favorite);
119+ var meta = $('#play_area');
120+ var song = meta.find('.t').text();
121+ var artist = meta.find('.a').text();
122+ var album = meta.find('.album .detail').text();
123+ var ab_art = meta.find('.cover').attr('src') || null;
124+
125+ var play_button = $j('#player_play_button');
126+ var pause_button = $j('#player_pause_button');
127+
128+ if (play_button.css('display') != "none"){
129+ this.state = Nuvola.STATE_PAUSED;
130+ } else if (pause_button.css('display') != "none"){
131+ this.state = Nuvola.STATE_PLAYING;
132+ } else {
133+ this.state = Nuvola.STATE_NONE;
134+ }
135+
136+ var can_fav = !!get_favorite_button().length;
137+ var can_next = true;
138+
139+ // Update song information
140+ Nuvola.updateSong(song, artist, album, ab_art, this.state);
141+
142+ // Update actions
143+ Nuvola.updateAction(Nuvola.ACTION_FAVORITE, can_fav);
144+ Nuvola.updateAction(Nuvola.ACTION_NEXT_SONG, can_next);
145+
146+ // Callback in 500ms
147+ setTimeout(Nuvola.bind(this, this.update), 500);
148 }
149-
150-
151+
152 /**
153- * Command handler
154+ * Message Handler
155 * @param cmd command to execute
156 */
157- Integration.prototype.command = function(cmd){
158- try{
159- console.log(this.name + ": " + cmd + ", " + this.state);
160- switch(cmd){
161- case Nuvola.CMD_PAUSE:
162+ Integration.prototype.messageHandler = function(cmd){
163+ switch(cmd){
164+ case Nuvola.ACTION_PAUSE:
165 if(this.state == Nuvola.STATE_PLAYING)
166- window.$j('#player_play_button').trigger('click');
167+ $j('#player_play_button').trigger('click');
168 break;
169- case Nuvola.CMD_PLAY:
170+
171+ case Nuvola.ACTION_PLAY:
172 if(this.state != Nuvola.STATE_PLAYING)
173- window.$j('#player_play_button').trigger('click');
174+ $j('#player_play_button').trigger('click');
175 break;
176- case Nuvola.CMD_TOGGLE:
177+
178+ case Nuvola.ACTION_TOGGLE_PLAY:
179 get_play_button().trigger('click');
180 break;
181- case Nuvola.CMD_NEXT_SONG:
182- window.$j('#player_skip_button').trigger('click');
183- break;
184- case Nuvola.CMD_FAVORITE:
185- window.$j('#like_button input[type="submit"]').trigger("click");
186- break;
187+
188+ case Nuvola.ACTION_NEXT_SONG:
189+ $j('#player_skip_button').trigger('click');
190+ break;
191+
192+ case Nuvola.ACTION_FAVORITE:
193+ get_favorite_button().trigger('click');
194+
195 default:
196- // Other commands are not supported
197- throw {"message": "Not supported."};
198- }
199- console.log(this.name + ": comand '" + cmd + "' executed.");
200- }
201- catch(e){
202- // API expects exception to be a string
203- throw (this.name + ": " + e.message);
204- }
205- }
206-
207-
208- Nuvola.integration = new Integration(); // Singleton ;-)
209-})(window._Nuvola);
210+ throw this.name + ': Action not supported';
211+
212+ console.log(this.name + ": command '" + cmd + "' executed.");
213+ }
214+ };
215+
216+ Nuvola.integration = new Integration();
217+
218+})(this, window.jQuery);
219
220
221=== modified file 'data/nuvolaplayer/services/eighttracks/metadata.conf'
222--- data/nuvolaplayer/services/eighttracks/metadata.conf 2012-07-31 13:51:32 +0000
223+++ data/nuvolaplayer/services/eighttracks/metadata.conf 2013-02-26 15:23:23 +0000
224@@ -1,8 +1,9 @@
225 name = 8tracks
226 home_page = http://8tracks.com/
227 sandbox_pattern = https?://8tracks.com/
228-maintainer_name = Orphaned service
229-maintainer_link = https://answers.launchpad.net/nuvola-player/+faq/2012
230-version = 3
231+maintainer_name = Michael J Coyne
232+maintainer_link = https://launchpad.net/~mikeycgto
233+version = 4
234 version_minor = 0
235+api_major= 2
236 flash_plugin = no

Subscribers

People subscribed via source and target branches