Пример #1
0
        /// <summary>
        /// Used to get all the video from Vippy.
        /// Vippy endpoint: GET http://rest.vippy.co/videos
        /// </summary>
        /// <param name="withStatistics">Use true to get information about plays, views ..., when false default values returned</param>
        /// <returns>Collection with all videos <see cref="Video"/></returns>
        public async Task <IEnumerable <Video> > GetVideos(bool withStatistics = false)
        {
            HttpClient client   = this.GetHttpClient();
            var        response = await client.GetAsync(string.Format("/videos?statistics={0}", withStatistics ? "1" : "0")).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(VippyDeserializer.Deserialize <Video>(responseContent));
        }
Пример #2
0
        /// <summary>
        /// Used to get video from Vippy.
        /// Vippy endpoint: GET http://rest.vippy.co/video
        /// </summary>
        /// <param name="videoId">Video id</param>
        /// <param name="withStatistics">Use true to get information about plays, views ..., when false default values returned</param>
        /// <returns>Video <see cref="Video"/></returns>
        public async Task <Video> GetVideo(string videoId, bool withStatistics = false)
        {
            HttpClient client   = this.GetHttpClient();
            var        response = await client.GetAsync(string.Format("/video?videoId={0}&statistics={1}", HttpUtility.UrlEncode(videoId), withStatistics ? "1" : "0")).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(VippyDeserializer.Deserialize <Video>(responseContent).FirstOrDefault());
        }
Пример #3
0
        /// <summary>
        /// Used to get all the tags from this Vippy archive.
        /// Vippy endpoint: GET http://rest.vippy.co/archivetags
        /// </summary>
        /// <param name="archiveId">Login to vippy.co, tools -> Archives, at the bottom you have the archive number.</param>
        /// <returns>Collection with all tags <see cref="Tag"/></returns>
        public async Task <IEnumerable <Tag> > GetTags(string archiveId)
        {
            var client = this.GetHttpClient();

            var response = await client.GetAsync(string.Format("/archivetags?archive={0}", HttpUtility.UrlEncode(archiveId))).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(VippyDeserializer.Deserialize <ArchiveTag>(responseContent));
        }
Пример #4
0
        /// <summary>
        /// Used to get all the players from Vippy.
        /// Vippy endpoint: GET http://rest.vippy.co/players
        /// </summary>
        /// <returns>Collection with all players <see cref="Player"/></returns>
        public async Task <IEnumerable <Player> > GetPlayers()
        {
            var client = this.GetHttpClient();

            var response = await client.GetAsync("/players").ConfigureAwait(false);

            response.EnsureSuccessStatusCode();

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(VippyDeserializer.Deserialize <Player>(responseContent));
        }
Пример #5
0
        /// <summary>
        /// Used to get logo from Vippy
        /// Vippy endpoint: GET http://rest.vippy.co/logo
        /// </summary>
        /// <param name="logoId">Logo id</param>
        /// <returns>Logo <see cref="Logo"/></returns>
        public async Task <Logo> GetLogo(string logoId)
        {
            var client = this.GetHttpClient();

            var response = await client.GetAsync(string.Format("/logo?logoId={0}", HttpUtility.UrlEncode(logoId))).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(VippyDeserializer.Deserialize <Logo>(responseContent).FirstOrDefault());
        }
Пример #6
0
        /// <summary>
        /// Used to get all the thumbnails for provided videos.
        /// Vippy endpoint: GET  http://rest.vippy.co/videothumbnails
        /// </summary>
        /// <param name="videoIds">Array of video ids</param>
        /// <returns>Collection with all thumbnails <see cref="Thumbnail"/></returns>
        public async Task <IEnumerable <Thumbnail> > GetVideoThumbnails(string[] videoIds)
        {
            HttpClient client = this.GetHttpClient();

            var queryString = new StringBuilder();

            for (int i = 0; i < videoIds.Length; i++)
            {
                queryString.AppendFormat("&videoId%5B{0}%5D={1}", i, videoIds[i]);
            }

            var requestString = string.Format("/videothumbnails?{0}", queryString.ToString().TrimStart('&'));
            var response      = await client.GetAsync(requestString).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            return(VippyDeserializer.Deserialize <Thumbnail>(responseContent));
        }