Esempio n. 1
0
        public Task <ContentResponse> GetRecentlyPlayedRadiosAsync(
            MediaNamespace mediaNamespace,
            int?maxItems = null,
            int?page     = null)
        {
            Dictionary <string, string> requestParameters = new Dictionary <string, string>();

            if (page.HasValue)
            {
                requestParameters.Add("page", page.ToString());
            }

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }

            return(ApiCallWithUserAuthorizationHeaderRefreshAsync(
                       headers => GetAsync <ContentResponse>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/radio/recentlyplayed",
                           new CancellationToken(false),
                           requestParameters,
                           headers)));
        }
Esempio n. 2
0
 public Task <ContentResponse> BrowseGenresAsync(
     MediaNamespace mediaNamespace,
     string country  = null,
     string language = null)
 {
     return(BrowseAsync(mediaNamespace, "genres", country, language));
 }
Esempio n. 3
0
 public Task <ContentResponse> SpotlightApiAsync(
     MediaNamespace mediaNamespace,
     string language = null,
     string country  = null)
 {
     return(DiscoverAsync(mediaNamespace, "spotlight", country, language));
 }
Esempio n. 4
0
        public Task <RadioResponse> CreateRadioAsync(
            MediaNamespace mediaNamespace,
            CreateRadioRequest createRadioRequest,
            int?maxItems = null)
        {
            if (createRadioRequest == null)
            {
                throw new ArgumentNullException(nameof(createRadioRequest));
            }

            Dictionary <string, string> requestParameters = new Dictionary <string, string>();

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }

            return(ApiCallWithUserAuthorizationHeaderRefreshAsync(
                       headers => PostAsync <RadioResponse, CreateRadioRequest>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/radio/create",
                           createRadioRequest,
                           new CancellationToken(false),
                           requestParameters,
                           headers)));
        }
Esempio n. 5
0
 public Task <ContentResponse> NewReleasesApiAsync(
     MediaNamespace mediaNamespace,
     string genre    = null,
     string language = null,
     string country  = null)
 {
     return(DiscoverAsync(mediaNamespace, "newreleases", country, language, genre));
 }
Esempio n. 6
0
 public Task <ContentResponse> BrowseContinuationAsync(
     MediaNamespace mediaNamespace,
     ContentSource source,
     ItemType type,
     string continuationToken)
 {
     return(BrowseApiAsync(mediaNamespace, source, type, continuationToken: continuationToken));
 }
Esempio n. 7
0
 public Task <ContentResponse> SearchAsync(
     MediaNamespace mediaNamespace,
     string query,
     ContentSource?source = null,
     SearchFilter filter  = SearchFilter.Default,
     string language      = null,
     string country       = null,
     int?maxItems         = null)
 {
     return(SearchApiAsync(mediaNamespace, query, source, filter, language, country, maxItems));
 }
Esempio n. 8
0
        public Task <RadioResponse> ContinueRadioAsync(
            MediaNamespace mediaNamespace,
            Radio radio,
            int?maxItems = null)
        {
            if (radio == null)
            {
                throw new ArgumentNullException(nameof(radio));
            }

            return(ContinueRadioAsync(mediaNamespace, radio.Id, maxItems));
        }
Esempio n. 9
0
        public Task <RadioResponse> ContinueRadioAsync(
            MediaNamespace mediaNamespace,
            RadioResponse previousResponse,
            int?maxItems = null)
        {
            if (previousResponse == null)
            {
                throw new ArgumentNullException(nameof(previousResponse));
            }

            return(ContinueRadioAsync(mediaNamespace, previousResponse.SessionId, maxItems));
        }
Esempio n. 10
0
        private async Task <ContentResponse> BrowseAsync(MediaNamespace mediaNamespace, string browseCategory, string country, string language)
        {
            Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

            Dictionary <string, string> requestParameters = FormatRequestParameters(language: language, country: country);

            return(await GetAsync <ContentResponse>(
                       Hostname,
                       $"/1/content/{mediaNamespace}/catalog/{browseCategory}",
                       new CancellationToken(false),
                       requestParameters,
                       requestHeaders));
        }
Esempio n. 11
0
        private async Task <ContentResponse> SearchApiAsync(
            MediaNamespace mediaNamespace,
            string query         = null,
            ContentSource?source = null,
            SearchFilter filter  =
            SearchFilter.Default,
            string language          = null,
            string country           = null,
            int?maxItems             = null,
            string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = FormatRequestParameters(continuationToken, language, country, source);

            if (!string.IsNullOrEmpty(query))
            {
                requestParameters.Add("q", Uri.EscapeDataString(query));
            }

            if (filter != SearchFilter.Default)
            {
                requestParameters.Add("filters", filter.ToString().Replace(", ", "+"));
            }

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxItems", maxItems.ToString());
            }

            if (_userTokenManager?.UserIsSignedIn == true)
            {
                return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                           headers => GetAsync <ContentResponse>(
                               Hostname,
                               $"/1/content/{mediaNamespace}/search",
                               new CancellationToken(false),
                               requestParameters,
                               headers)));
            }
            else
            {
                Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

                return(await GetAsync <ContentResponse>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/search",
                           new CancellationToken(false),
                           requestParameters,
                           requestHeaders));
            }
        }
