Exemplo n.º 1
0
        public async Task OnGet(string id)
        {
            backDrop       = History.GetBackDrop();
            History.CastID = Convert.ToInt32(id);

            movieID = History.GetMovieID();
            await Program.Fetch.GrabCastBioAsync(id);

            string bioData      = Program.Fetch.Bios;
            string movieCredits = Program.Fetch.movieCredits;

            JsonNinja bNinja = new JsonNinja(bioData);

            bios    = bNinja.GetDetails("\"biography\"");
            name    = bNinja.GetDetails("\"name\"")[0];
            bio     = ((bios[0].Replace("\n", "")).Replace("\\", "")).Replace(".nn", ". ");
            castImg = bNinja.GetPosters("\"profile_path\"");
            img     = castImg[0];

            bNinja = new JsonNinja(movieCredits);

            List <string> cast = bNinja.GetDetails("\"cast\"");

            bNinja = new JsonNinja(cast[0]);

            vote        = bNinja.GetIds("\"vote_average\"");
            movieId     = bNinja.GetIds("\"id\"");
            posterPaths = bNinja.GetDetails("\"poster_path\"");
            titles      = bNinja.GetDetails("\"original_title\"");
        }
Exemplo n.º 2
0
        private static async Task AskQuestion(string question)
        {
            string newText = "";

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue
                                                        ("applicationException/json"));

            HttpResponseMessage response = await client.GetAsync($"http://api.duckduckgo.com/?q= {question} &format=json");

            if (response.IsSuccessStatusCode)
            {
                string Data = await response.Content.ReadAsStringAsync();

                JsonNinja     ninja   = new JsonNinja(Data);
                List <string> answer  = ninja.GetDetails("\"Abstract\"");
                List <string> rTopics = ninja.GetDetails("\"RelatedTopics\"");
                JsonNinja     ninji   = new JsonNinja(rTopics[0]);
                List <string> texts   = ninji.GetDetails("\"Text\"");
                //Console.WriteLine("Answer: \n");
                if (answer[0] != "")
                {
                    string addStr = answer[0].Split('.')[0];
                    wolframText += "\n" + addStr;
                    Console.WriteLine(wolframText);
                }
                else
                {
                    if (texts.Count == 0)
                    {
                        //string data = ""; //this is so that if the search field is empty it does not show what was last searched
                        Console.WriteLine(wolframText);
                    }
                    else
                    {
                        int count = 1;
                        wolframText += "\nFound " + texts.Count + " other result(s)";
                        //Console.WriteLine("Found " + texts.Count + " results");
                        foreach (string text in texts)
                        {
                            newText += count + ": " + text.Split('.')[0].Replace("\\", "") + "\n";
                            //Console.WriteLine(count + ": " + newText + "\n");
                            count++;
                        }
                        wolframText += "\n" + newText;
                        Console.WriteLine(wolframText);
                    }
                }
            }
            else
            {
                string Data = ""; //this is so that if the search field is empty it does not show what was last searched
                Console.WriteLine(Data);
            }
        }
Exemplo n.º 3
0
        public static string FredReads()
        {
            List <string> tempWords = new List <string>();
            List <string> words     = new List <string>();

            jNinja = new JsonNinja(data);
            string filterCollection = jNinja.GetDetails("\"regions\"")[0]; // jNinja.GetInfo("\"regions\"");

            jNinja           = new JsonNinja(filterCollection);
            filterCollection = jNinja.GetDetails("\"lines\"")[0];             // jNinja.GetInfo("\"lines\"");
            jNinja           = new JsonNinja(filterCollection);
            List <string> filterCollections = jNinja.GetDetails("\"words\""); // jNinja.GetInfoList("\"words\"");

            for (int i = 0; i < filterCollections.Count; i++)
            {
                jNinja    = new JsonNinja(filterCollections[i]);
                tempWords = jNinja.GetDetails("\"text\""); // jNinja.GetInfoList("\"text\"");
                foreach (string word in tempWords)
                {
                    words.Add(word);
                }
            }

            string fredReads = string.Join(" ", words);

            return(fredReads);
        }
