Esempio n. 1
0
        public static async void Imdb(Movie movie)
        {
            ApiLib api  = new ApiLib(API_KEY);
            var    data = await api.TitleAsync($"{movie.ImdbID}");

            var result = data.Similars;
        }
Esempio n. 2
0
        public Step2_SearchUC()
        {
            InitializeComponent();

            string apiKey = Properties.Settings.Default.ApiKey;

            _apiLib = new ApiLib(apiKey, Program.GetWebProxy());
        }
Esempio n. 3
0
 public Form1()
 {
     InitializeComponent();
     TMDbClient = new TMDbClient("c6b31d1cdad6a56a23f0c913e2482a31", true);
     ApiLib     = new ApiLib("k_f1ykeqs7");
     dBVM       = new DBVM();
     shouldSave = false;
 }
Esempio n. 4
0
        public MoreInfoForm(string id)
        {
            InitializeComponent();
            _id = id;

            string apiKey = Properties.Settings.Default.ApiKey;

            _apiLib = new ApiLib(apiKey, Program.GetWebProxy());
        }
Esempio n. 5
0
        public Step4_DownloadUC(List <GridData> gridDataItems)
        {
            InitializeComponent();

            ddlWhenDone.SelectedIndex = 0;
            _gridDataItems            = gridDataItems;

            string apiKey = Properties.Settings.Default.ApiKey;

            _apiLib = new ApiLib(apiKey, Program.GetWebProxy());

            _clientOptions = Properties.Settings.Default.ClientOptions;
        }
Esempio n. 6
0
        public SearchForm(SearchData searchData)
        {
            InitializeComponent();

            txtExpression.Text = searchData.Expression;

            rbMovie.Checked    = Properties.Settings.Default.OperationType == OperationType.Movies;
            rbSeriesTV.Checked = Properties.Settings.Default.OperationType == OperationType.TVSeries;
            _searchData        = searchData;

            string apiKey = Properties.Settings.Default.ApiKey;

            _apiLib = new ApiLib(apiKey, Program.GetWebProxy());
        }
Esempio n. 7
0
    // Start is called before the first frame update
    async void StartAsync()
    {
        var apiLib = new ApiLib("k_GjnD0m0X");
        var data   = await apiLib.TitleAsync(imdbID);

        Debug.Log(data.ErrorMessage);
        title       = data.FullTitle;
        discribtion = data.Plot;
        tagline     = data.Tagline;
        genre       = data.Genres;
        rating      = float.Parse(data.IMDbRating);
        url         = data.Image;
        //trailer = data.Trailer.Link;
        StartCoroutine("SetThumbnail");
    }
Esempio n. 8
0
        public static string GetApiLibName(ApiLib lib)
        {
            switch (lib)
            {
            case ApiLib.System:
                return("system");

            case ApiLib.AvContent:
                return("avContent");

            case ApiLib.Audio:
                return("audio");

            default:
                throw new ArgumentOutOfRangeException(nameof(lib));
            }
        }
Esempio n. 9
0
        public Step1_InitUC()
        {
            InitializeComponent();

            MovieType         = Properties.Settings.Default.OperationType;
            MovieFile         = Properties.Settings.Default.MovieFile;
            MoviesDirectory   = Properties.Settings.Default.MoviesDirectory;
            SeriesTvDirectory = Properties.Settings.Default.SeriesTvDirectory;
            SeriesTvID        = Properties.Settings.Default.SeriesTvID;

            txtApiKey.Text = Properties.Settings.Default.ApiKey;
            txtApiKey.UseSystemPasswordChar = true;

            string apiKey = Properties.Settings.Default.ApiKey;

            _apiLib = new ApiLib(apiKey, Program.GetWebProxy());
        }
Esempio n. 10
0
        private async Task <TResult> makeRequestAsync <TResult>(ApiLib lib, ApiVersion version, string method, object @params = null)
        {
            if (this.Device is null)
            {
                throw new ArgumentNullException(nameof(this.Device));
            }

            if (string.IsNullOrEmpty(method))
            {
                throw new ArgumentNullException(nameof(method));
            }

            RequestObject requestObject = new RequestObject(method, version, @params);

            string libName    = Utilities.GetApiLibName(lib);
            string requestUrl = $"http://{this.Device.Hostname}:{this.Device.Port}/sony/{libName}";

            HttpContent httpContent = new StringContent(requestObject.Serialized, Encoding.UTF8, "application/json");

            using (HttpClient httpClient = new HttpClient())
            {
                HttpResponseMessage response = await httpClient.PostAsync(requestUrl, httpContent);

                if (response.IsSuccessStatusCode)
                {
                    ResponseObject <TResult> responseObject = JsonSerializer.Deserialize <ResponseObject <TResult> >(await response.Content.ReadAsStringAsync());
                    if (responseObject.Error != null)
                    {
                        // TODO - handle
                        throw new Exception("Unexpected error");
                    }
                    else
                    {
                        return(responseObject.Result);
                    }
                }
                else
                {
                    // TODO - handle this better
                    throw new Exceptions.HttpException();
                }
            }
        }
