[banshee] Dap.MassStorage: don't sync 'unknown album' metadata



commit 8370715d55108c82abdcf81dce5f503a0fd57f78
Author: Andres G. Aragoneses <knocte gmail com>
Date:   Sun Nov 27 04:07:09 2011 +0000

    Dap.MassStorage: don't sync 'unknown album' metadata
    
    When a sync via MassStorage Dap happens,
    tracks without album info or singles were
    wrapped in a subfolder called "Unknown Album"
    in the language that Banshee is translated to,
    or a folder with this term in the name.
    
    This is confusing because "Unknown Album"
    is just a placeholder used by Banshee to
    present data in a more aesthetic way when
    it is missing, to also let the user find
    it more easily. The OS of the device should
    instead be the one which decides how to
    handle this data being missing. In this
    case we only adapt MaemoDevice for this
    change because it has a FolderDepth of 2,
    but can also work with a FolderDepth of 1.
    
    For devices with FolderDepth < 2, this
    will be fixed automatically. For devices
    with FolderDepth == 2, their corresponding
    *Device.cs class should be modified in
    case it works properly.

 .../Banshee.Dap.MassStorage/MaemoDevice.cs         |    4 ++++
 .../Banshee.Dap.MassStorage/MassStorageDevice.cs   |    4 ++++
 .../Banshee.Dap.MassStorage/MassStorageSource.cs   |   15 ++++++++++++---
 3 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MaemoDevice.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MaemoDevice.cs
index e299c80..821e961 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MaemoDevice.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MaemoDevice.cs
@@ -122,6 +122,10 @@ namespace Banshee.Dap.MassStorage
             get { return 2; }
         }
 
+        internal override int MinimumFolderDepth {
+            get { return 1; }
+        }
+
         protected override string DefaultCoverArtFileName {
             get { return "cover.jpg"; }
         }
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
index 5da5a9a..78ce92e 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
@@ -203,6 +203,10 @@ namespace Banshee.Dap.MassStorage
             get { return folder_depth; }
         }
 
+        internal virtual int MinimumFolderDepth {
+            get { return FolderDepth; }
+        }
+
         protected virtual string [] DefaultAudioFolders {
             get { return new string[0]; }
         }
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
index 1dc3324..3e02c53 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
@@ -633,6 +633,9 @@ namespace Banshee.Dap.MassStorage
                 // the exact given depth (not including the mount point/audio_folder).
                 if (FolderDepth != -1) {
                     int depth = FolderDepth;
+
+                    bool is_album_unknown = String.IsNullOrEmpty (track.AlbumTitle);
+
                     string album_artist = FileNamePattern.Escape (track.DisplayAlbumArtistName);
                     string track_album  = FileNamePattern.Escape (track.DisplayAlbumTitle);
                     string track_number = FileNamePattern.Escape (String.Format ("{0:00}", track.TrackNumber));
@@ -641,15 +644,21 @@ namespace Banshee.Dap.MassStorage
                     if (depth == 0) {
                         // Artist - Album - 01 - Title
                         string track_artist = FileNamePattern.Escape (track.DisplayArtistName);
-                        file_path = String.Format ("{0} - {1} - {2} - {3}", track_artist, track_album, track_number, track_title);
+                        file_path = is_album_unknown ?
+                            String.Format ("{0} - {1} - {2}", track_artist, track_number, track_title) :
+                            String.Format ("{0} - {1} - {2} - {3}", track_artist, track_album, track_number, track_title);
                     } else if (depth == 1) {
                         // Artist - Album/01 - Title
-                        file_path = String.Format ("{0} - {1}", album_artist, track_album);
+                        file_path = is_album_unknown ?
+                            album_artist :
+                            String.Format ("{0} - {1}", album_artist, track_album);
                         file_path = System.IO.Path.Combine (file_path, String.Format ("{0} - {1}", track_number, track_title));
                     } else if (depth == 2) {
                         // Artist/Album/01 - Title
                         file_path = album_artist;
-                        file_path = System.IO.Path.Combine (file_path, track_album);
+                        if (!is_album_unknown || ms_device.MinimumFolderDepth == depth) {
+                            file_path = System.IO.Path.Combine (file_path, track_album);
+                        }
                         file_path = System.IO.Path.Combine (file_path, String.Format ("{0} - {1}", track_number, track_title));
                     } else {
                         // If the *required* depth is more than 2..go nuts!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]