emesene forum
September 09, 2010, 08:04:44 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: CACHE KEY ERRORS? NICK NOT SAVED? UPGRADE TO 1.6.2 FIRST!

REPORT ANY ISSUE HERE - PLEASE CHECK IF THE PROBLEM HAS ALREADY BEEN REPORTED FIRST -- THANKS
 
  Home   Forum   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: banshee album arts in current song plugin  (Read 2069 times)
trollhammaren
Full Member
***

l33tness: 1
Offline Offline

Posts: 49


\m/

remcohaszing@gmail.com
View Profile
« on: November 01, 2009, 11:54:52 AM »

the emesene CurrentSong plugin puts the covers in /.covers in your home folder. Banshee stores them in /.cache/album-art and banshee mostly has better ones. So my idea was to make /.covers a link to /.cache/album-art.. The only problem is that they tag the names a little differently both artist-album
but for example
emesene: Cannibal%20Corpse-Butchered%20at%20Birth.jpg
banshee: cannibalcorpse-butcheredatbirth.jpg

If the current song plugin could use the files in /.cache/album-art the covers in emesene would fit much better =]
Logged
braytac
Hero Member
*****

l33tness: 9
Offline Offline

Posts: 202



View Profile WWW Email
« Reply #1 on: November 01, 2009, 02:34:01 PM »

Finntroll ^_^  Grin
Logged
karasu
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 285


Noein

gustaucastells@hotmail.com
View Profile WWW
« Reply #2 on: November 22, 2009, 04:00:26 AM »

Hi! I had the same problem with "sonata", because also stores covers without those %20...

I've proposed a new search_remote_image for this plugin, don't know if it's well coded but works for me :p

http://forum.emesene.org/index.php/topic,2575.0.html

You could also modify the search_local_image function (just for yourself), but I think this should be a configuration option... :p

First you define a new constant:

Code:
BANSHEE_PATH = os.path.join(paths.HOME_DIR, '.cache/album-art','')

And then modify the search_local_image:

Code:
def search_local_image(self):
        '''searches in the local covers cache
        returns None if no local image found'''
       
        artist = self.player.artist.encode('utf8')
        album = self.player.album.encode('utf8')

        file_dsc = COVERART_PATH + artist + '-' + album + '.jpg'
        if os.path.exists(file_dsc):
            return file_dsc

        file_dsc = BANSHEE_PATH + artist + ' - ' + album + '.jpg'
        if os.path.exists(file_dsc):
            return file_dsc

        return None
 

Karasu.
« Last Edit: November 22, 2009, 04:09:13 AM by karasu » Logged

I a vegades... els ocells fan cagarades...
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9989
Offline Offline

Posts: 2327



View Profile Email
« Reply #3 on: November 22, 2009, 08:21:49 AM »

is there somekind of freedesktop spec for this?
Logged
karasu
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 285


Noein

gustaucastells@hotmail.com
View Profile WWW
« Reply #4 on: November 25, 2009, 09:48:18 AM »

Hi,

I've searched in freedesktop.org, and I've only found a spec that says that all program's data that's not critical should go into ~/.cache so it seems that banshee does it well.

