Exemplo n.º 1
0
 public DACPGenre(DACPContainer container, string name)
     : base(container.Server, null)
 {
     Name      = name;
     Database  = container.Database;
     Container = container;
 }
Exemplo n.º 2
0
 public TVShow(DACPContainer container, int index, string name, int seasonNumber, IEnumerable <TVShowEpisode> episodes)
     : base(container, null)
 {
     Index        = index;
     Name         = name;
     SeasonNumber = seasonNumber;
     ProcessEpisodes(episodes);
 }
Exemplo n.º 3
0
        public async Task <bool> RequestStationsAsync()
        {
            DACPRequest request = new DACPRequest("/databases/{0}/containers", ID);

            request.QueryParameters["meta"] = "dmap.itemname,dmap.itemid,com.apple.itunes.cloud-id,dmap.downloadstatus,dmap.persistentid,daap.baseplaylist,com.apple.itunes.special-playlist,com.apple.itunes.smart-playlist,com.apple.itunes.saved-genius,dmap.parentcontainerid,dmap.editcommandssupported,com.apple.itunes.jukebox-current,daap.songcontentdescription,dmap.haschildcontainers";

            try
            {
                var response = await Server.SubmitRequestAsync(request).ConfigureAwait(false);

                var containers = DACPUtility.GetItemsFromNodes(response.Nodes, n => DACPContainer.GetContainer(this, n));

                List <iTunesRadioStation> newStations         = new List <iTunesRadioStation>();
                List <iTunesRadioStation> newFeaturedStations = new List <iTunesRadioStation>();

                // There is a property (aeRf) that indicates whether a station is a "featured" station, but in some cases
                // featured stations may not have this property set to "true".
                // For now, checking the index of the last "featured" station as a workaround.

                int lastFeaturedStationIndex = 0;
                var stations = containers.Where(c => c.Type == ContainerType.iTunesRadio).Select(c => (iTunesRadioStation)c).ToArray();

                for (int i = 0; i < stations.Length; i++)
                {
                    if (stations[i].IsFeaturedStation)
                    {
                        lastFeaturedStationIndex = i;
                    }
                }

                for (int i = 0; i < stations.Length; i++)
                {
                    if (i <= lastFeaturedStationIndex)
                    {
                        newFeaturedStations.Add(stations[i]);
                    }
                    else
                    {
                        newStations.Add(stations[i]);
                    }
                }

                Stations         = newStations;
                FeaturedStations = newFeaturedStations;
            }
            catch (Exception e)
            {
                Stations         = new List <iTunesRadioStation>();
                FeaturedStations = new List <iTunesRadioStation>();

                Server.HandleHTTPException(request, e);
                return(false);
            }

            return(true);
        }
Exemplo n.º 4
0
        public async Task <bool> RequestContainersAsync()
        {
            DACPRequest request = new DACPRequest("/databases/{0}/containers", ID);

            request.QueryParameters["meta"] = "dmap.itemname,dmap.itemid,com.apple.itunes.cloud-id,dmap.downloadstatus,dmap.persistentid,daap.baseplaylist,com.apple.itunes.special-playlist,com.apple.itunes.smart-playlist,com.apple.itunes.saved-genius,dmap.parentcontainerid,dmap.editcommandssupported,com.apple.itunes.jukebox-current,daap.songcontentdescription,dmap.haschildcontainers";

            try
            {
                var response = await Server.SubmitRequestAsync(request).ConfigureAwait(false);

                var containers = DACPUtility.GetItemsFromNodes(response.Nodes, n => DACPContainer.GetContainer(this, n));

                List <Playlist>  newPlaylists       = new List <Playlist>();
                List <Playlist>  newParentPlaylists = new List <Playlist>();
                List <GeniusMix> newGeniusMixes     = new List <GeniusMix>();

                foreach (DACPContainer container in containers)
                {
                    if (container.BasePlaylist)
                    {
                        BasePlaylist = container;
                        if (Server.IsAppleTV && container is MusicContainer)
                        {
                            MusicContainer = (MusicContainer)container;
                        }
                        continue;
                    }

                    switch (container.Type)
                    {
                    case ContainerType.Playlist:
                        newPlaylists.Add((Playlist)container);
                        if (container.ParentContainerID == 0)
                        {
                            newParentPlaylists.Add((Playlist)container);
                        }
                        break;

                    case ContainerType.Music:
                        MusicContainer = (MusicContainer)container;
                        break;

                    case ContainerType.Movies:
                        MoviesContainer = (MoviesContainer)container;
                        break;

                    case ContainerType.TVShows:
                        TVShowsContainer = (TVShowsContainer)container;
                        break;

                    case ContainerType.Podcasts:
                        PodcastsContainer = (PodcastsContainer)container;
                        break;

                    case ContainerType.iTunesU:
                        iTunesUContainer = (iTunesUContainer)container;
                        break;

                    case ContainerType.Books:
                        BooksContainer = (BooksContainer)container;
                        break;

                    case ContainerType.Purchased:
                        break;

                    case ContainerType.Rentals:
                        break;

                    case ContainerType.GeniusMixes:
                        break;

                    case ContainerType.GeniusMix:
                        newGeniusMixes.Add((GeniusMix)container);
                        break;

                    default:
                        break;
                    }
                }

                Playlists       = newPlaylists;
                ParentPlaylists = newParentPlaylists;
                GeniusMixes     = newGeniusMixes;
            }
            catch (Exception e)
            {
                Server.HandleHTTPException(request, e);
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
 public iTunesUCourse(DACPContainer container, DACPNodeDictionary nodes)
     : base(container, nodes)
 {
 }
Exemplo n.º 6
0
 public AudiobookEpisode(DACPContainer container, DACPNodeDictionary nodes)
     : base(container, nodes)
 {
 }
Exemplo n.º 7
0
 public DACPGroup(DACPContainer container, DACPNodeDictionary nodes)
     : base(container.Server, nodes)
 {
     Database  = container.Database;
     Container = container;
 }
Exemplo n.º 8
0
 public Album(DACPContainer container, DACPNodeDictionary nodes)
     : base(container, nodes)
 {
 }
Exemplo n.º 9
0
 public TVShowEpisode(DACPContainer container, DACPNodeDictionary nodes)
     : base(container, nodes)
 {
 }
Exemplo n.º 10
0
 public PodcastEpisode(DACPContainer container, DACPNodeDictionary nodes)
     : base(container, nodes)
 {
 }
Exemplo n.º 11
0
 public DACPGenre(DACPContainer container, byte[] data)
     : this(container, DACPUtility.GetStringValue(data))
 {
 }
Exemplo n.º 12
0
 public Movie(DACPContainer container, DACPNodeDictionary nodes)
     : base(container, nodes)
 {
 }