~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/playlistparsers/cueparser.cpp

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
*/
17
17
 
18
18
#include "cueparser.h"
 
19
#include "core/logging.h"
 
20
#include "core/timeconstants.h"
19
21
 
20
22
#include <QBuffer>
21
23
#include <QDateTime>
114
116
    } while(!(line = text_stream.readLine()).isNull());
115
117
 
116
118
    if(line.isNull()) {
117
 
      qWarning() << "the .cue file from " << dir_path << " defines no tracks!";
 
119
      qLog(Warning) << "the .cue file from " << dir_path << " defines no tracks!";
118
120
      return ret;
119
121
    }
120
122
 
206
208
  for(int i = 0; i < entries.length(); i++) {
207
209
    CueEntry entry = entries.at(i);
208
210
 
209
 
    Song current;
210
 
    if (!ParseTrackLocation(entry.file, dir, &current)) {
211
 
      qWarning() << "failed to parse location in .cue file from " << dir_path;
 
211
    Song song = LoadSong(entry.file, IndexToMarker(entry.index), dir);
 
212
 
 
213
    // cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime)
 
214
    if(cue_mtime.isValid()) {
 
215
      song.set_mtime(qMax(cue_mtime.toTime_t(), song.mtime()));
 
216
    }
 
217
    song.set_cue_path(playlist_path);
 
218
 
 
219
    // overwrite the stuff, we may have read from the file or library, using
 
220
    // the current .cue metadata
 
221
 
 
222
    // set track number only in single-file mode
 
223
    if(files == 1) {
 
224
      song.set_track(i + 1);
 
225
    }
 
226
 
 
227
    // the last TRACK for every FILE gets it's 'end' marker from the media file's
 
228
    // length
 
229
    if(i + 1 < entries.size() && entries.at(i).file == entries.at(i + 1).file) {
 
230
      // incorrect indices?
 
231
      if(!UpdateSong(entry, entries.at(i + 1).index, &song)) {
 
232
        continue;
 
233
      }
212
234
    } else {
213
 
      // look for the section in library
214
 
      Song song = LoadLibrarySong(current.filename(), IndexToMarker(entry.index));
215
 
      if (!song.is_valid()) {
216
 
        song.InitFromFile(current.filename(), -1);
217
 
      }
218
 
 
219
 
      // cue song has mtime equal to qMax(media_file_mtime, cue_sheet_mtime)
220
 
      if(cue_mtime.isValid()) {
221
 
        song.set_mtime(qMax(cue_mtime.toTime_t(), song.mtime()));
222
 
      }
223
 
      song.set_cue_path(playlist_path);
224
 
 
225
 
      // overwrite the stuff, we may have read from the file or library, using
226
 
      // the current .cue metadata
227
 
 
228
 
      // set track number only in single-file mode
229
 
      if(files == 1) {
230
 
        song.set_track(i + 1);
231
 
      }
232
 
 
233
 
      // the last TRACK for every FILE gets it's 'end' marker from the media file's
234
 
      // length
235
 
      if(i + 1 < entries.size() && entries.at(i).file == entries.at(i + 1).file) {
236
 
        // incorrect indices?
237
 
        if(!UpdateSong(entry, entries.at(i + 1).index, &song)) {
238
 
          continue;
239
 
        }
240
 
      } else {
241
 
        // incorrect index?
242
 
        if(!UpdateLastSong(entry, &song)) {
243
 
          continue;
244
 
        }
245
 
      }
246
 
 
247
 
      ret << song;
 
235
      // incorrect index?
 
236
      if(!UpdateLastSong(entry, &song)) {
 
237
        continue;
 
238
      }
248
239
    }
 
240
 
 
241
    ret << song;
249
242
  }
250
243
 
251
244
  return ret;