public HttpResponseMessage GetSearchForVine(string query)
        {
            string htmlString = VineScopeHtmlRequester(string.Format("search.php?query={0}", query));

            if (htmlString == null)
            {
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Server is down"));
            }

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(htmlString);

            var vinesNodes = htmlDocument.GetElementbyId("searchresultdata").SelectNodes("div/article");

            if (vinesNodes == null)
            {
                return(this.Request.CreateErrorResponse(HttpStatusCode.NotFound, "Item not found"));
            }

            var vines = new List <VineThumbnail>();

            foreach (var node in vinesNodes)
            {
                var vine = VineThumbnail.Parse(node);
                vine.Url = vine.Url.Substring(vine.Url.LastIndexOf("/") + 1);
                vines.Add(vine);
            }

            return(this.Request.CreateResponse(HttpStatusCode.OK, vines));
        }
        public HttpResponseMessage Get()
        {
            string htmlString = VineScopeHtmlRequester();

            if (htmlString == null)
            {
                return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Server is down"));
            }

            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(htmlString);

            var           indexVideoNode = htmlDocument.GetElementbyId("container").SelectSingleNode("div");
            VineThumbnail indexMainVine  = Vine.Parse(indexVideoNode);

            indexMainVine.Url = Vine.GetUrl(indexMainVine);
            var vines = new List <VineThumbnail>();

            vines.Add(indexMainVine);

            var featuredVinesNodes = htmlDocument.GetElementbyId("container")
                                     .SelectNodes("div/div/div")
                                     .Where(n => n.Attributes["class"] != null &&
                                            n.Attributes["class"].Value == "thumb-list")
                                     .FirstOrDefault()
                                     .SelectNodes("article");

            foreach (var node in featuredVinesNodes)
            {
                var vine = VineThumbnail.Parse(node);
                vine.Url = vine.Url.Substring(vine.Url.LastIndexOf("/") + 1);
                vines.Add(vine);
            }

            return(this.Request.CreateResponse(HttpStatusCode.OK, vines));
        }