Beispiel #1
0
        public async Task <VideoResults> GetVideosById(long movieId)
        {
            VideoResults videos   = null;
            var          response = await client.GetAsync(Settings.GetMovieVideos(movieId));

            if (response.IsSuccessStatusCode)
            {
                videos = await response.Content.ReadAsAsync <VideoResults>();
            }
            return(videos);
        }
Beispiel #2
0
        public void GetLatestMovie()
        {
            var url = "https://api.themoviedb.org/3/movie/upcoming?api_key=" + Config.ApiKey + "&language=en-US";

            var          syncClient = new WebClient();
            string       content    = syncClient.DownloadString(url);
            MovieResults mr         = new MovieResults();

            // Create the Json serializer and parse the movie results response
            mr = JSONHelper.Deserialise <MovieResults>(content);

            var movieData = mr.results.FirstOrDefault();     //to get the first item of the results and parse

            m             = new Movie();
            m.id          = movieData.id;
            m.overview    = movieData.overview;
            m.title       = movieData.title;
            m.poster_path = movieData.poster_path;

            if (MovieDbOps.checkValueExists(movieData.id))
            {
                System.Diagnostics.Debug.WriteLine("Already Posted on Fb");
            }
            else
            {
                MovieDbOps.UploadDbContent(m.id, m.title);
                System.Diagnostics.Debug.WriteLine("Data saved in db");

                var          videoUrl     = "https://api.themoviedb.org/3/movie/" + m.id + "/videos?api_key=" + Config.ApiKey + "&language=en-US";
                string       videoContent = syncClient.DownloadString(videoUrl);
                VideoResults vr           = new VideoResults();

                // Create the Json serializer and parse the videourl response
                vr = JSONHelper.Deserialise <VideoResults>(videoContent);
                var    videoData = vr.results.FirstOrDefault();
                string videoKey  = "https://www.youtube.com/watch?v=" + videoData.key.ToString();

                PostOnFb(m, videoKey);
            }
        }