Ejemplo n.º 1
0
        public static async Task <JSON_ListVideos> ListLikes(string UserID, string Fields, VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 10, int OffSet = 1)
        {
            var parameters = new Dictionary <string, string>
            {
                { "fields", Fields },
                { "limit", Limit.ToString() },
                { "page", OffSet.ToString() },
                { "sort", Sort.ToString() }
            };

            using (HtpClient localHttpClient = new HtpClient(new HCHandler()))
            {
                HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/user/{UserID}/likes", parameters)).ConfigureAwait(false);

                var result = await ResPonse.Content.ReadAsStringAsync();

                return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result));
            }
        }
Ejemplo n.º 2
0
        public async Task <JSON_ListVideos> ListFavorites(VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 10, int OffSet = 1)
        {
            var parameters = new Dictionary <string, string>
            {
                { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsVideo))) },
                { "limit", Limit.ToString() },
                { "page", OffSet.ToString() },
                { "sort", Sort.ToString() }
            };

            using (HtpClient localHttpClient = new HtpClient(new HCHandler()))
            {
                var RequestUri = new pUri(string.Format("/user/me/favorites"), parameters);
                HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false);

                var result = await ResPonse.Content.ReadAsStringAsync();

                return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result));
            }
        }
Ejemplo n.º 3
0
        public static async Task <JSON_ListVideos> SearchForAVideo(string UserID, string Fields, string Keyword, VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 100, int OffSet = 1)
        {
            var parameters = new Dictionary <string, string>
            {
                { "fields", Fields },
                { "search", Keyword },//   { "search", SearchType == SearchTypesEnum.Contains ? Keyword : string.Concat("\"", Keyword.Replace(" ", "+"), "\"") },
                { "limit", Limit.ToString() },
                { "page", OffSet.ToString() },
                { "sort", Sort.ToString() }
            };

            using (HtpClient localHttpClient = new HtpClient(new HCHandler()))
            {
                HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/user/{UserID}/videos", parameters)).ConfigureAwait(false);

                string result = await ResPonse.Content.ReadAsStringAsync();

                return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result));
            }
        }
Ejemplo n.º 4
0
        public async Task <JSON_ListVideos> ListVideosInSubscriptedChannels(ChannelsEnum Channel, int?DurationShorterOrEqual_inMins = null, VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 10, int OffSet = 1)
        {
            var parameters = new Dictionary <string, string>
            {
                { "shorter_than", DurationShorterOrEqual_inMins.HasValue ? DurationShorterOrEqual_inMins.Value.ToString() : null },
                { "channel", Channel.ToString() },
                { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsVideo))) },
                { "limit", Limit.ToString() },
                { "page", OffSet.ToString() },
                { "sort", Sort.ToString() }
            };

            using (HtpClient localHttpClient = new HtpClient(new HCHandler()))
            {
                HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/user/me/subscriptions", parameters)).ConfigureAwait(false);

                string result = await ResPonse.Content.ReadAsStringAsync();

                return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result));
            }
        }
Ejemplo n.º 5
0
        public async Task <JSON_ListVideos> AdvancedVideoSearch(string Keyword, SearchTypesEnum SearchType, SearchOption SearchOption, VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 100, int OffSet = 1)
        {
            bool KeepLooping = true;
            List <JSON_VideoMetadata> fin      = new List <JSON_VideoMetadata>();
            JSON_ListVideos           toreturn = new JSON_ListVideos();

            do
            {
                var parameters = new Dictionary <string, string>
                {
                    { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsVideo)).ToList().Where(u => !u.StartsWith("preview_") && !u.StartsWith("publish_date") && !u.StartsWith("expiry_date_deletion") && !u.StartsWith("expiry_date")).ToList()) },
                    { "search", SearchType == SearchTypesEnum.Contains ? Keyword : string.Concat("\"", Keyword.Replace(" ", "+"), "\"") },
                    { "longer_than", SearchOption.LongerThan_Mins.HasValue ? SearchOption.LongerThan_Mins.Value.TotalMinutes.ToString() : null },
                    { "shorter_than", SearchOption.ShorterThan_Mins.HasValue ? SearchOption.ShorterThan_Mins.Value.TotalMinutes.ToString() : null },
                    { "360_degree", SearchOption._360VideosOnly ? "1" : null },
                    { "channel", SearchOption.Channel.HasValue ? SearchOption.Channel.Value.ToString() : null },
                    { "no_live", SearchOption.NonLiveStreamingVideos ? "1" : null },
                    { "hd", SearchOption.HDVideosOnly ? "1" : null },
                    { "verified", SearchOption.VerifiedUserVideosOnly ? "1" : null },
                    { "premium", SearchOption.PremiumVideosOnly ? "1" : null },
                    { "created_before", SearchOption.CreatedBeforeDate.HasValue ? DateTimeToUnixTimestampMilliseconds(SearchOption.CreatedBeforeDate.Value).ToString() : null },
                    { "created_after", SearchOption.CreatedAfterDate.HasValue ? DateTimeToUnixTimestampMilliseconds(SearchOption.CreatedAfterDate.Value).ToString() : null },
                    { "limit", Limit.ToString() },
                    { "page", OffSet.ToString() },
                    { "sort", Sort.ToString() }
                };
                using (HtpClient localHttpClient = new HtpClient(new HCHandler()))
                {
                    HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/videos", parameters.RemoveEmptyValues())).ConfigureAwait(false);

                    string result = await ResPonse.Content.ReadAsStringAsync();

                    return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result));
                }
            }while (!KeepLooping == false);
            return(toreturn);
        }