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
=== modified file 'data/nuvolaplayer/services/eighttracks/integration.js'
--- data/nuvolaplayer/services/eighttracks/integration.js 2012-08-28 15:42:51 +0000
+++ data/nuvolaplayer/services/eighttracks/integration.js 2013-02-26 15:23:23 +0000
@@ -1,6 +1,7 @@
1/*1/*
2 * Copyright 2011-2012 Janez Troha <janez.troha@gmail.com>2 * Copyright 2011-2012 Janez Troha <janez.troha@gmail.com>
3 * Copyright 2011-2012 Jiří Janoušek <janousek.jiri@gmail.com>3 * Copyright 2011-2012 Jiří Janoušek <janousek.jiri@gmail.com>
4 * Copyright 2013 Michael J Coyne <mikeycgto@gmail.com>
4 *5 *
5 * Redistribution and use in source and binary forms, with or without6 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
@@ -24,14 +25,21 @@
24 */25 */
2526
26/* Anonymous function is used not to pollute environment */27/* Anonymous function is used not to pollute environment */
27(function(Nuvola){28(function(Nuvola, $j){
28 29 if (!$j) return alert("Unable to find window.jQuery");
29 var get_play_button = function(){30
31 function get_play_button(){
30 var play_button = $j('#player_play_button');32 var play_button = $j('#player_play_button');
31 if(play_button.length == 0) play_button = $j('#play_page span');33
32 if(play_button.length == 0) play_button = null;34 if (play_button.length == 0) play_button = $j('#play_page span');
35 if (play_button.length == 0) play_button = null;
36
33 return play_button;37 return play_button;
34 }38 }
39
40 function get_favorite_button(){
41 return $('#like_button');
42 }
35 43
36 /**44 /**
37 * Creates 8tracks integration binded to Nuvola JS API45 * Creates 8tracks integration binded to Nuvola JS API
@@ -39,117 +47,87 @@
39 */47 */
40 var Integration = function(){48 var Integration = function(){
41 /* Overwrite default commnad function */49 /* Overwrite default commnad function */
42 Nuvola.command = Nuvola.bind(this, this.command);50 Nuvola.onMessageReceived = Nuvola.bind(this, this.messageHandler);
43 51
44 /* For debug output */52 // We can never go back in 8tracks
53 Nuvola.updateAction(Nuvola.ACTION_PREV_SONG, false);
54
45 this.name = "8tracks";55 this.name = "8tracks";
46
47 /* Let's run */
48 this.state = Nuvola.STATE_NONE;56 this.state = Nuvola.STATE_NONE;
57
49 this.update();58 this.update();
50 // Periodically update state
51 this.timeout = setInterval(Nuvola.bind(this, this.update), 500);
52 };59 };
5360
54 /**61 /**
55 * Updates current playback state62 * Updates current playback state
56 */63 */
57 Integration.prototype.update = function(){64 Integration.prototype.update = function(){
58 65 var meta = $('#play_area');
59 var album = null;66 var song = meta.find('.t').text();
60 var album_art = null;67 var artist = meta.find('.a').text();
61 var artist = null;68 var album = meta.find('.album .detail').text();
62 var song = null;69 var ab_art = meta.find('.cover').attr('src') || null;
63 var state = Nuvola.STATE_NONE;70
64 var can_prev = false;71 var play_button = $j('#player_play_button');
65 var can_next = false;72 var pause_button = $j('#player_pause_button');
66 var can_thumbs_up = false;73
67 var can_thumbs_down = false;74 if (play_button.css('display') != "none"){
68 var can_favorite = $("#profile_link").length != 0;75 this.state = Nuvola.STATE_PAUSED;
69 76 } else if (pause_button.css('display') != "none"){
70 try{77 this.state = Nuvola.STATE_PLAYING;
71 song = $(".track.now_playing .t").text();78 } else {
72 album = $(".track.now_playing .album .detail").text();79 this.state = Nuvola.STATE_NONE;
73 artist = $(".track.now_playing .a").text();80 }
74 album_art = $("#play_area .cover")[0].src;81
75 can_next = true; // FIXME82 var can_fav = !!get_favorite_button().length;
76 83 var can_next = true;
77 }84
78 catch(e){85 // Update song information
79 //alert("Unable to grab info:" + e.message);86 Nuvola.updateSong(song, artist, album, ab_art, this.state);
80 }87
81 try{ 88 // Update actions
82 var play_button = $j('#player_play_button');89 Nuvola.updateAction(Nuvola.ACTION_FAVORITE, can_fav);
83 play_button = play_button.length == 0 90 Nuvola.updateAction(Nuvola.ACTION_NEXT_SONG, can_next);
84 ? null : play_button[0];91
85 92 // Callback in 500ms
86 //~ if(! play_button){93 setTimeout(Nuvola.bind(this, this.update), 500);
87 //~ play_button = $j('#play_page');
88 //~ play_button = play_button.length == 0
89 //~ ? null : play_button[0];
90 //~ }
91
92 var pause_button = $j('#player_pause_button');
93 pause_button = pause_button.length == 0
94 ? null : pause_button[0];
95
96 if(play_button && play_button.style.display != "none"){
97 state = Nuvola.STATE_PAUSED;
98 }
99 else if(pause_button && pause_button.style.display != "none"){
100 state = Nuvola.STATE_PLAYING;
101 }
102 }
103 catch(e){
104 alert("Unable to grab state: " + e.message);
105 }
106
107 this.state = state;
108 Nuvola.dataChanged(
109 song, artist, album, album_art,
110 state, can_prev, can_next,
111 can_thumbs_up, can_thumbs_down, can_favorite);
112 }94 }
113 95
114
115 /**96 /**
116 * Command handler97 * Message Handler
117 * @param cmd command to execute98 * @param cmd command to execute
118 */99 */
119 Integration.prototype.command = function(cmd){100 Integration.prototype.messageHandler = function(cmd){
120 try{101 switch(cmd){
121 console.log(this.name + ": " + cmd + ", " + this.state);102 case Nuvola.ACTION_PAUSE:
122 switch(cmd){
123 case Nuvola.CMD_PAUSE:
124 if(this.state == Nuvola.STATE_PLAYING)103 if(this.state == Nuvola.STATE_PLAYING)
125 window.$j('#player_play_button').trigger('click');104 $j('#player_play_button').trigger('click');
126 break;105 break;
127 case Nuvola.CMD_PLAY:106
107 case Nuvola.ACTION_PLAY:
128 if(this.state != Nuvola.STATE_PLAYING)108 if(this.state != Nuvola.STATE_PLAYING)
129 window.$j('#player_play_button').trigger('click');109 $j('#player_play_button').trigger('click');
130 break;110 break;
131 case Nuvola.CMD_TOGGLE:111
112 case Nuvola.ACTION_TOGGLE_PLAY:
132 get_play_button().trigger('click');113 get_play_button().trigger('click');
133 break;114 break;
134 case Nuvola.CMD_NEXT_SONG:115
135 window.$j('#player_skip_button').trigger('click');116 case Nuvola.ACTION_NEXT_SONG:
136 break;117 $j('#player_skip_button').trigger('click');
137 case Nuvola.CMD_FAVORITE:118 break;
138 window.$j('#like_button input[type="submit"]').trigger("click");119
139 break;120 case Nuvola.ACTION_FAVORITE:
121 get_favorite_button().trigger('click');
122
140 default:123 default:
141 // Other commands are not supported124 throw this.name + ': Action not supported';
142 throw {"message": "Not supported."};125
143 }126 console.log(this.name + ": command '" + cmd + "' executed.");
144 console.log(this.name + ": comand '" + cmd + "' executed.");127 }
145 }128 };
146 catch(e){129
147 // API expects exception to be a string130 Nuvola.integration = new Integration();
148 throw (this.name + ": " + e.message);131
149 }132})(this, window.jQuery);
150 }
151
152
153 Nuvola.integration = new Integration(); // Singleton ;-)
154})(window._Nuvola);
155133
156134
=== modified file 'data/nuvolaplayer/services/eighttracks/metadata.conf'
--- data/nuvolaplayer/services/eighttracks/metadata.conf 2012-07-31 13:51:32 +0000
+++ data/nuvolaplayer/services/eighttracks/metadata.conf 2013-02-26 15:23:23 +0000
@@ -1,8 +1,9 @@
1name = 8tracks1name = 8tracks
2home_page = http://8tracks.com/2home_page = http://8tracks.com/
3sandbox_pattern = https?://8tracks.com/3sandbox_pattern = https?://8tracks.com/
4maintainer_name = Orphaned service4maintainer_name = Michael J Coyne
5maintainer_link = https://answers.launchpad.net/nuvola-player/+faq/20125maintainer_link = https://launchpad.net/~mikeycgto
6version = 36version = 4
7version_minor = 07version_minor = 0
8api_major= 2
8flash_plugin = no9flash_plugin = no

Subscribers

People subscribed via source and target branches