예제 #1
0
        static void Main(string[] args)
        {
            var terms = new SearchTerms();

            terms.rawString = "if i were you";

            AppleSearchEngine engine    = new AppleSearchEngine();
            List <Series>     searchRes = engine.searchSeries(terms);

            Console.WriteLine("Count: " + searchRes.Count);
            if (searchRes.Count <= 0)
            {
                Console.WriteLine("Returned no results");
            }
            Console.WriteLine(searchRes[0]);

            Console.WriteLine("Grabbing first search result and doing full parse");


            RSSReader reader     = new RSSReader();
            Series    fullSeries = searchRes[0];
            var       succ       = reader.ParseSeriesRSS(ref fullSeries);

            if (succ == false)
            {
                Console.WriteLine("Could not parse full series RSS feed");
            }

            Console.WriteLine("After parse: " + fullSeries);
            Console.WriteLine("Downloading most recent episode {0}", fullSeries.Episodes[0].Name);

            PodStreamer.DownloadMedia(fullSeries.Episodes[0].ContentInfo.Link.ToString());
        }
예제 #2
0
        public Uri buildQueryString(SearchTerms terms)
        {
            UriBuilder query      = new UriBuilder(this.AppleBaseString);
            var        parameters = HttpUtility.ParseQueryString(String.Empty);

            parameters["term"]      = terms.rawString;
            parameters["media"]     = "podcast";
            parameters["entity"]    = "podcast";
            parameters["attribute"] = "titleTerm";
            parameters["limit"]     = "100";
            query.Query             = parameters.ToString();

            return(query.Uri);
        }
예제 #3
0
        public List <Series> searchSeries(SearchTerms terms)
        {
            Uri             searchUri     = buildQueryString(terms);
            AppleRepoParser repoParser    = new AppleRepoParser();
            List <Series>   parsedResults = null;

            WebRequest req = WebRequest.Create(searchUri);

            req.Method      = WebRequestMethods.Http.Get;
            req.ContentType = "application/json";
            var    res = (HttpWebResponse)req.GetResponse();
            string ptext;

            using (var sr = new StreamReader(res.GetResponseStream()))
            {
                ptext = sr.ReadToEnd();
            }

            parsedResults = repoParser.ParseJSON(ptext);

            return(parsedResults);
        }