Esempio n. 12
0
 public Task <ContentResponse> BrowseAsync(
     MediaNamespace mediaNamespace,
     ContentSource source,
     ItemType type,
     string genre    = null,
     string mood     = null,
     string activity = null,
     OrderBy?orderBy = null,
     int?maxItems    = null,
     int?page        = null,
     string country  = null,
     string language = null)
 {
     return(BrowseApiAsync(mediaNamespace, source, type, genre, mood, activity, orderBy, maxItems, page, country, language));
 }
Esempio n. 13
0
        public async Task <UserProfileResponse> GetUserProfileAsync(
            MediaNamespace mediaNamespace,
            string language = null,
            string country  = null)
        {
            Dictionary <string, string> requestParameters = FormatRequestParameters(language: language, country: country);

            return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                       headers => GetAsync <UserProfileResponse>(
                           Hostname,
                           $"/1/user/{mediaNamespace}/profile",
                           new CancellationToken(false),
                           requestParameters,
                           headers)));
        }
        public async Task <TrackActionResponse> CollectionOperationAsync(
            MediaNamespace mediaNamespace,
            TrackActionType operation,
            TrackActionRequest trackActionRequest)
        {
            Dictionary <string, string> requestParameters = await FormatRequestParametersAsync();

            return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                       headers => PostAsync <TrackActionResponse, TrackActionRequest>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/collection/{operation}",
                           trackActionRequest,
                           new CancellationToken(false),
                           requestParameters,
                           headers)));
        }
Esempio n. 15
0
        public async Task <PlaylistActionResponse> PlaylistOperationAsync(
            MediaNamespace mediaNamespace,
            PlaylistActionType operation,
            PlaylistAction playlistAction)
        {
            Dictionary <string, string> requestParameters = FormatRequestParameters();

            return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                       headers => PostAsync <PlaylistActionResponse, PlaylistAction>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/collection/playlists/{operation}",
                           playlistAction,
                           new CancellationToken(false),
                           requestParameters,
                           headers)));
        }
Esempio n. 16
0
        public Task <RadioResponse> ContinueRadioAsync(
            MediaNamespace mediaNamespace,
            string id,
            int?maxItems = null)
        {
            Dictionary <string, string> requestParameters = new Dictionary <string, string>();

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }

            return(ApiCallWithUserAuthorizationHeaderRefreshAsync(
                       headers => GetAsync <RadioResponse>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/radio/{id}/next",
                           new CancellationToken(false),
                           requestParameters,
                           headers)));
        }
Esempio n. 17
0
        private async Task <ContentResponse> DiscoverAsync(
            MediaNamespace mediaNamespace,
            string type,
            string country  = null,
            string language = null,
            string genre    = null)
        {
            Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

            Dictionary <string, string> requestParameters = FormatRequestParameters(language: language, country: country);

            if (!string.IsNullOrEmpty(genre))
            {
                requestParameters.Add("genre", genre);
            }

            return(await GetAsync <ContentResponse>(
                       Hostname,
                       $"/1/content/{mediaNamespace}/{type}",
                       new CancellationToken(false),
                       requestParameters,
                       requestHeaders));
        }
Esempio n. 18
0
        private async Task <ContentResponse> BrowseApiAsync(
            MediaNamespace mediaNamespace,
            ContentSource source,
            ItemType type,
            string genre             = null,
            string mood              = null,
            string activity          = null,
            OrderBy?orderBy          = null,
            int?maxItems             = null,
            int?page                 = null,
            string country           = null,
            string language          = null,
            string continuationToken = null)
        {
            Dictionary <string, string> requestParameters = FormatRequestParameters(continuationToken, language, country);

            if (genre != null)
            {
                requestParameters.Add("genre", genre);
            }

            if (mood != null)
            {
                requestParameters.Add("mood", genre);
            }

            if (activity != null)
            {
                requestParameters.Add("activity", genre);
            }

            if (orderBy.HasValue)
            {
                requestParameters.Add("orderby", orderBy.ToString());
            }

            if (maxItems.HasValue)
            {
                requestParameters.Add("maxitems", maxItems.ToString());
            }

            if (page.HasValue)
            {
                requestParameters.Add("page", page.ToString());
            }

            if (_userTokenManager?.UserIsSignedIn == true)
            {
                return(await ApiCallWithUserAuthorizationHeaderRefreshAsync(
                           headers => GetAsync <ContentResponse>(
                               Hostname,
                               $"/1/content/{mediaNamespace}/{source}/{type}/browse",
                               new CancellationToken(false),
                               requestParameters,
                               headers)));
            }
            else
            {
                Dictionary <string, string> requestHeaders = await FormatRequestHeadersAsync(null);

                return(await GetAsync <ContentResponse>(
                           Hostname,
                           $"/1/content/{mediaNamespace}/{source}/{type}/browse",
                           new CancellationToken(false),
                           requestParameters,
                           requestHeaders));
            }
        }
Esempio n. 19
0
 public Task <ContentResponse> BrowseActivitiesAsync(MediaNamespace mediaNamespace, string country, string language)
 {
     return(BrowseAsync(mediaNamespace, "activities", country, language));
 }
Esempio n. 20
0
 public Task <ContentResponse> SearchContinuationAsync(
     MediaNamespace mediaNamespace,
     string continuationToken)
 {
     return(SearchApiAsync(mediaNamespace, continuationToken: continuationToken));
 }