Esempio n. 11
0
        static void Main()
        {
            // 14-29 TAGNA
            int start = 14;
            int end   = 29;

            // ----------------------------------------
            // --- Rensa Db om något måste göras om ---
            // ----------------------------------------
            //
            // ct.RemoveRange(ct.MovieLinks); ct.SaveChanges();

            // -----------------------------
            // --- ImdbId från CSV filen ---
            // -----------------------------
            //        ***Hur många filmer vi tar***
            //                  \   /
            // ImdbIdFromRawCSVFile(500);

            // ---------------------------------
            // --- PosterLink to MovieLinkDb ---
            // ---------------------------------

            #region POSTER LINKS

            // hur många vi uppdaterar åt gången -> 0(i) upp till 10

            string posterLink = "";
            for (int i = start; i < end; i++)
            {
                MovieLink entity = ct.MovieLinks.Skip(i).Take(1).First();

                // ImdbApi plockar Poster info
                var apiLib = new ApiLib(APIKeyRobin);
                var data   = apiLib.PostersAsync($"tt{entity.ImdbID}");

                // Sparar poster link, sorterar efter EN
                try
                {
                    posterLink = data.Result.Posters.Where(p => p.Language == "en").First().Link;
                }
                catch
                {
                    Console.WriteLine(Helper.DataBaseError.NoPostersFound);
                }
                // Testar så länken inte är trasig, tar nästa om trasig
                bool isBroken = true;
                int  count    = 1;
                while (isBroken)
                {
                    try
                    {
                        var testLink = new Uri(posterLink);
                        isBroken = false;
                    }
                    catch
                    {
                        Console.WriteLine(Helper.DataBaseError.BrokenTrailerLink);

                        posterLink = data.Result.Posters.Where(p => p.Language == "en").Skip(count).First().Link;
                        count++;
                    }
                }

                // Uppdaterar databas
                entity.PosterLink = posterLink;
                ct.MovieLinks.Update(entity);
                ct.SaveChanges();
            }

            #endregion


            // ---------------------------------
            // --- Synopsis to MovieLinkDb ---
            // ---------------------------------

            #region SYNOPSIS

            string synopsis = "";
            for (int i = start; i < end; i++)
            {
                MovieLink entity = ct.MovieLinks.Skip(i).Take(1).First();

                // ImdbApi plockar synopsis
                var apiLib = new ApiLib(APIKeyRobin);
                var data   = apiLib.TitleAsync($"tt{entity.ImdbID}");

                // Sparar synopsis
                synopsis = data.Result.Plot;

                // Uppdaterar databas
                entity.Synopsis = synopsis;
                ct.MovieLinks.Update(entity);
                ct.SaveChanges();
            }
            #endregion


            // ---------------------------------
            // --- YoutubeId to MovieLinkDb ---
            // ---------------------------------
            //
            #region YOUTUBE

            string youtubeId = "";
            for (int i = start; i < end; i++)
            {
                MovieLink entity = ct.MovieLinks.Skip(i).Take(1).First();

                // ImdbApi plockar youtube info
                var apiLib = new ApiLib(APIKeyRobin);
                var data   = apiLib.YouTubeTrailerAsync($"tt{entity.ImdbID}");

                // Sparar videoId
                youtubeId = data.Result.VideoId;

                // Uppdaterar databas
                entity.YoutubeId = youtubeId;
                ct.MovieLinks.Update(entity);
                ct.SaveChanges();
            }
            #endregion
        }
Esempio n. 12
0
 protected BaseImdbApiAccess(IAutoMapper mapper, IConfig config)
 {
     CultureInfo.CurrentCulture = new CultureInfo("en-US");
     this.mapper = mapper;
     apiLib      = new ApiLib(config.GetIMDbApiKey());
 }
