Difference between revisions of "Patch MediaPlayer Ignore 'A', 'An', and 'The' In Artist and Album names"

From WebOS Internals
Jump to navigation Jump to search
Line 1: Line 1:
 
{{template:patch}}
 
{{template:patch}}
 +
 +
'''Works in 1.1, but might need to check line numbers.  I instead used the context of the patch to get this working.'''
 
The Pre's default music player does not treat artists and albums beginning with 'A', 'An', or 'The' with any special consideration. Thus 'The Killers' shows up under the 'T' section in your list of artists, or an album such as 'The Colour and The Shape' also resides under 'T' in an album title listing.
 
The Pre's default music player does not treat artists and albums beginning with 'A', 'An', or 'The' with any special consideration. Thus 'The Killers' shows up under the 'T' section in your list of artists, or an album such as 'The Colour and The Shape' also resides under 'T' in an album title listing.
  

Revision as of 04:30, 11 August 2009


Works in 1.1, but might need to check line numbers. I instead used the context of the patch to get this working. The Pre's default music player does not treat artists and albums beginning with 'A', 'An', or 'The' with any special consideration. Thus 'The Killers' shows up under the 'T' section in your list of artists, or an album such as 'The Colour and The Shape' also resides under 'T' in an album title listing.

Thankfully, a few simple code changes fix this.

You will need a rooted Pre to apply this patch.

Start by making the file system writable:

rootfs_open -w

We'll begin by change code related to artist names.

The patch for /usr/palm/applications/com.palm.app.musicplayer/app/views/artists/artist-entry.html

--- artist-entry.html.bak Tue Jun 16 20:52:00 2009
+++ artist-entry.html Sun Jul 5 03:12:29 2009
@@ -9,7 +9,7 @@
</div>
<div class="single-album-art-shill"></div>
<div class="title">
- <div class="truncating-text artist-name">#{artistNameFormatted}</div>
+ <div class="truncating-text artist-name">#{artistDisplayNameFormatted}</div>
</div>
</div>
</div> 

The patch for /usr/palm/applications/com.palm.app.musicplayer/app/controllers/artists-assistant.js

--- artists-assistant.js.bak Tue Jun 16 20:52:00 2009
+++ artists-assistant.js Sun Jul 5 03:30:02 2009
@@ -23,7 +23,8 @@
lookahead: 100,
fixedHeightItems: true,
formatters: {
- artistName: Util.artistFormatter
+ artistName: Util.artistFormatter,
+ artistDisplayName: Util.artistFormatter
}
};
this.controller.setupWidget('artistslist', model);
@@ -141,8 +142,15 @@
}.bind(this));
},

+
translateResults: function(filter, widget, offset, response){

+ function sortByArtistDisplayName(a,b) {
+ var x = a.artistDisplayName.toLowerCase();
+ var y = b.artistDisplayName.toLowerCase();
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+ }
+
if(response.artistsTotal == 0){
this.controller.get('no-items-message').innerHTML = AppAssistant.noItems;
this.controller.get('no-items-message').show();
@@ -155,7 +163,25 @@
var ret = {};
ret.list = response.artists;
ret.total = parseInt(response.artistsTotal);
-
+ for (i = 0; i < ret.list.length; i++) {
+ var artistName = ret.list[i].artistName;
+ if (artistName.toUpperCase().indexOf('THE ') == 0) {
+ ret.list[i].artistDisplayName = artistName.substring(4) + ', ' + artistName.substr(0,3);
+ }
+ else
+ if (artistName.toUpperCase().indexOf('A ') == 0) {
+ ret.list[i].artistDisplayName = artistName.substring(2) + ', ' + artistName.substr(0,1);
+ }
+ else
+ if (artistName.toUpperCase().indexOf('AN ') == 0) {
+ ret.list[i].artistDisplayName = artistName.substring(3) + ', ' + artistName.substr(0,2);
+ }
+ else {
+ ret.list[i].artistDisplayName = artistName;
+ }
+ //Mojo.Log.info(ret.list[i].artistDisplayName);
+ }
+ ret.list.sort(sortByArtistDisplayName);
widget.mojo.noticeUpdatedItems(offset, ret.list);
widget.mojo.setCount(ret.total);
widget.mojo.setLength(ret.total);
@@ -188,7 +214,7 @@
},

getAlphaGroup: function(item){
- return Util.getAlphaGroup(item.artistName);
+ return Util.getAlphaGroup(item.artistDisplayName);
},

THUMB_WIDTH: 80, 

Now we'll patch the files necessary for album names.

The patch for /usr/palm/applications/com.palm.app.musicplayer/app/views/allalbums/album-entry.html

--- album-entry.html.bak Sun Jul 5 16:22:02 2009
+++ album-entry.html Sun Jul 5 16:22:27 2009
@@ -8,7 +8,7 @@
</div>
<div class="single-album-art-shill"></div>
<div class="all-albums title">
- <div class="truncating-text all-albums-album-title">#{albumTitleFormatted}</div>
+ <div class="truncating-text all-albums-album-title">#{albumDisplayTitleFormatted}</div>
<div class="truncating-text all-albums-album-artist">#{albumArtistFormatted}</div>
</div>
</div> 

A similar patch for /usr/palm/applications/com.palm.app.musicplayer/app/views/albums/album-entry.html

--- album-entry.html.bak Sun Jul 5 16:01:02 2009
+++ album-entry.html Sun Jul 5 16:01:25 2009
@@ -7,7 +7,7 @@
</div>
<div class="single-album-art-shill"></div>
<div class="title">
- <div class="truncating-text albums-album-title">#{albumTitleFormatted}</div>
+ <div class="truncating-text albums-album-title">#{albumDisplayTitleFormatted}</div>
<!-- <div class="truncating-text albums-album-song-count">#{albumCount}</div> -->
</div>
</div> 

For /usr/palm/applications/com.palm.app.musicplayer/app/controllers/albums-assistant.js

 --- albums-assistant.js.bak Sun Jul 5 16:01:46 2009
+++ albums-assistant.js Sun Jul 5 16:14:41 2009
@@ -24,6 +24,7 @@
fixedHeightItems : true,
formatters: {
albumTitle: Util.albumFormatter,
+ albumDisplayTitle: Util.albumFormatter,
albumPictureUrl: Util.albumArtListUrlFormatter
}
};
@@ -118,6 +119,12 @@


