public ImportPlaylistWorker(string name, string [] uris, PrimarySource source, DatabaseImportManager importer) { this.name = name; this.uris = uris; this.source = source; this.importer = importer; }
public UPnPTrackInfo(Item track, PrimarySource source) : base() { if (track == null) { throw new ArgumentNullException ("track"); } if (source == null) { throw new ArgumentNullException ("source"); } TrackTitle = track.Title; Resource resource = FindSuitableResource (track.Resources); if (resource != null) { BitRate = (int)resource.BitRate.GetValueOrDefault (); BitsPerSample = (int)resource.BitsPerSample.GetValueOrDefault (); Duration = resource.Duration.GetValueOrDefault (); SampleRate = (int)resource.SampleFrequency.GetValueOrDefault (); FileSize = (int)resource.Size.GetValueOrDefault (); Uri = new SafeUri (resource.Uri); } else { CanPlay = false; } ExternalId = ++id; PrimarySource = source; }
public AbstractPlaylistSource(string generic_name, string name, long dbid, int sortColumn, int sortType, PrimarySource parent, bool is_temp) : base(generic_name, name, dbid.ToString (), 500, parent) { primary_source_id = parent.DbId; DbId = dbid; IsTemporary = is_temp; AfterInitialized (); }
public SmartPlaylistSource ToSmartPlaylistSource (PrimarySource primary_source) { return new SmartPlaylistSource ( Name, UserQueryParser.Parse (Condition, BansheeQuery.FieldSet), Order, Limit, LimitNumber, primary_source ); }
public AbstractPlaylistSource(string generic_name, string name, PrimarySource parent) : base() { GenericName = generic_name; Name = name; if (parent != null) { primary_source_id = parent.DbId; SetParentSource (parent); } }
private void UpdateForPlaylist (SmartPlaylistSource playlist) { PlaylistName = playlist.Name; Condition = playlist.ConditionTree; LimitEnabled = playlist.IsLimited; LimitValue = playlist.LimitValue; Limit = playlist.Limit; Order = playlist.QueryOrder; if (playlist.DbId > 0) { this.playlist = playlist; this.primary_source = playlist.PrimarySource; currently_editing = playlist; } }
public Editor(SmartPlaylistSource playlist) { currently_editing = playlist; this.playlist = playlist; this.primary_source = playlist.PrimarySource; /*Console.WriteLine ("Loading smart playlist into editor: {0}", playlist.ConditionTree == null ? "" : playlist.ConditionTree.ToXml (BansheeQuery.FieldSet, true));*/ Initialize (); Title = Catalog.GetString ("Edit Smart Playlist"); name_entry.Text = playlist.Name; UpdateForPlaylist (playlist); }
public MoodbarDetectJob() : base(Catalog.GetString ("Detecting Mood")) { IconNames = new string[] { "audio-x-generic" }; IsBackground = true; SetResources (Resource.Cpu, Resource.Disk); PriorityHints = PriorityHints.LongRunning; CanCancel = true; DelayShow = true; music_library = ServiceManager.SourceManager.MusicLibrary; CountCommand = new HyenaSqliteCommand (@" SELECT Uri FROM CoreTracks WHERE PrimarySourceID = ? AND TrackID NOT IN ( SELECT TrackID FROM MoodPaths WHERE LastAttempt > ? ) AND TrackID NOT IN ( SELECT TrackID FROM MoodPaths WHERE FileName IS NOT NULL ) ", music_library.DbId, DateTime.Now - TimeSpan.FromDays (1)); SelectCommand = new HyenaSqliteCommand (@" SELECT Uri FROM CoreTracks WHERE PrimarySourceID = ? AND TrackID NOT IN ( SELECT TrackID FROM MoodPaths WHERE LastAttempt > ? ) AND TrackID NOT IN ( SELECT TrackID FROM MoodPaths WHERE FileName IS NOT NULL ) LIMIT 1", music_library.DbId, DateTime.Now - TimeSpan.FromDays (1)); Register (); }
public BpmDetectJob () : base (Catalog.GetString ("Detecting BPM")) { IconNames = new string [] {"audio-x-generic"}; IsBackground = true; SetResources (Resource.Cpu, Resource.Disk); PriorityHints = PriorityHints.LongRunning; music_library = ServiceManager.SourceManager.MusicLibrary; CountCommand = new HyenaSqliteCommand (String.Format ( "SELECT COUNT(*) FROM CoreTracks WHERE PrimarySourceID = {0} AND (BPM = 0 OR BPM IS NULL)", music_library.DbId )); SelectCommand = new HyenaSqliteCommand (String.Format (@" SELECT DISTINCT {0}, TrackID FROM CoreTracks WHERE PrimarySourceID IN ({1}) AND (BPM IS NULL OR BPM = 0) LIMIT 1", Banshee.Query.BansheeQuery.UriField.Column, music_library.DbId )); Register (); }
public MusicTrack(Google.Music.Track track, string url, PrimarySource source) : base() { var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, new System.Globalization.GregorianCalendar(), DateTimeKind.Utc); AlbumArtist = track.albumArtist; AlbumArtistSort = track.albumArtistNorm; ArtistName = track.artist; ArtistNameSort = track.artistNorm; AlbumTitle = track.album; AlbumTitleSort = track.albumNorm; Bpm = track.beatsPerMinute; CanPlay = true; CanSaveToDatabase = false; Comment = track.comment; Composer = track.composer; DateAdded = epoch.AddTicks(track.creationDate*10); DiscCount = track.totalDiscs; DiscNumber = track.disc; Duration = TimeSpan.FromMilliseconds(track.durationMillis); Genre = track.genre; LastPlayed = epoch.AddTicks(track.lastPlayed*10); MediaAttributes = TrackMediaAttributes.AudioStream | TrackMediaAttributes.Music; MimeType = "audio/mp3"; PlayCount = track.playCount; Rating = track.rating; TrackCount = track.totalTracks; TrackNumber = track.track; TrackTitle = track.title; TrackTitleSort = track.titleNorm; Year = track.year; Uri = new Hyena.SafeUri(url); ExternalId = ++id; PrimarySource = source; }
public Editor(PrimarySource primary_source) { this.primary_source = primary_source; Initialize (); }
public DatabaseImportManager (PrimarySource psource) : this (psource.ErrorSource, delegate { return psource; }, new int [] {psource.DbId}, psource.BaseDirectory) { }
public static IEnumerable<PlaylistSource> LoadAll(PrimarySource parent) { ClearTemporary (); using (HyenaDataReader reader = new HyenaDataReader (ServiceManager.DbConnection.Query ( @"SELECT PlaylistID, Name, SortColumn, SortType, PrimarySourceID, CachedCount, IsTemporary FROM CorePlaylists WHERE Special = 0 AND PrimarySourceID = ?", parent.DbId))) { while (reader.Read ()) { yield return new PlaylistSource ( reader.Get<string> (1), reader.Get<long> (0), reader.Get<int> (2), reader.Get<int> (3), parent, reader.Get<int> (5), reader.Get<bool> (6) ); } } }
public static void ClearTemporary(PrimarySource parent) { if (parent != null) { ServiceManager.DbConnection.BeginTransaction (); ServiceManager.DbConnection.Execute (@" DELETE FROM CorePlaylistEntries WHERE PlaylistID IN (SELECT PlaylistID FROM CorePlaylists WHERE PrimarySourceID = ? AND IsTemporary = 1); DELETE FROM CorePlaylists WHERE PrimarySourceID = ? AND IsTemporary = 1;", parent.DbId, parent.DbId ); ServiceManager.DbConnection.CommitTransaction (); } }
protected PlaylistSource(string name, long dbid, int sortColumn, int sortType, PrimarySource parent, int count, bool is_temp) : base(generic_name, name, dbid, sortColumn, sortType, parent, is_temp) { SetProperties (); SavedCount = count; }
protected PlaylistSource(string name, long dbid, PrimarySource parent) : this(name, dbid, -1, 0, parent, 0, false) { }
public PlaylistSource(string name, PrimarySource parent) : base(generic_name, name, parent) { SetProperties (); }
private void LoadAllMoodbarsFromSource(PrimarySource source) { if (loaded_sources.Contains (source.DbId)) return; source.DatabaseTrackModel.Reloaded += delegate { LoadAllMoodbarsFromSource (source); }; if (source.TrackModel.Count == 0) return; //TODO: maybe use a threadpool ?! Banshee.Base.ThreadAssist.SpawnFromMain (delegate { CachedList<DatabaseTrackInfo> cached_list = CachedList<DatabaseTrackInfo>.CreateFromModel (source.DatabaseTrackModel); for (int i = 0; i < cached_list.Count; i++) { GetMoodbar (cached_list[i].Uri); } }); loaded_sources.Add (source.DbId); }
public SyncPlaylist(string name, PrimarySource parent, DapLibrarySync libsync) : base(name, parent) { this.libsync = libsync; }
public static void ImportPlaylistToLibrary (string path, PrimarySource source, DatabaseImportManager importer) { try { SafeUri uri = new SafeUri (path); PlaylistParser parser = new PlaylistParser (); string relative_dir = System.IO.Path.GetDirectoryName (uri.LocalPath); if (relative_dir[relative_dir.Length - 1] != System.IO.Path.DirectorySeparatorChar) { relative_dir = relative_dir + System.IO.Path.DirectorySeparatorChar; } parser.BaseUri = new Uri (relative_dir); if (parser.Parse (uri)) { List<string> uris = new List<string> (); foreach (Dictionary<string, object> element in parser.Elements) { uris.Add (((Uri)element["uri"]).LocalPath); } ImportPlaylistWorker worker = new ImportPlaylistWorker ( parser.Title, uris.ToArray (), source, importer); worker.Import (); } } catch (Exception e) { Hyena.Log.Exception (e); } }
public static void ImportPlaylistToLibrary (string path, PrimarySource source, DatabaseImportManager importer) { try { SafeUri uri = new SafeUri (path); PlaylistParser parser = new PlaylistParser (); string relative_dir = System.IO.Path.GetDirectoryName (uri.LocalPath); if (relative_dir[relative_dir.Length - 1] != System.IO.Path.DirectorySeparatorChar) { relative_dir = relative_dir + System.IO.Path.DirectorySeparatorChar; } parser.BaseUri = new Uri (relative_dir); if (parser.Parse (uri)) { List<string> uris = new List<string> (); foreach (PlaylistElement element in parser.Elements) { uris.Add (element.Uri.LocalPath); } if (source == null) { if (uris.Count > 0) { // Get the media attribute of the 1st Uri in Playlist // and then determine whether the playlist belongs to Video or Music SafeUri uri1 = new SafeUri (uris[0]); var track = new TrackInfo (); StreamTagger.TrackInfoMerge (track, uri1); if (track.HasAttribute (TrackMediaAttributes.VideoStream)) source = ServiceManager.SourceManager.VideoLibrary; else source = ServiceManager.SourceManager.MusicLibrary; } } // Give source a fallback value - MusicLibrary when it's null if (source == null) source = ServiceManager.SourceManager.MusicLibrary; // Only import an non-empty playlist if (uris.Count > 0) { ImportPlaylistWorker worker = new ImportPlaylistWorker ( parser.Title, uris.ToArray (), source, importer); worker.Import (); } } } catch (Exception e) { Hyena.Log.Exception (e); } }