Bug 262668 - Bad .cue gives some trouble
Summary: Bad .cue gives some trouble
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Unclassified
Component: Playlist (show other bugs)
Version: 2.4-GIT
Platform: openSUSE RPMs Linux
: NOR normal (vote)
Target Milestone: 2.4.0
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-09 16:42 UTC by Lisp2D
Modified: 2011-01-13 11:43 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.4.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lisp2D 2011-01-09 16:42:12 UTC
Version:           2.3.0
OS:                Linux

I have file a.cue with wrong file-names or without some songs.
All songs received Wrong song-length, Wrong kbps, Wrong KHz.
And most beautiful: Ignoring option NOT loading a cover.

Loading covers will stop all actions from me. (bug II)


Reproducible: Didn't try
Comment 1 Myriam Schweingruber 2011-01-09 19:48:20 UTC
Please upgrade to Amarok 2.3.2 and try again.
Comment 2 Lisp2D 2011-01-10 20:27:26 UTC
In openSuSe upgrading is very hard:

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:70 (MESSAGE):
  Could NOT find Taglib (missing: TAGLIB_INCLUDES TAGLIB_LIBRARIES)

It seems for me to simple wait for a miracle from openSuSe.
Comment 3 Myriam Schweingruber 2011-01-10 22:14:11 UTC
You should ask in the OpenSUSE forum to get help.
Comment 4 Lisp2D 2011-01-11 17:21:50 UTC
I've install new version in unstable repository:    2.4-GIT

File .cue have information of 9 songs.
Really exist 6 songs.
Amarok load directory and show 6x9 = 54 items (with wrong data).

One cover still show (with option NOT LOAD).
Comment 5 Lisp2D 2011-01-11 18:41:38 UTC
May be index is wrong ?

REM GENRE Rock
REM DATE 1996
REM DISCID A30E330C
REM COMMENT "ExactAudioCopy v0.99pb4"
PERFORMER "Dire Straits"
TITLE "On Every Street"
FILE "Dire Straits - On Every Street.flac" WAVE
  TRACK 01 AUDIO
    TITLE "Calling Elvis"
    PERFORMER "Dire Straits"
    INDEX 01 00:00:00
  TRACK 02 AUDIO
    TITLE "On Every Street"
    PERFORMER "Dire Straits"
    INDEX 01 06:26:43
  TRACK 03 AUDIO
    TITLE "When It Comes To You"
    PERFORMER "Dire Straits"
    INDEX 01 11:30:58
  TRACK 04 AUDIO
    TITLE "Fade To Black"
    PERFORMER "Dire Straits"
    INDEX 01 16:31:60
  TRACK 05 AUDIO
    TITLE "The Bug"
    PERFORMER "Dire Straits"
    INDEX 01 20:22:28
  TRACK 06 AUDIO
    TITLE "You And Your Friend"
    PERFORMER "Dire Straits"
    INDEX 01 24:38:73
  TRACK 07 AUDIO
    TITLE "Heavy Fuel"
    PERFORMER "Dire Straits"
    INDEX 01 30:38:23
  TRACK 08 AUDIO
    TITLE "Iron Hand"
    PERFORMER "Dire Straits"
    INDEX 01 35:49:00
  TRACK 09 AUDIO
    TITLE "Ticket To Heaven"
    PERFORMER "Dire Straits"
    INDEX 01 38:58:48
  TRACK 10 AUDIO
    TITLE "My Parties"
    PERFORMER "Dire Straits"
    INDEX 01 43:24:20
  TRACK 11 AUDIO
    TITLE "Planet Of New Orleans"
    PERFORMER "Dire Straits"
    INDEX 01 48:57:25
  TRACK 12 AUDIO
    TITLE "How Long"
    PERFORMER "Dire Straits"
    INDEX 01 56:45:33
Comment 6 Myriam Schweingruber 2011-01-11 20:10:02 UTC
What do you mean by "really exist": do you actually have an incomplete cue file? That could explain the problem, at least partially. If the index counts 9 tracks the .cue file should also contain 9 tracks, else the information is wrong.
Comment 7 Lisp2D 2011-01-11 20:28:34 UTC
Sorry for wrong file, we are talking about this .cue :

