Exemple #1
0
        private void OnTrackFinished(object o, AudioCdRipperTrackFinishedArgs args)
        {
            if (user_job == null || ripper == null)
            {
                return;
            }

            AudioCdTrackInfo track = (AudioCdTrackInfo)args.Track;

            ripped_duration    += track.Duration;
            track.PrimarySource = ServiceManager.SourceManager.MusicLibrary;
            track.Uri           = args.Uri;

            track.FileSize          = Banshee.IO.File.GetSize(track.Uri);
            track.FileModifiedStamp = Banshee.IO.File.GetModifiedTime(track.Uri);
            track.LastSyncedStamp   = DateTime.Now;

            using (var file = StreamTagger.ProcessUri(track.Uri)) {
                StreamTagger.TrackInfoMerge(track, file, true);
            }

            track.Save();

            source.UnlockTrack(track);
            RipNextTrack();
        }
Exemple #2
0
        public void LoadModelFromDisc()
        {
            Clear();

            LocalDisc mb_disc = LocalDisc.GetFromDevice(volume.DeviceNode);

            if (mb_disc == null)
            {
                throw new ApplicationException("Could not read contents of the disc. Platform may not be supported.");
            }

            TimeSpan[] durations = mb_disc.GetTrackDurations();
            for (int i = 0, n = durations.Length; i < n; i++)
            {
                AudioCdTrackInfo track = new AudioCdTrackInfo(this, volume.DeviceNode, i);
                track.TrackNumber = i + 1;
                track.TrackCount  = n;
                track.DiscNumber  = 1;
                track.Duration    = durations[i];
                track.ArtistName  = Catalog.GetString("Unknown Artist");
                track.AlbumTitle  = Catalog.GetString("Unknown Album");
                track.TrackTitle  = String.Format(Catalog.GetString("Track {0}"), track.TrackNumber);
                track.FileSize    = PCM_FACTOR * (uint)track.Duration.TotalSeconds;
                Add(track);

                duration  += track.Duration;
                file_size += track.FileSize;
            }

            EnabledCount = Count;

            Reload();

            ThreadPool.QueueUserWorkItem(LoadDiscMetadata, mb_disc);
        }
        private void RipNextTrack()
        {
            if (queue.Count == 0)
            {
                OnFinished();
                Dispose();
                return;
            }

            AudioCdTrackInfo track = queue.Dequeue();

            user_job.Title = String.Format(Catalog.GetString("Importing {0} of {1}"),
                                           ++track_index, source.DiscModel.EnabledCount);
            status          = String.Format("{0} - {1}", track.ArtistName, track.TrackTitle);
            user_job.Status = status;

            SafeUri uri = new SafeUri(FileNamePattern.BuildFull(ServiceManager.SourceManager.MusicLibrary.BaseDirectory, track, null));
            bool    tagging_supported;

            ripper.RipTrack(track.IndexOnDisc, track, uri, out tagging_supported);
        }
 internal void UnlockTrack (AudioCdTrackInfo track)
 {
     track.CanPlay = true;
     disc_model.NotifyUpdated ();
 }
