public static LibraryTrackInfo HitToTrack(Hit hit) { uint track_number = 0; uint track_count = 0; int year = 0; try { track_number = UInt32.Parse(hit.GetFirstProperty("fixme:tracknumber")); } catch { } try { track_count = UInt32.Parse(hit.GetFirstProperty("fixme:trackcount")); } catch { } try { year = Int32.Parse(hit.GetFirstProperty("fixme:year")); } catch { } try { LibraryTrackInfo track = new LibraryTrackInfo( new SafeUri(hit.Uri), hit.GetFirstProperty("fixme:artist"), hit.GetFirstProperty("fixme:album"), hit.GetFirstProperty("fixme:title"), hit.GetFirstProperty("fixme:genre"), track_number, track_count, year, TimeSpan.Zero, null, RemoteLookupStatus.NoAttempt); return track; } catch { return null; } }
public static LibraryTrackInfo HitToTrack(Hit hit) { uint track_number = 0; uint track_count = 0; int year = 0; try { track_number = UInt32.Parse(hit.GetFirstProperty("fixme:tracknumber")); } catch { } try { track_count = UInt32.Parse(hit.GetFirstProperty("fixme:trackcount")); } catch { } try { year = Int32.Parse(hit.GetFirstProperty("fixme:year")); } catch { } try { LibraryTrackInfo track = new LibraryTrackInfo( new SafeUri(hit.Uri), hit.GetFirstProperty("fixme:artist"), hit.GetFirstProperty("fixme:album"), hit.GetFirstProperty("fixme:title"), hit.GetFirstProperty("fixme:genre"), track_number, track_count, year, TimeSpan.Zero, null, RemoteLookupStatus.NoAttempt); return(track); } catch { return(null); } }
private void HandleLibraryReloaded(object sender, EventArgs args) { // Listen for changes to any track to keep our playlists up to date IDataReader reader = Globals.Library.Db.Query(String.Format( "SELECT TrackID FROM Tracks" )); while (reader.Read()) { LibraryTrackInfo track = Globals.Library.GetTrack(Convert.ToInt32(reader[0])); if (track != null) { track.Changed += HandleTrackChanged; } } reader.Dispose(); Globals.Library.Reloaded -= HandleLibraryReloaded; }
private static void OnDownloadCompletedHandler(object sender, DownloadCompletedEventArgs args) { DownloadInfo dif = args.DownloadInfo; SafeUri local_uri = new SafeUri(args.LocalUri); if (dif == null || local_uri == null) { return; } PodcastInfo pi = null; lock (downloads.SyncRoot) { if (downloads.Contains(dif)) { pi = downloads [args.DownloadInfo] as PodcastInfo; } } if (pi != null) { TrackInfo ti = null; try { try { ti = new LibraryTrackInfo(local_uri.LocalPath); } catch (ApplicationException) { ti = Globals.Library.TracksFnKeyed [PathUtil.MakeFileNameKey(local_uri)] as TrackInfo; } } catch (Exception e) { PodcastErrorsSource.Instance.AddError( local_uri.ToString(), Catalog.GetString("Unable to add file to library"), e ); } pi.IsDownloaded = true; if (ti != null) { pi.Track = ti; } else { pi.DownloadFailed = true; PodcastDBManager.Commit(pi); return; } pi.LocalPath = local_uri.ToString(); PodcastDBManager.Commit(pi); pi.Feed.UpdateCounts(); ThreadAssist.ProxyToMain(delegate { Library.AddTrack(ti, pi, true); }); } source.Update(); }
private static void OnDownloadCompletedHandler(object sender, DownloadCompletedEventArgs args) { DownloadInfo dif = args.DownloadInfo; SafeUri local_uri = new SafeUri (args.LocalUri); if (dif == null || local_uri == null) { return; } PodcastInfo pi = null; lock (downloads.SyncRoot) { if (downloads.Contains (dif)) { pi = downloads [args.DownloadInfo] as PodcastInfo; } } if (pi != null) { TrackInfo ti = null; try { try { ti = new LibraryTrackInfo(local_uri.LocalPath); } catch (ApplicationException) { ti = Globals.Library.TracksFnKeyed [PathUtil.MakeFileNameKey(local_uri)] as TrackInfo; } } catch (Exception e) { PodcastErrorsSource.Instance.AddError ( local_uri.ToString (), Catalog.GetString ("Unable to add file to library"), e ); } pi.IsDownloaded = true; if (ti != null) { pi.Track = ti; } else { pi.DownloadFailed = true; PodcastDBManager.Commit (pi); return; } pi.LocalPath = local_uri.ToString (); PodcastDBManager.Commit (pi); pi.Feed.UpdateCounts (); ThreadAssist.ProxyToMain (delegate { Library.AddTrack (ti, pi, true); }); } source.Update (); }