// Used for podcasts only //private string description; public AppleDeviceTrackInfo (GPod.Track track) { IpodTrack = track; LoadFromIpodTrack (); CanSaveToDatabase = true; }
// FIXME: No reason for this to use GdkPixbuf - the file is on disk already in // the artwork cache as a JPEG, so just shove the bytes from disk into the track public static void SetIpodCoverArt (GPod.Device device, GPod.Track track, string path) { // try { // Gdk.Pixbuf pixbuf = null; // foreach (IPod.ArtworkFormat format in device.LookupArtworkFormats (IPod.ArtworkUsage.Cover)) { // if (!track.HasCoverArt (format)) { // // Lazily load the pixbuf // if (pixbuf == null) { // pixbuf = new Gdk.Pixbuf (path); // } // // track.SetCoverArt (format, IPod.ArtworkHelpers.ToBytes (format, pixbuf)); // } // } // // if (pixbuf != null) { // pixbuf.Dispose (); // } // } catch (Exception e) { // Log.Exception (String.Format ("Failed to set cover art on iPod from {0}", path), e); // } }
public void CommitToIpod (GPod.ITDB database) { bool addTrack = IpodTrack == null; if (IpodTrack == null) { IpodTrack = new GPod.Track (); } var track = IpodTrack; track.Compilation = IsCompilation; track.AlbumArtist = AlbumArtist; track.Bitrate = BitRate; track.Samplerate= (ushort)SampleRate; track.BPM = (short)Bpm; track.Comment = Comment; track.Composer = Composer; track.TimeAdded = DateAdded; track.CDs = DiscCount; track.CDNumber = DiscNumber; track.TrackLength = (int) Duration.TotalMilliseconds; track.Size = (int)FileSize; track.Grouping = Grouping; track.TimePlayed = LastPlayed; track.PlayCount = (uint) PlayCount; track.Tracks = TrackCount; track.TrackNumber = TrackNumber; track.Year = Year; track.TimeReleased = ReleaseDate; track.Album = AlbumTitle; track.Artist = ArtistName; track.Title = TrackTitle; track.Genre = Genre; switch (Rating) { case 1: case 2: case 3: case 4: case 5: track.Rating = (uint) rating; break; default: track.Rating = 0; break; } // if (HasAttribute (TrackMediaAttributes.Podcast)) { // track.DateReleased = ReleaseDate; // track.Description = description; // track.RememberPosition = true; // track.NotPlayedMark = track.PlayCount == 0; // } // // if (HasAttribute (TrackMediaAttributes.VideoStream)) { // if (HasAttribute (TrackMediaAttributes.Podcast)) { // track.Type = IPod.MediaType.VideoPodcast; // } else if (HasAttribute (TrackMediaAttributes.Music)) { // track.Type = IPod.MediaType.MusicVideo; // } else if (HasAttribute (TrackMediaAttributes.Movie)) { // track.Type = IPod.MediaType.Movie; // } else if (HasAttribute (TrackMediaAttributes.TvShow)) { // track.Type = IPod.MediaType.TVShow; // } else { // track.Type = IPod.MediaType.Video; // } // } else { // if (HasAttribute (TrackMediaAttributes.Podcast)) { // track.Type = IPod.MediaType.Podcast; // } else if (HasAttribute (TrackMediaAttributes.AudioBook)) { // track.Type = IPod.MediaType.Audiobook; // } else if (HasAttribute (TrackMediaAttributes.Music)) { // track.Type = IPod.MediaType.Audio; // } else { // track.Type = IPod.MediaType.Audio; // } // } track.MediaType = GPod.MediaType.Audio; if (addTrack) { track.Filetype = "MP3-file"; database.Tracks.Add (IpodTrack); database.MasterPlaylist.Tracks.Add (IpodTrack); database.CopyTrackToIPod (track, Uri.LocalPath); ExternalId = (long) IpodTrack.DBID; } // if (CoverArtSpec.CoverExists (ArtworkId)) { // SetIpodCoverArt (device, track, CoverArtSpec.GetPath (ArtworkId)); // } }
public void CommitToIpod (GPod.ITDB database) { bool addTrack = IpodTrack == null; if (IpodTrack == null) { IpodTrack = new GPod.Track (); } var track = IpodTrack; track.Compilation = IsCompilation; track.AlbumArtist = AlbumArtist; track.Bitrate = BitRate; track.Samplerate= (ushort)SampleRate; track.BPM = (short)Bpm; track.Comment = Comment; track.Composer = Composer; track.TimeAdded = DateTime.Now; track.CDs = DiscCount; track.CDNumber = DiscNumber; track.TrackLength = (int) Duration.TotalMilliseconds; track.Size = (uint)FileSize; track.Grouping = Grouping; try { track.TimePlayed = LastPlayed; } catch { Hyena.Log.InformationFormat ("Couldn't set TimePlayed to '{0}'", LastPlayed); } track.PlayCount = (uint) PlayCount; track.Tracks = TrackCount; track.TrackNumber = TrackNumber; track.Year = Year; try { track.TimeReleased = ReleaseDate; } catch { Hyena.Log.InformationFormat ("Couldn't set TimeReleased to '{0}'", ReleaseDate); } track.Album = AlbumTitle; track.Artist = ArtistName; track.Title = TrackTitle; track.Genre = Genre; track.SortArtist = ArtistNameSort; track.SortAlbum = AlbumTitleSort; track.SortAlbumArtist = AlbumArtistSort; track.SortTitle = TrackTitleSort; track.Rating = ((Rating >= 1) && (Rating <= 5)) ? (uint)Rating * ITDB_RATING_STEP : 0; if (HasAttribute (TrackMediaAttributes.Podcast)) { track.Description = description; track.RememberPlaybackPosition = true; track.SkipWhenShuffling = true; track.Flag4 = (byte)1; track.MarkUnplayed = (track.PlayCount == 0); } track.MediaType = GPod.MediaType.Audio; if (HasAttribute (TrackMediaAttributes.VideoStream)) { if (HasAttribute (TrackMediaAttributes.Podcast)) { track.MediaType = GPod.MediaType.Podcast | GPod.MediaType.Movie; } else if (HasAttribute (TrackMediaAttributes.Music)) { if (HasAttribute (TrackMediaAttributes.TvShow)) { track.MediaType = GPod.MediaType.MusicTVShow; } else { track.MediaType = GPod.MediaType.MusicVideo; } } else if (HasAttribute (TrackMediaAttributes.Movie)) { track.MediaType = GPod.MediaType.Movie; } else if (HasAttribute (TrackMediaAttributes.TvShow)) { track.MediaType = GPod.MediaType.TVShow; } else { // I dont' think AudioVideo should be used here; upon loading the tracks // into Banshee, audio files often have AudioVideo (aka MediaType == 0) too. //track.MediaType = GPod.MediaType.AudioVideo; track.MediaType = GPod.MediaType.Movie; } } else { if (HasAttribute (TrackMediaAttributes.Podcast)) { track.MediaType = GPod.MediaType.Podcast; } else if (HasAttribute (TrackMediaAttributes.AudioBook)) { track.MediaType = GPod.MediaType.Audiobook; } else if (HasAttribute (TrackMediaAttributes.Music)) { track.MediaType = GPod.MediaType.Audio; } else { track.MediaType = GPod.MediaType.Audio; } } if (addTrack) { track.Filetype = mimetype; database.Tracks.Add (IpodTrack); database.MasterPlaylist.Tracks.Add (IpodTrack); if (HasAttribute (TrackMediaAttributes.Podcast) && database.Device.SupportsPodcast) { database.PodcastsPlaylist.Tracks.Add (IpodTrack); } database.CopyTrackToIPod (track, Uri.LocalPath); Uri = new SafeUri (GPod.ITDB.GetLocalPath (database.Device, track)); ExternalId = (long) IpodTrack.DBID; } if (CoverArtSpec.CoverExists (ArtworkId)) { string path = CoverArtSpec.GetPath (ArtworkId); if (!track.ThumbnailsSet (path)) { Log.Error (String.Format ("Could not set cover art for {0}.", path)); } } else { track.ThumbnailsRemoveAll (); } }
// Apple products do not save DateTime info for each track play, only a total // sum of number of plays (playcount) of each track. private IList<DateTime> GenerateFakePlaytimes (GPod.Track track) { IList<DateTime> playtimes = new List<DateTime> (); //FIXME: avoid sequences of overlapping playtimes? DateTime current_playtime = track.TimePlayed; for (int i = 0; i < track.RecentPlayCount; i++) { playtimes.Add (current_playtime); current_playtime -= TimeSpan.FromMilliseconds (track.TrackLength); } return playtimes; }
private void DeleteTrack (GPod.Track track, bool removeFile) { foreach (var playlist in MediaDatabase.Playlists) { playlist.Tracks.Remove (track); } if (SupportsPodcasts && track.MediaType == GPod.MediaType.Podcast && MediaDatabase.PodcastsPlaylist != null) { MediaDatabase.PodcastsPlaylist.Tracks.Remove (track); } MediaDatabase.MasterPlaylist.Tracks.Remove (track); MediaDatabase.Tracks.Remove (track); if (removeFile) { Banshee.IO.File.Delete (new SafeUri (GPod.ITDB.GetLocalPath (Device, track))); } }