예제 #1
0
            public static string FullInfo(User user, int TVID, out MessageKeyboard keyboard, out List <MediaAttachment> attachments)
            {
                Video trailer = null;
                var   t       = new Task(() => GetTrailer(TVID, ref trailer));

                t.Start();

                var client  = new RestClient("https://kinopoiskapiunofficial.tech/api/v2.1/films/" + TVID.ToString());
                var request = new RestRequest(Method.GET);

                request.AddHeader("X-API-KEY", Bot._kp_key);
                request.AddQueryParameter("append_to_response", "RATING");
                IRestResponse response = client.Execute(request);

                TVObject film;

                try { film = JsonConvert.DeserializeObject <TVObject>(response.Content); }
                catch (Exception) { keyboard = null; attachments = null; return("При загрузке информации о сериале что-то произошло... 😔 Попробуй повторно выполнить запрос"); }
                if (film.data.nameEn != null)
                {
                    user.AddTVSoundtrackAsync(film.data.nameEn, "series");
                }
                else
                {
                    user.AddTVSoundtrackAsync(film.data.nameRu, "сериал");
                }
                var poster = Attachments.PosterObject(user, film.data.posterUrl, film.data.filmId.ToString());

                t.Wait();
                attachments = new List <MediaAttachment> {
                    poster
                };
                if (trailer != null)
                {
                    attachments.Add(trailer);
                }

                if (film.data.nameEn != null && film.data.nameEn != string.Empty)
                {
                    user.AddTVSoundtrackAsync(film.data.nameEn, "ost");
                }
                else
                {
                    user.AddTVSoundtrackAsync(film.data.nameRu, "саундтрек");
                }
                keyboard = Keyboards.TVSearch(film.data.nameRu, film.data.nameEn, film.data.filmId.ToString(), string.Join("*", film.data.genres.Select(g => g.genre)), film.data.premiereRu);
                return(FullInfo(film));
            }
예제 #2
0
        public static MessageKeyboard LevelKeyboard(Mode m)
        {
            switch (m)
            {
            case Mode.Default: return(Keyboards.MainKeyboard);

            case Mode.Film: return(Keyboards.FilmKeyboard);

            case Mode.TV: return(Keyboards.TVKeyboard);

            case Mode.Food: return(Keyboards.FoodKeyboard);

            case Mode.Options: return(Keyboards.Options());

            case Mode.SearchGenre: return(Keyboards.GenresKeyboard);

            default: return(null);
            }
        }
예제 #3
0
            //----not online---------------------------------------------------------
            public static void Search_inMessage(User user, string TVName)
            {
                var client  = new RestClient("https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword");
                var request = new RestRequest(Method.GET);

                request.AddHeader("X-API-KEY", Bot._kp_key);
                request.AddQueryParameter("keyword", TVName);
                IRestResponse response = client.Execute(request);

                TVResults.Results results;
                try { results = JsonConvert.DeserializeObject <TVResults.Results>(response.Content); }
                catch (Exception) { results = null; }
                if (results == null || results.pagesCount == 0)
                {
                    SendMessage(user, "К сожалению, я не смог найти такой сериал... 😔");
                }
                else
                {
                    Keyboards.TVResultsMessage(user, results);
                }
            }
예제 #4
0
            public static MessageTemplate Search(string TVName)
            {
                var client  = new RestClient("https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword");
                var request = new RestRequest(Method.GET);

                request.AddHeader("X-API-KEY", Bot._kp_key);
                request.AddQueryParameter("keyword", TVName);
                IRestResponse response = client.Execute(request);

                TVResults.Results results;
                try { results = JsonConvert.DeserializeObject <TVResults.Results>(response.Content); }
                catch (Exception) { return(null); }
                if (results == null || results.pagesCount == 0)
                {
                    return(null);
                }
                else
                {
                    return(Keyboards.TVResults(results));
                }
            }
예제 #5
0
            public static MessageKeyboard ServiceLinks(string TVName, string date)
            {
                var client  = new RestSharp.RestClient("https://www.googleapis.com/customsearch/v1");
                var request = new RestRequest(Method.GET);

                request.AddQueryParameter("key", _google_key);
                request.AddQueryParameter("cx", _google_sid_series);
                request.AddQueryParameter("q", $"{TVName} {date.Substring(0, 4)} сериал смотреть");
                request.AddQueryParameter("num", "10");
                IRestResponse response = client.Execute(request);

                ServiceClass.service_data.IncGoogleRequests();
                GoogleResponse results;

                try { results = JsonConvert.DeserializeObject <GoogleResponse>(response.Content); }
                catch (Exception) { return(null); }
                var dict = new Dictionary <string, string>();

                foreach (var item in results.items)
                {
                    if (Regex.IsMatch(item.link, @"https://megogo.net/ru/view/.+") && !dict.ContainsKey("MEGOGO"))
                    {
                        dict["MEGOGO"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://www.tvigle.ru/video/.+") && !dict.ContainsKey("TVIGLE"))
                    {
                        dict["TVIGLE"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://wink.rt.ru/media_items/.+") && !dict.ContainsKey("WINK"))
                    {
                        dict["WINK"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://okko.tv/serial/.+") && !dict.ContainsKey("OKKO"))
                    {
                        dict["OKKO"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://hd.kinopoisk.ru/film/.+") && !dict.ContainsKey("КИНОПОИСК"))
                    {
                        dict["КИНОПОИСК"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://www.kinopoisk.ru/series/.+") && !dict.ContainsKey("КИНОПОИСК") && item.title.Contains("смотреть онлайн"))
                    {
                        dict["КИНОПОИСК"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://www.netflix.com/ru/title/.+") && !dict.ContainsKey("NETFLIX"))
                    {
                        dict["NETFLIX"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://www.amediateka.ru/watch/series.+") && !dict.ContainsKey("AMEDIATEKA"))
                    {
                        dict["AMEDIATEKA"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://more.tv/.+") && !dict.ContainsKey("MORE"))
                    {
                        dict["MORE"] = item.link;
                    }
                    else if (Regex.IsMatch(item.link, @"https://www.tvzavr.ru/film/.+") && !dict.ContainsKey("TVZAVR"))
                    {
                        dict["TVZAVR"] = item.link;
                    }
                    if (dict.Count == 2)
                    {
                        break;
                    }
                }
                return(dict.Count == 0 ? null : Keyboards.ServiceLinks(dict));
            }