Example #1
0
        static TVDBInfo GetTVDBInfo()
        {
            string   filePath = GetTVDBInfoFilePath();
            TVDBInfo tvdbInfo = TVDBInfo.ReadFromFile(filePath);

            return(tvdbInfo);
        }
Example #2
0
        public void ReadFromFile_InvalidFile_ThrowsException()
        {
            string filePath = @"c:\tempobox\tvdbinfo.json";

            // Assert
            Assert.Throws <FileNotFoundException>(() => TVDBInfo.ReadFromFile(filePath));
        }
Example #3
0
        static void ReadTVDBInfo()
        {
            string   filePath = GetTVDBInfoFilePath();
            TVDBInfo tvdbInfo = TVDBInfo.ReadFromFile(filePath);

            tvdbInfo.TokenRetrievedDate = DateTime.Now.AddDays(-1);
            Console.WriteLine($"apiKey from TVDBInfo: {tvdbInfo.ApiKey}. DateTime: {tvdbInfo.TokenRetrievedDate}");
            tvdbInfo.SaveToFile(filePath);
        }
Example #4
0
        public void ReadFromFile_ValidFile_Passes()
        {
            string filePath       = @"c:\temp\tvdbinfo.json";
            string expectedApiKey = "URV9WXPTFX8R9J6A";
            // Act
            TVDBInfo tvdbInfo = TVDBInfo.ReadFromFile(filePath);

            // Assert
            Assert.Equal(expectedApiKey, tvdbInfo.ApiKey);
        }
Example #5
0
        public async Task DisplayMenu()
        {
            TVDBInfo tvdbInfo  = Facade._tvdbInfo;
            int      userInput = 0;

            while (userInput != 9)
            {
                userInput = DisplayMainMenu(tvdbInfo);
                await ProcessMainMenuUserInput(userInput);
            }
        }
Example #6
0
        private void PrintTokenExpiration(TVDBInfo tvdbInfo)
        {
            DateTime expiration = tvdbInfo.GetExpiration();
            string   expireWord = "expires";

            if (tvdbInfo.TokenIsExpired)
            {
                expireWord = "expired";
            }
            MenuHelpers.WriteColorVT24Bit($"Token {expireWord} on ", "#dbbbf5");
            MenuHelpers.WriteColorVT24Bit($"{expiration.ToString("MM/dd/yyyy hh:mm tt")}", "#ce5374");
            Console.WriteLine();
        }
Example #7
0
        public void ToAuthenticator_Valid_ReturnsAuthenticator()
        {
            string filePath         = @"c:\temp\tvdbinfo.json";
            string expectedApiKey   = "URV9WXPTFX8R9J6A";
            string expectedUserKey  = "6U0AVI208RGC9EWE";
            string expectedUsername = "******";
            // Act
            TVDBInfo          tvdbInfo      = TVDBInfo.ReadFromFile(filePath);
            TVDBAuthenticator authenticator = tvdbInfo.ToAuthenticator();

            Assert.Equal(expectedApiKey, authenticator.ApiKey);
            Assert.Equal(expectedUserKey, authenticator.UserKey);
            Assert.Equal(expectedUsername, authenticator.Username);
        }
Example #8
0
 public RenamerFacade(TVDBRetrieverService retrieverService,
                      TVShowService showService,
                      EpisodeService episodeService,
                      LocalMediaService localService,
                      EpisodeContext context,
                      IRenamePrompter prompter,
                      string tvdbPath)
 {
     _retrieverService = retrieverService;
     _showService      = showService;
     _episodeService   = episodeService;
     _localservice     = localService;
     _context          = context;
     _tvdbInfoFilePath = tvdbPath;
     _prompter         = prompter;
     _tvdbInfo         = TVDBInfo.ReadFromFile(_tvdbInfoFilePath);
 }
Example #9
0
        private int DisplayMainMenu(TVDBInfo tvdbInfo)
        {
            bool tokenIsValid = !tvdbInfo.TokenIsInvalid;

            PrintTokenExpiration(tvdbInfo);
            MenuHelpers.WriteLineColor("\u001b[4mEpisode Renamer!\u001b[0m", ConsoleColor.Yellow, ConsoleColor.DarkMagenta);
            // MenuHelpers.WriteLineGradientWhiteToBlue("Episode Renamer!");
            Console.WriteLine();

            MenuHelpers.PrintMenuNumber(1);
            MenuHelpers.WriteColorVT24Bit("Get or refresh token  ", "#e56399");
            DisplayTokenStatus(tokenIsValid);

            MenuHelpers.PrintMenuNumber(2);
            MenuHelpers.WriteLineColorVT24Bit("Populate Shows table from User Favorites", "#e5d4ce");

            MenuHelpers.PrintMenuNumber(3);
            MenuHelpers.WriteLineColorVT24Bit("Populate Episodes for existing Active shows", "#7fd1b9");

            MenuHelpers.PrintMenuNumber(4);
            MenuHelpers.WriteLineColorVT24Bit("TV Show menu", "#FF6C2C");

            MenuHelpers.PrintMenuNumber(5);
            MenuHelpers.WriteLineColor("RENAME FILES!!", ConsoleColor.Yellow);

            MenuHelpers.PrintMenuNumber(6);
            MenuHelpers.WriteLineColor("Search for shows on TVDB", ConsoleColor.White);


            MenuHelpers.PrintMenuNumber(9);
            MenuHelpers.WriteLineColor("Exit, if you dare", ConsoleColor.DarkCyan);
            var result = Console.ReadLine();

            if (result.IsNumeric())
            {
                return(result.ToInt());
            }
            else
            {
                return(0);
            }
        }
Example #10
0
 static void SetNewTokenAndSaveToFile(ref TVDBInfo tvdbInfo, string token, string filePath)
 {
     tvdbInfo.Token = token;
     tvdbInfo.TokenRetrievedDate = DateTime.Now;
     tvdbInfo.SaveToFile(filePath);
 }