Re: [Banshee-List] Cover art patch
- From: Aaron Bockover <abockover novell com>
- To: banshee-list gnome org
- Subject: Re: [Banshee-List] Cover art patch
- Date: Wed, 08 Feb 2006 01:15:01 -0500
I just wrote up a patch for this, loosely based off this code.
Functionally it differs as such:
a) The ASIN cover art in the Banshee cover art location is checked first
b) The ASIN is used to see if an actual amazon-downloaded cover is in
the song's directory
c) Finally check for {[Cc]over,[Ff]older}.{jpg,png,jpeg,gif}, in that
order
Additionally, if a cover is found, its location is cached for the
session.
I'm thinking that maybe the "cover.jpg" check should be first, though
I'd like to think MusicBrainz is always accurate (which it is not :-).
Any thoughts?
For the sake of discussion, I've attached the patch, but it's already
committed.
Also, Pepijn, for future reference, you can create patches against a CVS
checkout, from the *top* of the checkout (i.e. where you see autogen.sh,
configure, etc.):
$ cvs diff -u > mypatch.diff
That will create a patch for any file that differs from what's in the
repo.
cvs diff -u src/Banshee.Base/TrackInfo.cs > TrackInfo.cs-coverart.diff
You can specify files which you only want included in the diff, as I did
to create the attached patch (since I have many other files that differ
locally and are not part of this patch).
If you're working from a tarball, you need to copy the original file
("cp TrackInfo.cs TrackInfo.cs.orig") and then use diff directly ("diff
-u TrackInfo.cs.orig TrackInfo.cs"). However, patches against CVS are
preferred.
Thanks!
--Aaron
On Sat, 2006-01-28 at 22:58 +0100, Pepijn van de Geer wrote:
> Hi all,
>
> First, I really like the Metadata plugin. But unfortunetly it only
> finds the cover art for some of my files. Mostly because of Amazon.
> They don't stock much foreign albums, so all local (dutch) artists
> don't get covers. Since i have coverart for almost every album present
> in the folders allready i decided to make Banshee use them.
> I added a few lines to the CoverArtFileName in the TrackInfo class. I
> don't knwo how to create a .patch file, so here it is. This can be
> easily extended to all kinds of filenames, but this catches most of
> them.
>
> public string CoverArtFileName {
> get {
> string basepath =
> System.IO.Path.GetDirectoryName(Uri.LocalPath) +
> System.IO.Path.DirectorySeparatorChar;
> if (System.IO.File.Exists (basepath + "folder.jpg")) {
> return basepath + "folder.jpg";
> }
> if (System.IO.File.Exists(basepath + "folder.gif")) {
> return basepath + " folder.gif";
> }
> if (System.IO.File.Exists(basepath + "front.jpg")) {
> return basepath + "front.jpg";
> }
> if ( System.IO.File.Exists(basepath + "front.gif")) {
> return basepath + "front.gif";
> }
> if (System.IO.File.Exists(basepath + asin +
> ".01._SCLZZZZZZZ_.jpg")) {
> return basepath + asin + ".01._SCLZZZZZZZ_.jpg";
> }
> string path = Paths.GetCoverArtPath(asin);
> if(System.IO.File.Exists(path)) {
> return path;
> }
> return null;
> }
> }
>
> Cheers,
> Pepijn
> _______________________________________________
> Banshee-list mailing list
> Banshee-list gnome org
> http://mail.gnome.org/mailman/listinfo/banshee-list
Index: src/Banshee.Base/TrackInfo.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/Banshee.Base/TrackInfo.cs,v
retrieving revision 1.5
diff -u -r1.5 TrackInfo.cs
--- src/Banshee.Base/TrackInfo.cs 5 Jan 2006 22:48:36 -0000 1.5
+++ src/Banshee.Base/TrackInfo.cs 8 Feb 2006 06:14:16 -0000
@@ -28,6 +28,7 @@
*/
using System;
+using System.IO;
using Mono.Unix;
using Gtk;
@@ -152,12 +153,39 @@
remote_lookup_status = value;
}
}
-
+
+ private string cover_art_file = null;
public string CoverArtFileName {
get {
+ if(cover_art_file != null) {
+ return cover_art_file;
+ }
+
string path = Paths.GetCoverArtPath(asin);
- if(System.IO.File.Exists(path)) {
+ if(File.Exists(path)) {
+ cover_art_file = path;
+ return path;
+ }
+
+ string basepath = Path.GetDirectoryName(Uri.LocalPath) + Path.DirectorySeparatorChar;
+
+ path = basepath + Asin + ".01._SCLZZZZZZZ_.jpg";
+ if(File.Exists(path)) {
+ cover_art_file = path;
return path;
+ }
+
+ string [] cover_names = { "cover", "Cover", "folder", "Folder" };
+ string [] cover_extensions = { "jpg", "png", "jpeg", "gif" };
+
+ foreach(string cover in cover_names) {
+ foreach(string ext in cover_extensions) {
+ string img = basepath + cover + "." + ext;
+ if(File.Exists(img)) {
+ cover_art_file = img;
+ return img;
+ }
+ }
}
return null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]