public void videoListTest() {
      var query = new VideoListQuery
      {
       count = 10,
       labels = new string[]{"api", "api2"}
      };

      var col = this.api.getVideoList(query);
      this.assertEqual(col.Count, 1, "videoList");
    }
Exemple #2
0
        /// <summary>
        /// This API call returns a list of the user's active videos along with it's relevant metadata. 20 videos are returned by default but this is customisable.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List <Video> getVideoList(VideoListQuery query)
        {
            var url = apiUrl + "/api/" + username + "/videos.json?count=" + query.count.ToString();

            if (query.labels.Length > 0)
            {
                url += "&labels=" + String.Join(",", query.labels);   //should we have it URL Encoded?
            }

            if (query.status != String.Empty)
            {
                url += "&status=" + query.status;
            }

            if (query.sort == VideoListSorting.ASCENDING)
            {
                url += "&sort=" + "asc";
            }
            else
            {
                url += "&sort=" + "desc";
            }

            if (query.title != String.Empty)
            {
                url += "&title=" + HttpUtility.UrlEncode(query.title);
            }

            var response = executeRequest(url);
            var jo       = (JArray)JsonConvert.DeserializeObject(response);

            var result = new List <Video>();

            foreach (var o in jo)
            {
                var video = new Video
                {
                    status      = (string)o["status"],
                    statusId    = (int)o["status_id"],
                    duration    = (decimal)o["duration"],
                    description = (string)o["description"],
                    height      = string.IsNullOrEmpty(o["height"].ToString()) ? 0 : int.Parse(o["height"].ToString()),
                    createdAt   = DateTime.Parse((string)o["created_at"].ToString()),
                    width       = string.IsNullOrEmpty(o["width"].ToString()) ? 0 : int.Parse(o["width"].ToString()),
                    playCount   = (Int64)o["play_count"],
                    version     = (string)o["version"],
                    thumbnail   = (string)o["thumbnail"],
                    url         = (string)o["url"],
                    id          = (Int64)o["id"],
                    title       = (string)o["title"],
                    user        = new VideoAuthor
                    {
                        videoCount = (Int64)o["user"]["video_count"],
                        name       = (string)o["user"]["author_name"],
                        account    = (int)o["user"]["author_account"],
                        url        = (string)o["user"]["author_url"]
                    }
                };

                result.Add(video);
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// This API call returns a list of the user's active videos along with it's relevant metadata. 20 videos are returned by default but this is customisable.
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public List<Video> getVideoList(VideoListQuery query)
        {
            var url = apiUrl + "/api/" + username + "/videos.json?count=" + query.count.ToString();

            if (query.labels.Length > 0)
            {
                var outh = new OAuthBase();
                url += "&labels=" + outh.UrlEncode(String.Join(",", query.labels));
            }

            if (query.status != String.Empty)
            {
                url += "&status=" + query.status;
            }

            if (query.sort == VideoListSorting.ASCENDING)
            {
                url += "&sort=" + "asc";
            }
            else
            {
                url += "&sort=" + "desc";
            }

            if (query.title != String.Empty)
            {
                url += "&title=" + HttpUtility.UrlEncode(query.title);
            }

            url += "&page=" + ((query.page > 1) ? query.page : 1);

            var response = executeRequest(url);
            var jo = (JArray)JsonConvert.DeserializeObject(response);

            var result = new List<Video>();

            foreach (var o in jo)
            {
                var video = new Video
                {
                    status = (string)o["status"],
                    statusId = String.IsNullOrEmpty(o["status_id"].ToString()) ? 0 : int.Parse(o["status_id"].ToString()),
                    duration = String.IsNullOrEmpty(o["duration"].ToString()) ? 0 : decimal.Parse(o["duration"].ToString()),
                    description = (string)o["description"],
                    height = string.IsNullOrEmpty(o["height"].ToString()) ? 0 : int.Parse(o["height"].ToString()),
                    createdAt = DateTime.Parse((string)o["created_at"].ToString()),
                    width = string.IsNullOrEmpty(o["width"].ToString()) ? 0 : int.Parse(o["width"].ToString()),
                    playCount = String.IsNullOrEmpty(o["play_count"].ToString()) ? 0 : Int64.Parse(o["play_count"].ToString()),
                    version = (string)o["version"],
                    thumbnail = (string)o["thumbnail"],
                    url = (string)o["url"],
                    id = String.IsNullOrEmpty(o["id"].ToString()) ? 0 : Int64.Parse(o["id"].ToString()),
                    title = (string)o["title"],
                    user = new VideoAuthor
                    {
                        videoCount = String.IsNullOrEmpty(o["user"]["video_count"].ToString()) ? 0 : Int64.Parse(o["user"]["video_count"].ToString()),
                        name = (string)o["user"]["author_name"],
                        account = String.IsNullOrEmpty(o["user"]["author_account"].ToString()) ? 0 : int.Parse(o["user"]["author_account"].ToString()),
                        url = (string)o["user"]["author_url"]
                    }
                };

                result.Add(video);
            }

            return result;
        }