Esempio n. 13
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
            Console.WriteLine("Movie to Search: ");
            string movieToSearch = Console.ReadLine();

            movieToSearch.Replace(" ", "%20");
            string apiKey = System.IO.File.ReadAllText("TmdbApiKey.txt");

            //https://api.themoviedb.org/3/movie/550?api_key=a852a3b3771672da86800503084b853b
            //https://api.themoviedb.org/3/search/movie?api_key=a852a3b3771672da86800503084b853b&language=en-US&query=inception&page=1&include_adult=false

            // Call asynchronous network methods in a try/catch block to handle exceptions.
            try
            {
                string uri = String.Format("https://api.themoviedb.org/3/search/movie?api_key={0}&language=en-US&query={1}&page=1&include_adult=false", apiKey, movieToSearch);
                HttpResponseMessage response = await client.GetAsync(uri);

                response.EnsureSuccessStatusCode();
                string responseBody = await response.Content.ReadAsStringAsync();

                // Above three lines can be replaced with new helper method below
                // string responseBody = await client.GetStringAsync(uri);
                SearchResults testSearchResults = SearchResults.FromJson(responseBody);

                for (int i = 0; i < testSearchResults.Results.Length; i++)
                {
                    Console.WriteLine(String.Format("Movie: {0}, Id: {1}", testSearchResults.Results[i].OriginalTitle, testSearchResults.Results[i].Id));
                }

                while (testSearchResults.Page < testSearchResults.TotalPages)
                {
                    uri      = String.Format("https://api.themoviedb.org/3/search/movie?api_key={0}&language=en-US&query={1}&page={2}&include_adult=false", apiKey, movieToSearch, testSearchResults.Page + 1);
                    response = await client.GetAsync(uri);

                    response.EnsureSuccessStatusCode();
                    responseBody = await response.Content.ReadAsStringAsync();

                    // Above three lines can be replaced with new helper method below
                    // string responseBody = await client.GetStringAsync(uri);
                    testSearchResults = SearchResults.FromJson(responseBody);
                    for (int i = 0; i < testSearchResults.Results.Length; i++)
                    {
                        Console.WriteLine(String.Format("Movie: {0}, Id: {1}", testSearchResults.Results[i].OriginalTitle, testSearchResults.Results[i].Id));
                    }
                }
                Console.WriteLine("Movie Id to Search: ");
                string movieId = Console.ReadLine();

                // Display relevant information about results somehow
                //User clicks movie, get the Id from the movie the user clicked on
                uri      = String.Format("https://api.themoviedb.org/3/movie/{0}?api_key={1}&language=en-US", movieId.ToString(), apiKey);
                response = await client.GetAsync(uri);

                response.EnsureSuccessStatusCode();
                responseBody = await response.Content.ReadAsStringAsync();

                Movie testMovie = Movie.FromJson(responseBody);
                Console.WriteLine("IMDB Title: " + testMovie.ImdbId);

                var apiLib   = new ApiLib("k_vxcfqztc");
                var testIMDB = await apiLib.TitleAsync(testMovie.ImdbId, Language.en, "FullActor,FullCast,Posters,Images,Trailer,Ratings,Wikipedia");

                Console.WriteLine("Full Title: " + testIMDB.FullTitle);
                Console.WriteLine("Director: " + testIMDB.Directors);
                Console.WriteLine("IMDB Rating: " + testIMDB.IMDbRating);
            }
            catch (HttpRequestException e)
            {
                Console.WriteLine("\nException Caught!");
                Console.WriteLine("Message :{0} ", e.Message);
            }
        }
 public ApiLibNotificationManager(DeviceDescriptor device, ApiLib lib, IEnumerable <NotificationSubscription> subscriptions)
 {
     this.Device        = device;
     this.Lib           = lib;
     this.subscriptions = new HashSet <NotificationSubscription>(subscriptions);
 }
            private IEnumerable <ApiLibNotificationManager.NotificationSubscription> getSubscriptionsForLib(ApiLib lib)
            {
                Dictionary <ApiVersion, Dictionary <string, EventInfo> > libDelegates = this.handlers[lib];

                if (libDelegates != null)
                {
                    return(libDelegates.SelectMany((versionElement) => versionElement.Value.Keys.Select((methodElement) => new ApiLibNotificationManager.NotificationSubscription()
                    {
                        Name = methodElement, Version = versionElement.Key
                    })));
                }
                else
                {
                    return(new ApiLibNotificationManager.NotificationSubscription[0]);
                }
            }