translateResults : function(filter, widget, offset, response){
+
+ function sortByAlbumDisplayTitle(a,b) {
+ var x = a.albumDisplayTitle.toLowerCase();
+ var y = b.albumDisplayTitle.toLowerCase();
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+ }

if(response.albums.length == 0){
this.controller.get('playAllAlbums').hide();
@@ -132,6 +139,26 @@
var ret = {};
ret.list = response.albums;
ret.total = parseInt(response.albumsTotal);
+
+ for (i = 0; i < ret.list.length; i++) {
+ var albumTitle = ret.list[i].albumTitle;
+ if (albumTitle.toUpperCase().indexOf('THE ') == 0) {
+ ret.list[i].albumDisplayTitle = albumTitle.substring(4) + ', ' + albumTitle.substr(0,3);
+ }
+ else
+ if (albumTitle.toUpperCase().indexOf('A ') == 0) {
+ ret.list[i].albumDisplayTitle = albumTitle.substring(2) + ', ' + albumTitle.substr(0,1);
+ }
+ else
+ if (albumTitle.toUpperCase().indexOf('AN ') == 0) {
+ ret.list[i].albumDisplayTitle = albumTitle.substring(3) + ', ' + albumTitle.substr(0,2);
+ }
+ else {
+ ret.list[i].albumDisplayTitle = albumTitle;
+ }
+ //Mojo.Log.info(ret.list[i].albumDisplayTitle);
+ }
+ ret.list.sort(sortByAlbumDisplayTitle);

Util.setZOrder(ret.list, offset); 

For /usr/palm/applications/com.palm.app.musicplayer/app/controllers/allalbums-assistant.js

--- allalbums-assistant.js.bak Sun Jul 5 16:23:16 2009
+++ allalbums-assistant.js Sun Jul 5 16:26:22 2009
@@ -26,6 +26,7 @@
fixedHeightItems : true,
formatters: {
albumTitle: Util.albumFormatter,
+ albumDisplayTitle: Util.albumFormatter,
albumArtist: Util.artistFormatter,
albumPictureUrl: Util.albumArtListUrlFormatter
}
@@ -181,6 +182,12 @@


translateResults : function(filter, widget, offset, response){
+
+ function sortByAlbumDisplayTitle(a,b) {
+ var x = a.albumDisplayTitle.toLowerCase();
+ var y = b.albumDisplayTitle.toLowerCase();
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+ }

if(response.albums.length == 0){
this.controller.get('no-items-message').innerHTML = AppAssistant.noItems;
@@ -193,6 +200,26 @@
var ret = {};
ret.list = response.albums;
ret.total = parseInt(response.albumsTotal);
+
+ for (i = 0; i < ret.list.length; i++) {
+ var albumTitle = ret.list[i].albumTitle;
+ if (albumTitle.toUpperCase().indexOf('THE ') == 0) {
+ ret.list[i].albumDisplayTitle = albumTitle.substring(4) + ', ' + albumTitle.substr(0,3);
+ }
+ else
+ if (albumTitle.toUpperCase().indexOf('A ') == 0) {
+ ret.list[i].albumDisplayTitle = albumTitle.substring(2) + ', ' + albumTitle.substr(0,1);
+ }
+ else
+ if (albumTitle.toUpperCase().indexOf('AN ') == 0) {
+ ret.list[i].albumDisplayTitle = albumTitle.substring(3) + ', ' + albumTitle.substr(0,2);
+ }
+ else {
+ ret.list[i].albumDisplayTitle = albumTitle;
+ }
+ //Mojo.Log.info(ret.list[i].albumDisplayTitle);
+ }
+ ret.list.sort(sortByAlbumDisplayTitle);

Util.setZOrder(ret.list, offset);

@@ -211,7 +238,7 @@
},

getAlphaGroup: function(item){
- return Util.getAlphaGroup(item.albumTitle);
+ return Util.getAlphaGroup(item.albumDisplayTitle);
}
}); 


That's it!

Now lock the file system:

mount -o remount,ro /

And restart LunaSysMgr to apply the changes:

luna-send -n 1 palm://com.palm.applicationManager/rescan {}