Ejemplo n.º 1
0
        public PlaylistItem(MPDSongResponseBlock block, DataModel dataModel)
        {
            Path = new Path(block.File);
            Position = block.Pos;
            Id = block.Id;

            if (Path.IsStream())
            {
                Artist = null;
                Album = null;
                AudioStream stream = dataModel.StreamsCollection.StreamByPath(Path);

                if (stream != null)
                {
                    Title = stream.Label;
                }
                else
                {
                    Title = block.Name ?? Path.ToString();
                }
            }
            else
            {
                Title = block.Title;
                Album = block.Album;

                if (Settings.Default.UseAlbumArtist)
                {
                    Artist = block.AlbumArtist ?? block.Artist;
                }

                Artist = block.Artist;
            }
        }
Ejemplo n.º 2
0
 public static AudioStream CreateAudioStream(Path path, string label, MPDSongResponseBlock block)
 {
     AudioStream result = new AudioStream(path, label);
     result.Title = block.Title;
     result.Name = block.Name;
     return result;
 }
Ejemplo n.º 3
0
Archivo: Link.cs Proyecto: paukr/auremo
 public Link(Path path)
 {
     Path = path;
     Title = null;
     Artist = null;
     Album = null;
     Date = null;
 }
Ejemplo n.º 4
0
 public static Link CreateLink(Path path, MPDSongResponseBlock block)
 {
     Link result = new Link(path);
     result.Title = block.Title;
     result.Artist = block.Artist;
     result.Album = block.Album;
     result.Date = block.Date;
     return result;
 }
Ejemplo n.º 5
0
        public static Song FetchSong(Path path, MPDSongResponseBlock block, Database database)
        {
            Song song = null;

            if (database.Songs.TryGetValue(path, out song))
            {
                return song;
            }
            else
            {
                throw new Exception("PlayableFactory.FetchSong(): expected to find \"" + block.File + "\" in library, didn't.");
            }
        }
Ejemplo n.º 6
0
        public static Playable CreatePlayable(MPDSongResponseBlock block, DataModel dataModel = null)
        {
            Path path = new Path(block.File);

            if (path.IsStream())
            {
                return CreateAudioStream(path, null, block);
            }
            else if (dataModel == null || !path.IsLocal())
            {
                return CreateLink(path, block);
            }

            return FetchSong(path, block, dataModel.Database);
        }
Ejemplo n.º 7
0
Archivo: Song.cs Proyecto: paukr/auremo
        public Song(MPDSongResponseBlock block)
        {
            Path = new Path(block.File);
            Title = block.Title;
            Length = block.Time;
            Track = block.Track;
            Length = block.Time;
            Filename = Path.Directories.Last();

            // These need to be set by the caller as they require external external objects.
            Artist = null;
            Album = null;
            Genre = null;
            Date = null;
            Directory = null;
        }
Ejemplo n.º 8
0
        private GenreFilteredAlbum GetOrCreateGenreFilteredAlbum(Album album, MPDSongResponseBlock block)
        {
            Genre genre = Genres[block.Genre ?? UnknownGenre];

            if (!m_GenreFilteredAlbumLookup.ContainsKey(genre))
            {
                m_GenreFilteredAlbumLookup[genre] = new SortedDictionary<Album, GenreFilteredAlbum>();
            }

            IDictionary<Album, GenreFilteredAlbum> albumList = m_GenreFilteredAlbumLookup[genre];

            if (!albumList.ContainsKey(album))
            {
                string directory = new Path(block.File).Directories.Last();
                GenreFilteredAlbum genreFilteredAlbum = new GenreFilteredAlbum(genre, album.Artist, album.Title, album.Date, directory);
                m_GenreFilteredAlbumLookup[genre][album] = genreFilteredAlbum;
                AddGenreExpansion(genre, genreFilteredAlbum);
            }

            return m_GenreFilteredAlbumLookup[genre][album];
        }
Ejemplo n.º 9
0
        private Directory GetOrCreateDirectory(Path path)
        {
            string[] parts = path.Directories;
            string fullpath = "";
            Directory parentOrResult = null;

            for (int i = 0; i < parts.Count() - 1; ++i)
            {
                fullpath = fullpath + parts[i] + "/";

                if (Directories.ContainsKey(fullpath))
                {
                    parentOrResult = Directories[fullpath];
                }
                else
                {
                    Directory dir = new Directory(parts[i], parentOrResult);
                    Directories[fullpath] = dir;
                    parentOrResult = dir;
                }
            }

            return parentOrResult;
        }
Ejemplo n.º 10
0
        private Album GetOrCreateAlbum(MPDSongResponseBlock block)
        {
            Artist artist = Artists[SelectArtistTag(block)];
            string albumKey = block.Album ?? UnknownAlbum;

            if (!m_AlbumLookup.ContainsKey(artist))
            {
                m_AlbumLookup[artist] = new SortedDictionary<string, Album>(StringComparer.Ordinal);
            }

            IDictionary<string, Album> albumList = m_AlbumLookup[artist];

            if (!albumList.ContainsKey(albumKey))
            {
                string date = null;

                if (block.Date != null)
                {
                    if (Path.IsSpotify(block.File))
                    {
                        date = m_DataModel.YearNormalizer.Normalize(block.Date);
                    }
                    else
                    {
                        date = m_DataModel.CustomDateNormalizer.Normalize(block.Date);
                    }
                }

                string directory = new Path(block.File).Directories.Last();
                Album album = new Album(artist, albumKey, date, directory);
                albumList[albumKey] = album;
                AddArtistExpansion(artist, album);
            }

            return albumList[albumKey];
        }
Ejemplo n.º 11
0
 public AudioStream(Path path, string label)
 {
     Path = path;
     Label = label;
     Title = null;
 }