banshee r4239 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Collection src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Metadata src/Core/Banshee.Services/Banshee.Metadata.FileSystem
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4239 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Collection src/Core/Banshee.Services src/Core/Banshee.Services/Banshee.Metadata src/Core/Banshee.Services/Banshee.Metadata.FileSystem
- Date: Tue, 22 Jul 2008 14:37:08 +0000 (UTC)
Author: gburt
Date: Tue Jul 22 14:37:08 2008
New Revision: 4239
URL: http://svn.gnome.org/viewvc/banshee?rev=4239&view=rev
Log:
2008-07-22 Gabriel Burt <gabriel burt gmail com>
* src/Core/Banshee.Services/Banshee.Services.mdp:
* src/Core/Banshee.Services/Makefile.am:
* src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemMetadataProvider.cs:
* src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs:
New provider that gets cover art files from the folder a track is in (BGO
#528137, BGO #336249). Looks for the largest JPG file in the folder.
* src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs: Use the
new provider, after the embedded provider.
* src/Core/Banshee.Core/Banshee.Collection/IBasicTrackInfo.cs: Add Uri
property.
Added:
trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/
trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemMetadataProvider.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/IBasicTrackInfo.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
trunk/banshee/src/Core/Banshee.Services/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/IBasicTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/IBasicTrackInfo.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Collection/IBasicTrackInfo.cs Tue Jul 22 14:37:08 2008
@@ -35,6 +35,7 @@
string AlbumTitle { get; }
string TrackTitle { get; }
string ArtworkId { get; }
+ Banshee.Base.SafeUri Uri { get; }
TrackMediaAttributes MediaAttributes { get; }
}
}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemMetadataProvider.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemMetadataProvider.cs Tue Jul 22 14:37:08 2008
@@ -0,0 +1,49 @@
+//
+// FileSystemMetadataProvider.cs
+//
+// Authors:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Banshee.Base;
+using Banshee.Collection;
+using Banshee.Metadata;
+
+namespace Banshee.Metadata.FileSystem
+{
+ public class FileSystemMetadataProvider : BaseMetadataProvider
+ {
+ public FileSystemMetadataProvider() : base()
+ {
+ }
+
+ public override IMetadataLookupJob CreateJob (IBasicTrackInfo track)
+ {
+ return new FileSystemQueryJob (track);
+ }
+ }
+}
Added: trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata.FileSystem/FileSystemQueryJob.cs Tue Jul 22 14:37:08 2008
@@ -0,0 +1,109 @@
+//
+// FileSystemdQueryJob.cs
+//
+// Authors:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+
+using Hyena;
+
+using Banshee.Base;
+using Banshee.Metadata;
+using Banshee.Collection;
+using Banshee.Streaming;
+
+namespace Banshee.Metadata.FileSystem
+{
+ public class FileSystemQueryJob : MetadataServiceJob
+ {
+ private TrackInfo track;
+ public FileSystemQueryJob (IBasicTrackInfo track)
+ {
+ Track = track;
+ this.track = track as TrackInfo;
+ }
+
+ public override void Run ()
+ {
+ if (Track == null || CoverArtSpec.CoverExists (Track.ArtworkId)) {
+ return;
+ }
+
+ Fetch ();
+ }
+
+ private static string [] extensions = new string [] { ".jpg", ".jpeg" };
+
+ protected void Fetch ()
+ {
+ if (Track.Uri == null || !Track.Uri.IsFile || Track.ArtworkId == null)
+ return;
+
+ string directory = System.IO.Path.GetDirectoryName (Track.Uri.AbsolutePath);
+
+ // Get the largest (in terms of file size) JPEG in the directory
+ long max_size = 0;
+ string best_file = null;
+ int items_in_directory = 0;
+ int max_acceptable_items = Math.Max (20, track.TrackCount + 8);
+ foreach (string file in Banshee.IO.Directory.GetFiles (directory)) {
+ // Ignore directories with tons of songs in them; this lookup is only intended for when the
+ // music file is in a directory specific to its album.
+ if (++items_in_directory > max_acceptable_items) {
+ return;
+ }
+
+ string extension = System.IO.Path.GetExtension (file).ToLower ();
+ if (Array.IndexOf (extensions, extension) != -1) {
+ long size = Banshee.IO.File.GetSize (new SafeUri (file));
+ if (size > max_size) {
+ max_size = size;
+ best_file = file;
+ }
+ }
+ }
+
+ if (best_file != null) {
+ try {
+ // Copy the file to the cover art directory
+ Banshee.IO.File.Copy (new SafeUri (best_file), new SafeUri (CoverArtSpec.GetPath (Track.ArtworkId)), false);
+
+ // Send the new StreamTag
+ StreamTag tag = new StreamTag ();
+ tag.Name = CommonTags.AlbumCoverId;
+ tag.Value = Track.ArtworkId;
+ AddTag (tag);
+
+ Log.Debug ("Got cover art from track's folder", best_file);
+ } catch (Exception e) {
+ Log.Exception (e);
+ }
+ }
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Metadata/MetadataService.cs Tue Jul 22 14:37:08 2008
@@ -57,6 +57,7 @@
public MetadataService ()
{
AddProvider (new Banshee.Metadata.Embedded.EmbeddedMetadataProvider ());
+ AddProvider (new Banshee.Metadata.FileSystem.FileSystemMetadataProvider ());
AddProvider (new Banshee.Metadata.Rhapsody.RhapsodyMetadataProvider ());
AddProvider (new Banshee.Metadata.MusicBrainz.MusicBrainzMetadataProvider ());
AddProvider (new Banshee.Metadata.LastFM.LastFMMetadataProvider ());
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Services.mdp Tue Jul 22 14:37:08 2008
@@ -79,6 +79,8 @@
<File name="Banshee.Metadata/IMetadataProvider.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Metadata/MetadataService.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Metadata/MetadataServiceJob.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Metadata.FileSystem/FileSystemMetadataProvider.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Metadata.FileSystem/FileSystemQueryJob.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Metadata.Embedded/EmbeddedMetadataProvider.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Metadata.Embedded/EmbeddedQueryJob.cs" subtype="Code" buildaction="Compile" />
<File name="Banshee.Metadata.MusicBrainz/MusicBrainzMetadataProvider.cs" subtype="Code" buildaction="Compile" />
Modified: trunk/banshee/src/Core/Banshee.Services/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Makefile.am (original)
+++ trunk/banshee/src/Core/Banshee.Services/Makefile.am Tue Jul 22 14:37:08 2008
@@ -79,6 +79,8 @@
Banshee.MediaProfiles/ProfileConfiguration.cs \
Banshee.Metadata.Embedded/EmbeddedMetadataProvider.cs \
Banshee.Metadata.Embedded/EmbeddedQueryJob.cs \
+ Banshee.Metadata.FileSystem/FileSystemMetadataProvider.cs \
+ Banshee.Metadata.FileSystem/FileSystemQueryJob.cs \
Banshee.Metadata.LastFM/LastFMMetadataProvider.cs \
Banshee.Metadata.LastFM/LastFMQueryJob.cs \
Banshee.Metadata.MusicBrainz/MusicBrainzMetadataProvider.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]