private void ProcessRegularPlaylist(string name, XmlReader xml_reader) { var playlist_source = new PlaylistSource(name, ServiceManager.SourceManager.MusicLibrary); playlist_source.Save(); ServiceManager.SourceManager.MusicLibrary.AddChildSource(playlist_source); // Get the songs in the playlists if (xml_reader != null) { while (xml_reader.ReadToFollowing("integer") && !CheckForCanceled()) { xml_reader.Read(); int itunes_id = Int32.Parse(xml_reader.ReadContentAsString()); int track_id; if (data.track_ids.TryGetValue(itunes_id, out track_id)) { try { ServiceManager.DbConnection.Execute( "INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES (?, ?)", playlist_source.DbId, track_id); } catch { } } } playlist_source.Reload(); playlist_source.NotifyUser(); } }
private void OnNewPlaylist(object o, EventArgs args) { PlaylistSource playlist = new PlaylistSource(Catalog.GetString("New Playlist"), ActivePrimarySource); playlist.Save(); playlist.PrimarySource.AddChildSource(playlist); playlist.NotifyUser(); SourceView.BeginRenameSource(playlist); }
// Commented out for now - this method doesn't handle actually subscribing to the feeds // (the most important task in migrating podcasts), and it looks like it imports podcast files // into the Music Library. /*private void ImportPodcasts(LibraryImportManager manager, XmlNodeList podcasts) * { * foreach (XmlElement entry in podcasts) { * if (CheckForCanceled ()) { * break; * } * * processed++; * * string title = String.Empty, feed = String.Empty; * SafeUri uri = null; * * foreach (XmlElement child in entry.ChildNodes) { * if (child == null || child.InnerText == null || child.InnerText == String.Empty) { * continue; * } * * try { * switch (child.Name) { * case "title": * title = child.InnerText; * break; * case "album": * feed = child.InnerText; * break; * case "mountpoint": * uri = new SafeUri (child.InnerText); * break; * } * } catch (Exception) { * // parsing InnerText failed * } * } * * if (uri == null) { * continue; * } * * UpdateUserJob (processed, count, "", title); * * try { * DatabaseTrackInfo track = manager.ImportTrack (uri); * * if (track == null) { * LogError (SafeUri.UriToFilename (uri), Catalog.GetString ("Unable to import podcast.")); * continue; * } * * track.TrackTitle = title; * track.AlbumTitle = feed; * track.Genre = "Podcast"; * * track.Save (false); * } catch (Exception e) { * LogError (SafeUri.UriToFilename (uri), e); * } * } * }*/ private void ImportStaticPlaylists(XmlNodeList playlists) { foreach (XmlElement list in playlists) { if (CheckForCanceled()) { break; } processed++; try { string title = String.Empty; if (list.HasAttribute("name")) { title = list.GetAttribute("name"); } UpdateUserJob(processed, count, "", title); PlaylistSource playlist = new PlaylistSource(title, ServiceManager.SourceManager.MusicLibrary); playlist.Save(); ServiceManager.SourceManager.MusicLibrary.AddChildSource(playlist); HyenaSqliteCommand insert_command = new HyenaSqliteCommand(String.Format( @"INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES ({0}, ?)", playlist.DbId)); foreach (XmlElement entry in list.ChildNodes) { if (entry.Name != "location") { continue; } int track_id = ServiceManager.SourceManager.MusicLibrary.GetTrackIdForUri(entry.InnerText); if (track_id > 0) { ServiceManager.DbConnection.Execute(insert_command, track_id); } } playlist.Reload(); playlist.NotifyUser(); } catch (Exception e) { LogError("", e); } } }