Exemplo n.º 4
0
        private async Task ShowPoster(string search)
        {
            await Program.Fetch.GrabPosterAsync(search);

            if (Program.Fetch.Data == null)
            {
                emptySearch = true;
            }
            else
            {
                jNinja = new JsonNinja(Program.Fetch.Data);

                List <string> names = jNinja.GetNames();
                List <string> vals  = jNinja.GetVals();

                if (vals[1] == "0")
                {
                    invalidSearch = true;
                }
                else
                {
                    filter = jNinja.GetDetails("\"results\"");

                    jNinja = new JsonNinja(filter[0]);

                    posterPath = jNinja.GetPosters("\"poster_path\"");
                    id         = jNinja.GetIds("\"id\"");
                }
            }
        }
Exemplo n.º 5
0
        public async Task OnGet(string id)
        {
            int moviePer;

            if (Convert.ToInt32(id) > 4)// if more than 4 movies in cart show only 1 similar movie else show 2 per
            {
                moviePer = 1;
            }
            else
            {
                moviePer = 2;
            }
            for (int i = 0; i < rentedMovieIDs.Count; i++)
            {
                await Program.Fetch.GetSImilarMovies(rentedMovieIDs[i]);

                JsonNinja similarMovieDetails = new JsonNinja(Program.Fetch.SimilarMovies);
                similarMovies       = similarMovieDetails.GetVals();
                similarMovieDetails = new JsonNinja(similarMovies[1]);
                List <string> moviePoster = similarMovieDetails.GetDetails("\"poster_path\"");
                List <string> movieTitle  = similarMovieDetails.GetDetails("\"title\"");
                List <string> movieID     = similarMovieDetails.GetIds("\"id\"");
                List <string> movieRating = similarMovieDetails.GetIds("\"vote_average\"");

                int count = 0;
                for (int j = 0; j < movieTitle.Count; j++)
                {
                    if (Convert.ToDouble(movieRating[j]) > 6.0 && !rentedMovieTitles.Contains(movieTitle[j]) &&
                        !similarMoviesTitle.Contains(movieTitle[j]))
                    {
                        count++;
                        similarMoviesPoster.Add(moviePoster[j]);
                        similarMoviesTitle.Add(movieTitle[j]);
                        similarMoviesID.Add(movieID[j]);

                        if (count == moviePer)
                        {
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        } // OnPostRemoveWeather()

        public async Task OnPostNews(string Coun, string Articles, int Time)
        {
            display = "grid";

            // SETTINGS
            Program.News.selCoun       = Coun;
            Program.News.numOfArticles = Articles;
            Program.News.selTime       = Convert.ToString(Time);

            // Pulling in information from the API
            await Program.Fetch.GrabNews(Coun, Articles);

            jNinja = new JsonNinja(Program.Fetch.Data);
            List <string> newsNames = jNinja.GetNames();
            List <string> newsVals  = jNinja.GetVals();

            // Retrieve information from News Class
            selCoun       = Program.News.selCoun;
            numOfArticles = Program.News.numOfArticles;
            selTime       = Program.News.selTime;

            // Grab information from NewsDataClass
            headline      = Program.NewsData.headline;
            headlineList  = Program.NewsData.headlineList;
            published     = Program.NewsData.published;
            publishedList = Program.NewsData.publishedList;
            publishedDate = Program.NewsData.publishedDate;
            headlines     = Program.NewsData.headlines;
            publishDates  = Program.NewsData.publishDates;

            int countArticle = Convert.ToInt32(Articles);

            for (int i = 0; i < countArticle; i++)
            {
                headlineList = jNinja.GetDetails("\"title\"");
                headline     = headlineList[i];
                headline     = headline.Replace("\"", "");
                Program.NewsData.AddHeadline(headline);
                publishedList = jNinja.GetDetails("\"publishedAt\"");
                published     = publishedList[i];
                published     = published.Replace("\"", "");
                published     = published.Replace("T", " ");
                published     = published.Replace("Z", "");
                publishedDate = DateTime.ParseExact(published, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); // stops the next line from taking the default time value
                // ^ date format has to be in the exact format as how it is taken in - then you can change it after the fact
                published = publishedDate.ToString("dddd, MMMM dd yyyy HH:mm tt (zzz") + " time zone difference.)";
                Program.NewsData.AddPublished(published);
            }
            headline  = Program.NewsData.GetHeadline();
            published = Program.NewsData.GetPublished();

            if (Program.UserDetails.UserID == 0) // not logged in
            {
                // only display the home page - no settings AKA no settings page to see these options.
            }

            else
            {
                using (SqlConnection myConn = new SqlConnection(Program.Fetch.cs))
                {
                    SqlCommand getNews = new SqlCommand
                    {
                        Connection = myConn
                    };
                    myConn.Open();

                    // Put in same order as the SP & Table (maybe change userId to last - since it's a FK ??)
                    // INSERT DEFAULT VALUES OF canada, 10, 15
                    getNews.Parameters.AddWithValue("@userId", Program.UserDetails.UserID);
                    getNews.Parameters.AddWithValue("@country", selCoun);
                    getNews.Parameters.AddWithValue("@articles", numOfArticles);
                    getNews.Parameters.AddWithValue("@time", Time);

                    getNews.CommandText = ("[spNewsSettings]");
                    getNews.CommandType = System.Data.CommandType.StoredProcedure;

                    getNews.ExecuteNonQuery();

                    myConn.Close();
                }
            }
            // Refresh the settings page @ news pos on page
        } //OnPostNews()
Exemplo n.º 7
0
        public async Task OnPostWeather(string City, string Country, string Unit)
        {
            display = "grid";
            // HAVE TO MAKE A DEFAULT - London, ON & Metric. DONE IN DB NOT DD

            // SETTINGS
            Program.Weather.selCity    = City;
            Program.Weather.selCountry = Country;
            Program.Weather.selUnit    = Unit;

            // Pulling in information from the API
            await Program.Fetch.GrabWeather(City, Country, Unit);

            jNinja = new JsonNinja(Program.Fetch.Data);
            List <string> names = jNinja.GetNames();
            List <string> vals  = jNinja.GetVals();

            Program.Weather.selCity    = jNinja.GetInfo("\"name\"");
            Program.Weather.selCountry = jNinja.GetInfo("\"country\"");

            // Retrieve information from Weather Class
            selCity    = Program.Weather.selCity;
            selCountry = Program.Weather.selCountry;
            selUnit    = Program.Weather.selUnit;

            selCity    = selCity.Replace("\"", "");
            selCountry = selCountry.Replace("\"", "");

            // Retrieve information from WeatherData Class
            // weather
            weather  = Program.WeatherData.weather;
            wetId    = Program.WeatherData.wetId;
            wetMain  = Program.WeatherData.wetMain;
            desc     = Program.WeatherData.desc;
            dayIcon  = Program.WeatherData.dayIcon;
            icon     = Program.WeatherData.icon;
            iconShow = Program.WeatherData.iconShow;
            // main
            temp       = Program.WeatherData.temp;
            tempHigh   = Program.WeatherData.tempHigh;
            tempLow    = Program.WeatherData.tempLow;
            humidity   = Program.WeatherData.humidity;
            pressure   = Program.WeatherData.pressure;
            visibility = Program.WeatherData.visibility;
            // wind
            wind      = Program.WeatherData.wind;
            windSpeed = Program.WeatherData.windSpeed;
            windDir   = Program.WeatherData.windDir;
            windText  = Program.WeatherData.windText;
            // length of day
            sunrise  = Program.WeatherData.sunrise;
            riseTime = Program.WeatherData.riseTime;
            sunset   = Program.WeatherData.sunset;
            setTime  = Program.WeatherData.setTime;
            // clouds
            clouds = Program.WeatherData.clouds;
            all    = Program.WeatherData.all;

            // weather
            listNinja = new JsonNinja(Program.Fetch.Data);
            weather   = listNinja.GetDetails("\"weather\"");
            wetId     = jNinja.GetInfo("\"id\"");          // might not need
            wetMain   = jNinja.GetDetails("\"main\"");     // ie. rain
            desc      = jNinja.GetInfo("\"description\""); // ie. light rain
            desc      = desc.Replace("\"", "");
            dayIcon   = listNinja.GetDetails("\"icon\"");
            icon      = dayIcon[0].Replace("\"]", "");
            icon      = icon.Replace("\"", "");
            iconShow  = "http://openweathermap.org/img/w/" + icon + ".png";

            // main
            temp       = wetMain[1].Replace("\"temp\":", ""); // fix! if rain and mist etc temp doesn't show properly
            tempHigh   = jNinja.GetInfo("\"temp_max\"");
            tempLow    = jNinja.GetInfo("\"temp_min\"");
            humidity   = jNinja.GetInfo("\"humidity\"");
            pressure   = jNinja.GetInfo("\"pressure\"");
            visibility = jNinja.GetInfo("\"visibility\"");

            // wind
            wind      = listNinja.GetDetails("\"wind\"");
            windSpeed = wind[0].Replace("\"speed\":", "");
            windDir   = jNinja.GetInfo("\"deg\"");

            // length of day
            sunrise  = jNinja.GetInfo("\"sunrise\"");
            riseTime = (new DateTime(1970, 1, 1)).AddMilliseconds(double.Parse(sunrise) * 1000).ToLocalTime().ToLongTimeString();
            sunset   = jNinja.GetInfo("\"sunset\"");
            setTime  = (new DateTime(1970, 1, 1)).AddMilliseconds(double.Parse(sunset) * 1000).ToLocalTime().ToLongTimeString();

            // clouds
            clouds = listNinja.GetDetails("\"clouds\"");
            all    = clouds[0].Replace("\"all\":", "");

            metric   = Program.Weather.metric;
            imperial = Program.Weather.imperial;
            kelvin   = Program.Weather.kelvin;

            if (Unit == "Metric") // Metric
            {
                temp       = temp + "°C";
                tempHigh   = tempHigh + "°C";
                tempLow    = tempLow + "°C";
                visibility = visibility + " meters";
                windSpeed  = windSpeed + " meters/second";
            }
            else if (Unit == "Imperial")
            {
                temp       = temp + "°F";
                tempHigh   = tempHigh + "°F";
                tempLow    = tempLow + "°F";
                visibility = visibility + " feet";
                windSpeed  = windSpeed + " miles/hour";
            }
            else // Kelvin
            {
                temp       = temp + "°K";
                tempHigh   = tempHigh + "°K";
                tempLow    = tempLow + "°K";
                visibility = visibility + " meters";
                windSpeed  = windSpeed + " meters/second";
            }

            // When Imperial is selected the input string is not the correct type & only sometimes ??
            // Break down into only N/NE/E/SE/S/SW/W/NW ??
            // Take out decimal values?

            /*double windTemp = Convert.ToDouble(windDir);
             * switch (windTemp)
             * {
             *  case double windDir when (windDir >= 348.75 && windDir <= 11.25):
             *      // 348.75 - 11.25 = N
             *      windText = windDir + " °N";
             *      break;
             *  case double windDir when (windDir >= 11.26 && windDir <= 33.75):
             *      // 11.26 - 33.75 = NNE
             *      windText = windDir + " °NNE";
             *      break;
             *  case double windDir when (windDir >= 33.76 && windDir <= 56.25):
             *      // 33.76 - 56.25 = NE
             *      windText = windDir + " °NE";
             *      break;
             *  case double windDir when (windDir >= 56.26 && windDir <= 78.75):
             *      // 56.26 - 78.75 = ENE
             *      windText = windDir + " °ENE";
             *      break;
             *  case double windDir when (windDir >= 78.76 && windDir <= 101.25):
             *      // 78.76 - 101.25 = E
             *      windText = windDir + " °E";
             *      break;
             *  case double windDir when (windDir >= 101.26 && windDir <= 123.75):
             *      // 101.26 - 123.75 = ESE
             *      windText = windDir + " °ESE";
             *      break;
             *  case double windDir when (windDir >= 123.76 && windDir <= 146.25):
             *      // 123.76 - 146.25 = SE
             *      windText = windDir + " °SE";
             *      break;
             *  case double windDir when (windDir >= 146.26 && windDir <= 168.75):
             *      // 146.26 - 168.75 = SSE
             *      windText = windDir + " °SSE";
             *      break;
             *  case double windDir when (windDir >= 168.76 && windDir <= 191.25):
             *      // 168.76 - 191.25 = S
             *      windText = windDir + " °S";
             *      break;
             *  case double windDir when (windDir >= 191.26 && windDir <= 213.75):
             *      // 191.26 - 213.75 = SSW
             *      windText = windDir + " °SSW";
             *      break;
             *  case double windDir when (windDir >= 213.76 && windDir <= 236.25):
             *      // 213.76 - 236.25 = SW
             *      windText = windDir + " °SW";
             *      break;
             *  case double windDir when (windDir >= 236.26 && windDir <= 258.75):
             *      // 236.26 - 258.75 = WSW
             *      windText = windDir + " °WSW";
             *      break;
             *  case double windDir when (windDir >= 258.76 && windDir <= 281.25):
             *      // 258.76 - 281.25 = W
             *      windText = windDir + " °W";
             *      break;
             *  case double windDir when (windDir >= 281.26 && windDir <= 303.75):
             *      // 281.26 - 303.75 = WNW
             *      windText = windDir + " °WNW";
             *      break;
             *  case double windDir when (windDir >= 303.76 && windDir <= 326.25):
             *      // 303.76 - 326.25 = NW
             *      windText = windDir + " °NW";
             *      break;
             *  case double windDir when (windDir >= 326.26 && windDir <= 348.74):
             *      // 326.26 - 348.75 = NNW
             *      windText = windDir + " °NNW";
             *      break;
             *  default:
             *      break;
             * } //windTemp() - Wind Direction*/

            if (Program.UserDetails.UserID == 0) // not logged in
            {
                // only display the home page - no settings AKA no settings page to see these options.
            }

            else
            {
                using (SqlConnection myConn = new SqlConnection(Program.Fetch.cs))
                {
                    SqlCommand getWeather = new SqlCommand
                    {
                        Connection = myConn
                    };
                    myConn.Open();

                    // Put in same order as the SP & Table (maybe change userId to last - since it's a FK ??)
                    // INSERT DEFAULT VALUES OF LONDON, CANADA AND METRIC - Done in Database????
                    getWeather.Parameters.AddWithValue("@userId", Program.UserDetails.UserID);
                    getWeather.Parameters.AddWithValue("@country", selCountry);
                    getWeather.Parameters.AddWithValue("@city", selCity);
                    getWeather.Parameters.AddWithValue("@unit", Unit);

                    getWeather.CommandText = ("[spWeatherSettings]");
                    getWeather.CommandType = System.Data.CommandType.StoredProcedure;

                    getWeather.ExecuteNonQuery();

                    myConn.Close();
                }
            }
            // Refresh the settings page @ weather pos on page
        } //OnPostWeather()
Exemplo n.º 8
0
        public async void WordsToText()
        {
            /*if ((args.Length < 2) || (string.IsNullOrWhiteSpace(args[0])))
            {
                Console.WriteLine("Arg[0]: Specify the endpoint to hit https://speech.platform.bing.com/recognize");
                Console.WriteLine("Arg[1]: Specify a valid input wav file.");

                return;
            }*/

            await RecordSound.Record();
            Thread.Sleep(3000); // allows 5secs of recording
            await RecordSound.StopRecording();


            // Note: Sign up at https://azure.microsoft.com/en-us/try/cognitive-services/ to get a subscription key.  
            // Navigate to the Speech tab and select Bing Speech API. Use the subscription key as Client secret below.
            AuthenticationSTT auth = new AuthenticationSTT("de48ef5b15d34f6498fbd831f5d72aec");// Environment.GetEnvironmentVariable("azure_STT_Key", EnvironmentVariableTarget.User));

            string requestUri = "https://westus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US"; //args[0];/*.Trim(new char[] { '/', '?' });*/

            string host = @"westus.stt.speech.microsoft.com";
            string contentType = @"audio/wav; codec=""audio/pcm""; samplerate=16000";
            List<string> texts;

            /*
             * Input your own audio file or use read from a microphone stream directly.
             */
            string curDir = Directory.GetCurrentDirectory();
            //string audioFile = curDir + "\\test.wav"; //args[1];
            string responseString;
            FileStream fs = null;

            try
            {
                var token = auth.GetAccessToken();
                //Console.WriteLine("Token: {0}\n", token);
                //Console.WriteLine("Request Uri: " + requestUri + Environment.NewLine);

                HttpWebRequest request = null;
                request = (HttpWebRequest)HttpWebRequest.Create(requestUri);
                request.SendChunked = true;
                request.Accept = @"application/json;text/xml";
                request.Method = "POST";
                request.ProtocolVersion = HttpVersion.Version11;
                request.Host = host;
                request.ContentType = contentType;
                request.Headers["Authorization"] = "Bearer " + token;

                int trial = 0;
                while (trial < 2)
                {
                    using (fs = new FileStream(@"record.wav", FileMode.Open, FileAccess.Read))
                    {

                        /*
                         * Open a request stream and write 1024 byte chunks in the stream one at a time.
                         */
                        byte[] buffer = null;
                        int bytesRead = 0;
                        using (Stream requestStream = request.GetRequestStream())
                        {
                            /*
                             * Read 1024 raw bytes from the input audio file.
                             */
                            buffer = new Byte[checked((uint)Math.Min(1024, (int)fs.Length))];
                            while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0)
                            {
                                requestStream.Write(buffer, 0, bytesRead);
                            }

                            // Flush
                            requestStream.Flush();
                        }
                    }
                    trial++;
                }

                /*
                     * Get the response from the service.
                     */
                //Console.WriteLine("Response:");
                using (WebResponse response = request.GetResponse())
                {
                    //Console.WriteLine(((HttpWebResponse)response).StatusCode);

                    using (StreamReader sr = new StreamReader(response.GetResponseStream()))
                    {
                        responseString = sr.ReadToEnd();

                        JsonNinja jninja = new JsonNinja(responseString);

                        texts = jninja.GetDetails("\"DisplayText\"");
                    }

                    Console.WriteLine(texts[0]);
                    text = texts[0];
                    //Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
                Console.WriteLine("Nothing recorded...");
                text = "Nothing recorded";
            }
        }
Exemplo n.º 9
0
        public static async Task DetectFace()
        {
            client.DefaultRequestHeaders.Clear();
            List <string> faceIDs = new List <string>();

            JsonArray jsonArray = (JsonArray)JsonValue.Parse(data);

            foreach (JsonObject obj in jsonArray)
            {
                JsonValue id;
                obj.TryGetValue("faceId", out id);
                faceIDs.Add(id.ToString());
            }

            var queryString = HttpUtility.ParseQueryString(string.Empty);

            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "e97b9e9e76314914b139b73a8a2148cb");

            var uri = "https://eastus.api.cognitive.microsoft.com/face/v1.0/identify?" + queryString;

            HttpResponseMessage response;

            // Request body
            if (faceIDs.Count > 0)
            {
                string faceID = "";
                if (faceIDs.Count != 1)
                {
                    foreach (string face in faceIDs)
                    {
                        faceID += face + ",";
                    }
                }
                else
                {
                    faceID = faceIDs[0];
                }

                byte[] byteData = Encoding.UTF8.GetBytes("{\"PersonGroupId\": \"1111\", \"faceIds\": [" +
                                                         faceID + "]," +
                                                         "\"maxNumOfCandidatesReturned\": 1," +
                                                         "\"confidenceThreshold\": 0.5}");

                using (var content = new ByteArrayContent(byteData))
                {
                    content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                    response = await client.PostAsync(uri, content);
                }

                if (response.IsSuccessStatusCode)
                {
                    data = await response.Content.ReadAsStringAsync();
                }
                else
                {
                    // do nothing yet
                }

                jNinja = new JsonNinja(data);
                List <string> filterCollections = jNinja.GetDetails("\"candidates\""); // jNinja.GetInfoList("\"candidates\"");
                for (int i = 0; i < filterCollections.Count; i++)
                {
                    jNinja = new JsonNinja(filterCollections[i]);
                    if (filterCollections[i] == "")
                    {
                        names.Add("dont recognize");
                    }
                    else
                    {
                        faces.Add(jNinja.GetDetails("\"personId\"")[0]); // jNinja.GetInfo("\"personId\"")
                    }
                }


                foreach (string face in faces)
                {
                    await GetPerson(face);
                }
                faces.Clear();
            }
            else
            {
                faces.Clear();
                names.Add("no face");
            }
        }//DectectFace
Exemplo n.º 10
0
        public async Task OnPostMovies(string intent)
        {
            showMoviePosters = "none";
            await ShowPoster(Program.Fetch.Search);

            search      = Program.Fetch.Search;
            this.search = Program.Fetch.Search;

            await Program.Fetch.GrabMovieAsync(intent);

            vidNinja = new JsonNinja(Program.Fetch.Videos);

            filter = vidNinja.GetDetails("\"results\"");

            vidNinja = new JsonNinja(filter[0]);

            List <string> vidNames = vidNinja.GetNames();
            List <string> vidVals  = vidNinja.GetVals();

            jNinja = new JsonNinja(Program.Fetch.Details);
            List <string> detailNames = jNinja.GetNames();
            List <string> detailVals  = jNinja.GetVals();

            //get movie details
            display = "grid";
            title   = jNinja.GetDetails("\"title\"");
            List <string> ratings = jNinja.GetIds("\"vote_average\"");

            rating = ratings[0] + "/10.0";
            List <string> descriptions = jNinja.GetDetails("\"overview\"");

            description = descriptions[0];
            List <string> backDrops = jNinja.GetDetails("\"poster_path\"");

            if (backDrops.Count == 2)
            {
                backDrop = backDrops[1];// backdrop or movieposter
            }
            else
            {
                backDrop = backDrops[0];// backdrop or movieposter
            }

            //get youtube movie keys for poster
            vidClips = vidNinja.GetDetails("\"key\"");

            //get movie cast
            jNinja = new JsonNinja(Program.Fetch.Credits);
            List <string> creditNames = jNinja.GetNames();
            List <string> creditVals  = jNinja.GetVals();

            filter = jNinja.GetDetails("\"cast\"");

            jNinja = new JsonNinja(filter[0]);

            History.SetMovieID(creditVals[0]); //to be used by rental method
            History.SetBackDrop(backDrop);     //same as poster, for cast page backdrop and rental method
            History.SetMovieTitle(title[0]);   //for use with rental method


            List <string> actorName = jNinja.GetDetails("\"name\"");

            castID   = jNinja.GetIds("\"id\"");
            actorImg = jNinja.GetDetails("\"profile_path\"");

            List <string> character = jNinja.GetDetails("\"character\"");

            int voteStat = DisplayVote();

            if (voteStat == 2)
            {
                thumbsDown = 0.4f;
                inBetween  = 0.4f;
            }
            else if (voteStat == 1)
            {
                thumbsUp   = 0.4f;
                thumbsDown = 0.4f;
            }
            else if (voteStat == 0)
            {
                thumbsUp  = 0.4f;
                inBetween = 0.4f;
            }
            else
            {
                //do nothing
            }
            moviePosterShow = "block";
        }