예제 #1
0
        public void GetConfigFailTest()
        {
            TMDbConfig config = _config.Client.Config;

            // Should always throw exception
            Assert.Fail();
        }
예제 #2
0
        private ApiHelper()
        {
            this.Client = new TMDbClient(ApiHelper.API);
            TMDbConfig Config = new TMDbConfig();

            this.Client.GetConfig();
        }
예제 #3
0
        private static async Task FetchConfig(TMDbClient client)
        {
            FileInfo configJson = new FileInfo("config.json");

            Console.WriteLine("Config file: " + configJson.FullName + ", Exists: " + configJson.Exists);

            if (configJson.Exists && configJson.LastWriteTimeUtc >= DateTime.UtcNow.AddHours(-1))
            {
                Console.WriteLine("Using stored config");
                string json = File.ReadAllText(configJson.FullName, Encoding.UTF8);

                client.SetConfig(TMDbJsonSerializer.Instance.DeserializeFromString <TMDbConfig>(json));
            }
            else
            {
                Console.WriteLine("Getting new config");
                TMDbConfig config = await client.GetConfigAsync();

                Console.WriteLine("Storing config");
                string json = TMDbJsonSerializer.Instance.SerializeToString(config);
                File.WriteAllText(configJson.FullName, json, Encoding.UTF8);
            }

            Spacer();
        }
예제 #4
0
        private static void ValidatePreferences(TMDbConfig config)
        {
            var imageConfig = config.Images;

            var pluginConfig = Plugin.Instance.Configuration;

            if (!imageConfig.PosterSizes.Contains(pluginConfig.PosterSize))
            {
                pluginConfig.PosterSize = imageConfig.PosterSizes[^ 1];
예제 #5
0
        public static void Update(this ShowSql showBdd, TMDbConfig config, TvShow item)
        {
            showBdd.PosterUrl = config.Images.SecureBaseUrl + "w500" + item.PosterPath;

            if (item.ExternalIds != null)
            {
                showBdd.Providers[ProviderSql.Imdb] = item.ExternalIds.ImdbId;
            }
        }
예제 #6
0
        public static void Update(this EpisodeSql episodeBdd, TMDbConfig config, TvEpisode item)
        {
            episodeBdd.PosterUrl = config.Images.SecureBaseUrl + "w300" + item.StillPath;
            episodeBdd.Name      = item.Name;
            episodeBdd.AirDate   = item.AirDate;

            if (item.ExternalIds != null)
            {
                episodeBdd.Providers[ProviderSql.Imdb] = item.ExternalIds.ImdbId;
            }
        }
예제 #7
0
        public TMDbManager()
        {
            TMDbClient   = new TMDbClient(ConfigurationManager.AppSettings["TheMovieDB"]);
            MongoManager = new MongoDBManager();

            TMDbClient.GetConfig();
            TMDbConfig config = TMDbClient.Config;

            ImageBase = config.Images.BaseUrl + config.Images.PosterSizes.Where(o => o == "w342").First();
            Client    = new TMDbClient(ConfigurationManager.AppSettings["TheMovieDB"]);
        }
예제 #8
0
        public void GetConfig()
        {
            TMDbConfig config = _client.Create("configuration").ExecuteGet <TMDbConfig>().Result;

            if (config == null)
            {
                throw new Exception("Unable to retrieve configuration");
            }

            // Store config
            Config    = config;
            HasConfig = true;
        }
        public static TMDbClient GetConfifuredClient()
        {
            var client = Client;

            if (client.HasConfig == false)
            {
                var config = new TMDbConfig();
                config.Images         = new ConfigImageTypes();
                config.Images.BaseUrl = BaseImagesUrl;
                client.SetConfig(config);
            }
            return(client);
        }
예제 #10
0
        public void SetConfigTest()
        {
            TMDbConfig config = new TMDbConfig();

            config.ChangeKeys = new List <string>();
            config.ChangeKeys.Add("a");
            config.Images         = new ConfigImageTypes();
            config.Images.BaseUrl = " ..";

            Assert.IsFalse(_config.Client.HasConfig);
            _config.Client.SetConfig(config);
            Assert.IsTrue(_config.Client.HasConfig);

            Assert.AreSame(config, _config.Client.Config);
        }
예제 #11
0
        public async Task <TMDbConfig> GetConfigAsync()
        {
            TMDbConfig config = await _client.Create("configuration").ExecuteGet <TMDbConfig>(CancellationToken.None);

            if (config == null)
            {
                throw new Exception("Unable to retrieve configuration");
            }

            // Store config
            Config    = config;
            HasConfig = true;

            return(config);
        }
예제 #12
0
 public void SetConfig(TMDbConfig config)
 {
     // Store config
     Config    = config;
     HasConfig = true;
 }
 public MovieQuery(IOptions <TMDbConfig> config)
 {
     client      = new HttpClient();
     this.config = config.Value;
 }
예제 #14
0
 public static async Task Init()
 {
     client       = new TMDbClient(MovieApp.Constants.Constants.APIKey);
     clientConfig = await client.GetConfigAsync();
 }
예제 #15
0
        public void GetConfigFailTest()
        {
            TMDbConfig config = _config.Client.Config;

            Assert.Fail();  // Should never reach here
        }