CATALOG 4988011350511
PERFORMER "Dire Straits"
TITLE "Dire Straits"
FILE "01 Down To The Waterline.flac" WAVE
  TRACK 01 AUDIO
    TITLE "Down To The Waterline"
    PERFORMER "Dire Straits"
    ISRC GBFO87800019
    INDEX 01 00:00:00
FILE "02 Water Of Love.flac" WAVE
  TRACK 02 AUDIO
    TITLE "Water Of Love"
    PERFORMER "Dire Straits"
    ISRC GBFO87800639
    INDEX 00 00:00:00
    INDEX 01 00:01:22
FILE "03 Setting Me Up.flac" WAVE
  TRACK 03 AUDIO
    TITLE "Setting Me Up"
    PERFORMER "Dire Straits"
    ISRC GBFO89601038
    INDEX 00 00:00:00
    INDEX 01 00:01:54
FILE "04 Six Blade Knife.flac" WAVE
  TRACK 04 AUDIO
    TITLE "Six Blade Knife"
    PERFORMER "Dire Straits"
    ISRC GBFO89601039
    INDEX 00 00:00:00
    INDEX 01 00:00:62
FILE "05 Southbound Again.flac" WAVE
  TRACK 05 AUDIO
    TITLE "Southbound Again"
    PERFORMER "Dire Straits"
    ISRC GBFO89601040
    INDEX 00 00:00:00
    INDEX 01 00:00:50
FILE "06 Sultans Of Swing.flac" WAVE
  TRACK 06 AUDIO
    TITLE "Sultans Of Swing"
    PERFORMER "Dire Straits"
    ISRC GBFO89601041
    INDEX 00 00:00:00
    INDEX 01 00:00:01
FILE "07 In The Gallery.flac" WAVE
  TRACK 07 AUDIO
    TITLE "In The Gallery"
    PERFORMER "Dire Straits"
    ISRC GBFO89601042
    INDEX 00 00:00:00
    INDEX 01 00:00:01
FILE "08 Wild West End.flac" WAVE
  TRACK 08 AUDIO
    TITLE "Wild West End"
    PERFORMER "Dire Straits"
    ISRC GBFO89601043
    INDEX 00 00:00:00
    INDEX 01 00:00:01
FILE "09 Lions.flac" WAVE
  TRACK 09 AUDIO
    TITLE "Lions"
    PERFORMER "Dire Straits"
    ISRC GBFO89601044
    INDEX 01 00:00:00
Comment 8 Myriam Schweingruber 2011-01-11 22:25:26 UTC
Could you please answer my question in comment #6: I refer to your explanation in comment #4
Comment 9 Lisp2D 2011-01-11 23:40:01 UTC
I don't understand you and you don't understand me.
Let's start from the beginning.

"Dire Straits - Dire Straits.cue" is in comment 7.

We have 9 FLAC songs with length approximately 4min.

Amarok looking for existing files under: FILE "0..." WAVE 
and add in song-list 9 songs for every 9 songs.

Result will be 81 lines in song-list.

The standard have no told me that:

http://wiki.hydrogenaudio.org/index.php?title=Cuesheet

http://wiki.hydrogenaudio.org/index.php?title=EAC_CUE_Sheets
Comment 10 Sergey Ivanov 2011-01-13 11:25:55 UTC
commit c5d7f3314c0c2fa5b9a69a0a98b64fdab843ad3d
branch master
Author: Sergey Ivanov <123kash@gmail.com>
Date:   Thu Jan 13 13:19:53 2011 +0300

    Fixed issue with wrong handling of multyfiles cuesheets.
    BUG: 262668
    BUG: 209341

diff --git a/ChangeLog b/ChangeLog
index 49aa9bb..a975985 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,9 @@ VERSION 2.4.1
   CHANGES:
 
   BUGFIXES:
+    * Fixed issues with multifiles cuesheet, when all tracks get metadata of last track
+      in cuesheet, and each file defined in sheet gets all tracks of this sheet.
+      (BR 262668) (BR 209341)
     * Fixed crash when trying to download a full size cover and the server redirects the request. (BR 262902)
     * Fixed issue when breadcrumbs stayed not updated after service insert/remove.
       (BR 262780)