BUT (there's always a but) the spec that talks about thumbnails (I know it's not the same) says that they should go in ~/.thumbnails (I think it's because this is not application specific).

If you think about covers as something that's not app specific, it seems a good solution to use ~/.covers .... :p

So, to sum it all, I haven't found an answer to your question, sorry. Maybe somebody with more experience?
Logged

I a vegades... els ocells fan cagarades...
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9989
Offline Offline

Posts: 2327



View Profile Email
« Reply #5 on: November 25, 2009, 10:30:20 AM »

no i'm fine with banshee directory Wink can you give me a diff?
Logged
karasu
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 285


Noein

gustaucastells@hotmail.com
View Profile WWW
« Reply #6 on: November 25, 2009, 02:03:58 PM »

mmmm... I haven't understood you quite well... Do you mean that it should use .covers, .cache/album-art or both? I would use both as there are other players that use .covers... so I've made a diff that uses both directories.

I've removed the call to urllib.quote as it doesn't make sense (and adds those annoying %20). I've also removed all white spaces when searching as it seems that Banshee stores covers without putting them in file names.

Here goes (also attached): 

Code:
--- CurrentSong.py.original 2009-11-25 22:06:49.135682163 +0100
+++ CurrentSong.py.newlocalsearchimage 2009-11-25 22:38:36.186729520 +0100
@@ -34,6 +34,7 @@
     'ResponseGroup=Images&Keywords=%s'
 
 COVERART_PATH = os.path.join(paths.HOME_DIR, '.covers', '')
+BANSHEE_PATH = os.path.join(paths.HOME_DIR, '.cache/album-art','')
 
 class MainClass( Plugin.Plugin ):
     '''Main plugin class'''
@@ -300,8 +301,11 @@
         '''searches in the local covers cache
         returns None if no local image found'''
         
-        artist = urllib.quote(self.player.artist.encode('utf8'))
-        album = urllib.quote(self.player.album.encode('utf8'))
+        artist = self.player.artist.encode('utf8')
+        album = self.player.album.encode('utf8')
+        file_dsc = BANSHEE_PATH + artist.replace(' ', '') + '-' + album.replace(' ', '') + '.jpg'
+        if os.path.exists(file_dsc):
+            return file_dsc
         file_dsc = COVERART_PATH + artist + '-' + album + '.jpg'
         if os.path.exists(file_dsc):
             return file_dsc


Our friend trollhammaren says that the plugin doesn't find good covers as it does banshee. I think that the search function used in the plugin is not working well. I've proposed another one in this thread:

http://forum.emesene.org/index.php/topic,2575.0.html

Could you give it a look, please? Thanks!
Logged

I a vegades... els ocells fan cagarades...
C10uD
ololol
Administrator
Hero Member
*****

l33tness: -9989
Offline Offline

Posts: 2327



View Profile Email
« Reply #7 on: November 25, 2009, 02:23:44 PM »

mm ok fine Smiley the other patch has been applied

this one too
Logged
karasu
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 285


Noein

gustaucastells@hotmail.com
View Profile WWW
« Reply #8 on: November 25, 2009, 02:41:35 PM »

Wow! Thanks a lot!!!!
Logged

I a vegades... els ocells fan cagarades...
trollhammaren
Full Member
***

l33tness: 1
Offline Offline

Posts: 49


\m/

remcohaszing@gmail.com
View Profile
« Reply #9 on: November 29, 2009, 10:07:37 AM »

I ment that it should use the covers in ~/.cache/album-art
Even I could change the path with my 0% experience in programming..
but the album arts in ~/.cache/album-art are named differently from what the plugin names them.
If the plugin would use the album arts in ~/.cache/album-art it would use the same album arts as banshee does, banshee gets more album arts right than this emesene plugin.
Logged
karasu
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 285


Noein

gustaucastells@hotmail.com
View Profile WWW
« Reply #10 on: November 29, 2009, 02:03:24 PM »

Yep, I got that Wink

Have you tested the new version? It should get a lot more covers, and also get the ones in your banshee directory (even they are named different).

EDIT: I've just noticed (as it's in the first post) that banshee uses low caps for all names in its files... :S so I think it won't work as it is now. Please, confirm that banshee uses always low caps and I'll try to change it in the code.
« Last Edit: November 29, 2009, 02:35:00 PM by karasu » Logged

I a vegades... els ocells fan cagarades...
mike.longbow
Newbie
*

l33tness: 0
Offline Offline

Posts: 2



View Profile WWW Email
« Reply #11 on: November 29, 2009, 08:37:46 PM »

Yep, I got that Wink

Have you tested the new version? It should get a lot more covers, and also get the ones in your banshee directory (even they are named different).

EDIT: I've just noticed (as it's in the first post) that banshee uses low caps for all names in its files... :S so I think it won't work as it is now. Please, confirm that banshee uses always low caps and I'll try to change it in the code.

It totally does. Every file I got under ~/.cache/album-art is in low caps, no spaces and non alphanumeric chars are excluded, except for the dividing hyphen.

E.g. "caftacvba-cuatrocaminos[.jpg]" stands for "Café Tacvba - Cuatro Caminos" (notice the lack of "é").

I hope it helps. I'm glad someone else beside me has addressed this issue. If I had the time right now I would try to fix this one, but unfortunately I don't.

Let me know if I could be of any more help.
Logged

Dubium sapientiae initium. --R. Descartes
karasu
Hero Member
*****

l33tness: 4
Offline Offline

Posts: 285


Noein

gustaucastells@hotmail.com
View Profile WWW
« Reply #12 on: December 01, 2009, 02:59:58 PM »

Hi!

Hopefully this should do the trick... (I've attached the whole currentSong.py)

Code:
    def search_local_image(self):
        '''searches in the local covers cache
        returns None if no local image found'''
       
        artist = self.player.artist.encode('utf8')
        album = self.player.album.encode('utf8')
       
        bartist = re.sub("\W", "",artist).lower()
        balbum = re.sub("\W", "",album).lower()
        file_dsc = BANSHEE_PATH + bartist + '-' + balbum + '.jpg'
        if os.path.exists(file_dsc):
            return file_dsc
       
        file_dsc = COVERART_PATH + artist + '-' + album + '.jpg'
        if os.path.exists(file_dsc):
            return file_dsc
        return None
Logged

I a vegades... els ocells fan cagarades...
mike.longbow
Newbie
*

l33tness: 0
Offline Offline

Posts: 2



View Profile WWW Email
« Reply #13 on: December 01, 2009, 11:21:49 PM »

Yes!

I've just added those lines to my CurrentSong.py and yes, indeed, that did it.

Thanks a lot, and I'm glad I could help.

And a message to myself: I need to learn more about those regular expressions things...
Logged

Dubium sapientiae initium. --R. Descartes
trollhammaren
Full Member
***

l33tness: 1
Offline Offline

Posts: 49


\m/

remcohaszing@gmail.com
View Profile
« Reply #14 on: December 02, 2009, 05:44:50 AM »

Yay it works ^^
Logged
Pages: [1] 2
  Print  
 
Jump to:  

TinyPortal v.1.0.6 beta 2 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!