コード例 #1
0
        // Artist metadata
        //[0]: "_elementType"
        //[1]: "ratingKey"
        //[2]: "key"
        //[3]: "type"
        //[4]: "title"
        //[5]: "summary"
        //[6]: "index"
        //[7]: "thumb"
        //[8]: "art"
        //[9]: "addedAt"
        //[10]: "updatedAt"
        //[11]: "_children"

        private async Task<List<Artist>> GetMusicSectionArtists(MusicSection musicSection)
        {
            var max = 10;
            var list = new List<Artist>();
            using (dynamic client = this.CreateDynamicClient(string.Format("library/sections/{0}/all", musicSection.SectionID)))
            {
                dynamic result = await client.get();
                var artists = result._children as IEnumerable<dynamic>;
                foreach (dynamic artist in artists)
                {
                    if (max-- == 0)
                    {
                        break;
                    }
                    DoProgress(String.Format("Adding '{0}'",artist.title));
                    var a = new Artist(musicSection, artist);
                    a.Albums = await GetArtistAlbums(a);
                    DoProgress(String.Format("...{0} albums", a.Albums.Count));
                    
                    if (a.Albums.Count > 0)
                    {
                        list.Add(a);
                    }
                }
            }
            return list;
        }
コード例 #2
0
 private static mediaCollection BuildArtist(Artist p)
 {
     return new mediaCollection() { id = String.Format("Art/{0}", p.Key), country = p.Country, itemType = itemType.artist, canPlay = true, canPlaySpecified = true, canEnumerate = true, canEnumerateSpecified = true, title = p.Name, albumArtURI = (!String.IsNullOrEmpty(p.ThumbLocation) ? new albumArtUrl() { Value = String.Format("http://192.168.1.227:8888/ImageService/GetImage?image={0}", p.ThumbLocation) } : null) };
 }
コード例 #3
0
        private async Task<List<Album>> GetArtistAlbums(Artist artist)
        {
            var list = new List<Album>();
            using (dynamic client = this.CreateDynamicClient(artist.Key))
            {
                dynamic result = await client.get();
                var albums = result._children as IEnumerable<dynamic>;
                var tasks = albums.Select(async album =>
                {
                    var a = new Album(artist, album);
                    a.Tracks = await BuildTracks(a);
                    if (a.Tracks.Count > 0)
                    {
                        lock (list) //ick, yes need to do concurrent
                        {
                            list.Add(a);
                        }
                    }
                });
                await Task.WhenAll(tasks);
                return list;

            }
        }