diff --git a/src/core-impl/meta/cue/CueFileSupport.cpp b/src/core-impl/meta/cue/CueFileSupport.cpp
index 53f4262..7765d26 100644
--- a/src/core-impl/meta/cue/CueFileSupport.cpp
+++ b/src/core-impl/meta/cue/CueFileSupport.cpp
@@ -35,34 +35,19 @@ using namespace MetaCue;
 * @author (C) 2005 by Martin Ehmke <ehmke@gmx.de>
 */
 
-CueFileItemMap CueFileSupport::loadCueFile( Meta::TrackPtr track )
-{
-
-    //attempt to find cue file, return empty map if not found or invalid
-    KUrl cuefile = locateCueSheet( track->playableUrl() );
-    if( cuefile.isEmpty() )
-    {
-        debug() << "No cue file found for track " << track->playableUrl();
-        return CueFileItemMap();
-    }
-
-    return loadCueFile( cuefile, track->length() );
-}
-
-
-CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLength  )
+CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, const Meta::TrackPtr track  )
 {
 
     DEBUG_BLOCK
 
     CueFileItemMap cueItems;
-    
+
     debug() << "CUEFILE: " << cuefile.pathOrUrl();
     if ( QFile::exists ( cuefile.pathOrUrl() ) )
     {
         debug() << "  EXISTS!";
         QFile file ( cuefile.pathOrUrl() );
-        int track = 0;
+        int trackNr = 0;
         QString defaultArtist;
         QString defaultAlbum;
         QString artist;
@@ -71,6 +56,8 @@ CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLen
         long prevIndex = -1;
         bool index00Present = false;
         long index = -1;
+        bool filesSection = false;
+        bool fileFound = false;
 
         int mode = BEGIN;
         if ( file.open ( QIODevice::ReadOnly ) )
@@ -94,12 +81,17 @@ CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLen
                 if ( line.startsWith ( "title", Qt::CaseInsensitive ) )
                 {
                     title = line.mid ( 6 ).remove ( '"' );
-                    if ( mode == BEGIN )
+                    if ( mode == BEGIN && !filesSection )
                     {
                         defaultAlbum = title;
                         title.clear();
                         debug() << "Album: " << defaultAlbum;
                     }
+                    else if( !fileFound )
+                    {
+                        title.clear();
+                        continue;
+                    }
                     else
                         debug() << "Title: " << title;
                 }
@@ -107,17 +99,22 @@ CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLen
                 else if ( line.startsWith ( "performer", Qt::CaseInsensitive ) )
                 {
                     artist = line.mid ( 10 ).remove ( '"' );
-                    if ( mode == BEGIN )
+                    if ( mode == BEGIN && !filesSection  )
                     {
                         defaultArtist = artist;
                         artist.clear();
                         debug() << "Album Artist: " << defaultArtist;
                     }
+                    else if( !fileFound )
+                    {
+                        artist.clear();
+                        continue;
+                    }
                     else
                         debug() << "Artist: " << artist;
                 }
 
-                else if ( line.startsWith ( "track", Qt::CaseInsensitive ) )
+                else if ( line.startsWith ( "track", Qt::CaseInsensitive ) && fileFound )
                 {
                     if ( mode == TRACK_FOUND )
                     {
@@ -126,24 +123,24 @@ CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLen
                         debug() << "Mode is TRACK_FOUND, abort.";
                         return CueFileItemMap();
                     }
-                    if ( mode == INDEX_FOUND )
+                    else if ( mode == INDEX_FOUND )
                     {
                         if ( artist.isNull() )
                             artist = defaultArtist;
 
-                        debug() << "Inserting item: " << title << " - " << artist << " on " << defaultAlbum << " (" << track << ")";
+                        debug() << "Inserting item: " << title << " - " << artist << " on " << defaultAlbum << " (" << trackNr << ")";
                         // add previous entry to map
-                        cueItems.insert ( index, CueFileItem ( title, artist, defaultAlbum, track, index ) );
+                        cueItems.insert ( index, CueFileItem ( title, artist, defaultAlbum, trackNr, index ) );
                         prevIndex = index;
                         title.clear();
                         artist.clear();
-                        track  = 0;
+                        trackNr  = 0;
                     }
-                    track = line.section ( ' ',1,1 ).toInt();
-                    debug() << "Track: " << track;
+                    trackNr = line.section ( ' ',1,1 ).toInt();
+                    debug() << "Track: " << trackNr;
                     mode = TRACK_FOUND;
                 }
-                else if ( line.startsWith ( "index", Qt::CaseInsensitive ) )
+                else if ( line.startsWith ( "index", Qt::CaseInsensitive ) && fileFound  )
                 {
                     if ( mode == TRACK_FOUND )
                     {
@@ -197,14 +194,23 @@ CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLen
                     }
                     debug() << "index: " << index;
                 }
+                else if( line.startsWith ( "file", Qt::CaseInsensitive ) )
+                {
+                    QString file = line.mid ( 5 ).remove ( '"' );
+                    if( fileFound )
+                        break;
+
+                    fileFound = file.contains ( track->playableUrl().fileName(), Qt::CaseInsensitive );
+                    filesSection = true;
+                }
             }
 
             if ( artist.isNull() )
                 artist = defaultArtist;
 
-            debug() << "Inserting item: " << title << " - " << artist << " on " << defaultAlbum << " (" << track << ")";
+            debug() << "Inserting item: " << title << " - " << artist << " on " << defaultAlbum << " (" << trackNr << ")";
             // add previous entry to map
-            cueItems.insert ( index, CueFileItem ( title, artist, defaultAlbum, track, index ) );
+            cueItems.insert ( index, CueFileItem ( title, artist, defaultAlbum, trackNr, index ) );
             file.close();
         }
 