Exemple #5
0
        private void LoadDiscMetadata(object state)
        {
            try {
                LocalDisc mb_disc = (LocalDisc)state;

                OnMetadataQueryStarted(mb_disc);

                Release release = Release.Query(mb_disc).PerfectMatch();

                var tracks = release.GetTracks();
                if (release == null || tracks.Count != Count)
                {
                    OnMetadataQueryFinished(false);
                    return;
                }

                disc_title = release.GetTitle();

                int disc_number = 1;
                int i           = 0;

                foreach (Disc disc in release.GetDiscs())
                {
                    i++;
                    if (disc.Id == mb_disc.Id)
                    {
                        disc_number = i;
                    }
                }

                DateTime release_date = DateTime.MaxValue;

                foreach (Event release_event in release.GetEvents())
                {
                    if (release_event.Date != null)
                    {
                        try {
                            // Handle "YYYY" dates
                            var      date_str = release_event.Date;
                            DateTime date     = DateTime.Parse(
                                date_str.Length > 4 ? date_str : date_str + "-01",
                                ApplicationContext.InternalCultureInfo
                                );

                            if (date < release_date)
                            {
                                release_date = date;
                            }
                        } catch {
                        }
                    }
                }

                DatabaseArtistInfo artist = new DatabaseArtistInfo();
                var mb_artist             = release.GetArtist();
                artist.Name          = mb_artist.GetName();
                artist.NameSort      = mb_artist.GetSortName();
                artist.MusicBrainzId = mb_artist.Id;
                bool is_compilation = false;

                DatabaseAlbumInfo album = new DatabaseAlbumInfo();
                album.Title         = disc_title;
                album.ArtistName    = artist.Name;
                album.MusicBrainzId = release.Id;
                album.ReleaseDate   = release_date == DateTime.MaxValue ? DateTime.MinValue : release_date;

                i = 0;
                foreach (Track track in tracks)
                {
                    AudioCdTrackInfo model_track = (AudioCdTrackInfo)this[i++];
                    var mb_track_artist          = track.GetArtist();

                    model_track.MusicBrainzId = track.Id;
                    model_track.TrackTitle    = track.GetTitle();
                    model_track.ArtistName    = mb_track_artist.GetName();
                    model_track.AlbumTitle    = disc_title;
                    model_track.DiscNumber    = disc_number;
                    model_track.Album         = album;

                    model_track.Artist               = new DatabaseArtistInfo();
                    model_track.Artist.Name          = model_track.ArtistName;
                    model_track.Artist.NameSort      = mb_track_artist.GetSortName();
                    model_track.Artist.MusicBrainzId = mb_track_artist.Id;

                    if (release_date != DateTime.MinValue)
                    {
                        model_track.Year = release_date.Year;
                    }

                    if (!is_compilation && mb_track_artist.Id != artist.MusicBrainzId)
                    {
                        is_compilation = true;
                    }
                }

                if (is_compilation)
                {
                    album.IsCompilation = true;
                    for (i = 0; i < tracks.Count; i++)
                    {
                        AudioCdTrackInfo model_track = (AudioCdTrackInfo)this[i];
                        model_track.IsCompilation   = true;
                        model_track.AlbumArtist     = artist.Name;
                        model_track.AlbumArtistSort = artist.NameSort;
                    }
                }

                OnMetadataQueryFinished(true);
            } catch (Exception ex) {
                Log.DebugException(ex);
                OnMetadataQueryFinished(false);
            }
        }
        public void LoadModelFromDisc ()
        {
            Clear ();

            LocalDisc mb_disc = LocalDisc.GetFromDevice (volume.DeviceNode);
            if (mb_disc == null) {
                throw new ApplicationException ("Could not read contents of the disc. Platform may not be supported.");
            }

            TimeSpan[] durations = mb_disc.GetTrackDurations ();
            for (int i = 0, n = durations.Length; i < n; i++) {
                AudioCdTrackInfo track = new AudioCdTrackInfo (this, volume.DeviceNode, i);
                track.TrackNumber = i + 1;
                track.TrackCount = n;
                track.DiscNumber = 1;
                track.Duration = durations[i];
                track.ArtistName = Catalog.GetString ("Unknown Artist");
                track.AlbumTitle = Catalog.GetString ("Unknown Album");
                track.TrackTitle = String.Format (Catalog.GetString ("Track {0}"), track.TrackNumber);
                track.FileSize = PCM_FACTOR * (uint)track.Duration.TotalSeconds;
                Add (track);

                duration += track.Duration;
                file_size += track.FileSize;
            }

            EnabledCount = Count;

            Reload ();

            ThreadPool.QueueUserWorkItem (LoadDiscMetadata, mb_disc);
        }
Exemple #7
0
 internal void UnlockTrack(AudioCdTrackInfo track)
 {
     track.CanPlay = true;
     disc_model.NotifyUpdated();
 }
        public override bool TrackEqual(TrackInfo track)
        {
            AudioCdTrackInfo cd_track = track as AudioCdTrackInfo;

            return(cd_track == null ? false : (cd_track.Model == Model && cd_track.IndexOnDisc == IndexOnDisc));
        }