tiliado / nuvola-app-amazon-cloud-player

Amazon Cloud Player script for Nuvola Apps Runtime.
https://nuvola.tiliado.eu/app/amazon_cloud_player/
BSD 2-Clause "Simplified" License
7 stars 7 forks source link

Missing title and artist information in the sidebar #5

Closed DavidWiesner closed 8 years ago

DavidWiesner commented 9 years ago

Hi, thanks for your work! I found an issue with your integration. The method 'update' in 'integrate.js' is unable to fetch information about the title and the artist of the current song.

acp-missing title and artist

I don´t know what webengine nuvola 3 beta use but 'innerText' on a text-element is empty. Similar to the nuvola-app-google-play/../integrate.js#L183 I recommend using 'textContent' and 'innerText' to determine the text content of an text element (see also http://perfectionkills.com/the-poor-misunderstood-innerText/).

Here is an example patch:

--- integrate-old.js    2015-11-09 09:37:56.637256248 +0100
+++ integrate.js    2015-11-09 09:47:06.486362774 +0100
@@ -131,8 +131,11 @@

     try {
         var songDetails = playerRoot.getElementsByClassName("currentSongDetails")[0];
-        track.title = songDetails.getElementsByClassName("title")[0].innerText;
-        track.artist = songDetails.getElementsByClassName("artistLink")[0].innerText;
+        var ele;
+        ele = songDetails.getElementsByClassName("title")[0];
+        track.title = ele.textContent || ele.innerText;
+        ele = songDetails.getElementsByClassName("artistLink")[0];
+        track.artist = ele.textContent || ele.innerText;

         var albumImage = playerRoot.getElementsByClassName("albumImage")[0];
         track.artLocation = albumImage.src;

regards, David


Amazon Cloud Player: 5.0 Nuvola Player 3 Beta: 3.0.0+201511042023.413b716

jiri-janousek commented 9 years ago

Hi @DavidWiesner, thanks for noticing this issue. I guess the HTML code of Amazon Cloud Player changed in a way that made innerText broken. I'll take a look at it later today.

DavidWiesner commented 9 years ago

Hi @fenryxo thanks for looking at. But the HTML Code doesn't change, or at least does not effect the parsing. The problem is the webengine and the javascript API to get to the text content of the element. It´s the same element in the DOM, just try the textContent and innerText to get the inner text

jiri-janousek commented 8 years ago

The script used to work fine. Something in the web page must have changed since then and it broke the parsing.

I've made a pull request #6 for @SteVwonder to review.

jiri-janousek commented 8 years ago

Fixed in Amazon Cloud Player script 5.1. Thanks for your bug report.