@@ -214,8 +220,8 @@ CueFileItemMap CueFileSupport::loadCueFile( const KUrl &cuefile, qint64 mediaLen
         *  we can set the lenth for the last track after all the cue file was loaded into array.
         */
 
-        cueItems[index].setLength ( mediaLength - index );
-        debug() << "Setting length of track " << cueItems[index].title() << " to " << mediaLength - index << " msecs.";
+        cueItems[index].setLength ( track->length() - index );
+        debug() << "Setting length of track " << cueItems[index].title() << " to " << track->length() - index << " msecs.";
 
         return cueItems;
     }
diff --git a/src/core-impl/meta/cue/CueFileSupport.h b/src/core-impl/meta/cue/CueFileSupport.h
index 741f7f6..e85b1a1 100644
--- a/src/core-impl/meta/cue/CueFileSupport.h
+++ b/src/core-impl/meta/cue/CueFileSupport.h
@@ -104,11 +104,9 @@ class CueFileSupport
         TRACK_FOUND, // track found, index not yet found
         INDEX_FOUND
     };
-        
-     static CueFileItemMap loadCueFile( Meta::TrackPtr track );
 
-     static CueFileItemMap loadCueFile( const KUrl &cuefile, qint64 mediaLength );
-        
+     static CueFileItemMap loadCueFile( const KUrl &cuefile, const Meta::TrackPtr track );
+
      /**
      * Used to locate a cue sheet for a local track.
      * @return A KUrl containing the url for the cue sheet
diff --git a/src/playlist/PlaylistController.cpp b/src/playlist/PlaylistController.cpp
index d6c78a1..578fee5 100644
--- a/src/playlist/PlaylistController.cpp
+++ b/src/playlist/PlaylistController.cpp
@@ -602,7 +602,7 @@ Playlist::Controller::insertionHelper( int bottomModelRow, Meta::TrackList& tl )
             KUrl cuesheet = MetaCue::CueFileSupport::locateCueSheet( track->playableUrl() );
             if( !cuesheet.isEmpty() )
             {
-                MetaCue::CueFileItemMap cueMap = MetaCue::CueFileSupport::loadCueFile( track );
+                MetaCue::CueFileItemMap cueMap = MetaCue::CueFileSupport::loadCueFile( cuesheet, track );
                 if( !cueMap.isEmpty() )
                 {
                     Meta::TrackList cueTracks = MetaCue::CueFileSupport::generateTimeCodeTracks( track, cueMap );