Exemplo n.º 1
0
 /// <summary>
 /// Downloads show data from TVDB.
 /// </summary>
 /// <param name="show">the name of the show to get data for.</param>
 /// <returns>A list of shows matching the specified <paramref name="show"/>.</returns>
 private async Task<List<Show>> DownloadShowsByTitle(string show)
 {
    try
    {
       ITVDBService tvdbManager = _serviceFactory.GetServiceManager<ITVDBService>();
       Task<List<Show>> searchTask = tvdbManager.GetShowsByTitle(show);
       SetStatus(String.Format("Searching for shows with the name '{0}'", show));
       List<Show> results = await searchTask;
       return results;
    }
    catch
    {
       throw;
    }
 }
Exemplo n.º 2
0
      internal async Task Rename(string file)
      {
         // TODO: set status text to parsing
         SetStatus("Parsing input file.");
         _view.VisualizeProgress(true);

         // Loop through each parser and check if it can parse the input file.
         foreach (ITVShowParser parser in _serviceFactory.GetServiceManagers<ITVShowParser>())
         {
            if (!parser.CanParse(file))
            {
               // Maybe the next parser will be able to parse the file.
               continue;
            }
            else
            {
               SetStatus("Successful parser found.");
               try
               {
                  TVShowFile tvShowFile = parser.Parse(file);
                  ITVDBService tvdbManager = _serviceFactory.GetServiceManager<ITVDBService>();

                  SetStatus(String.Format("Searching for a show with the name '{0}'", tvShowFile.ShowName));
                  Task<List<Show>> showsTaskResult = tvdbManager.GetShowsByTitle(tvShowFile.ShowName);
                  // TODO: downloading show data..
                  // TODO: update the progress bar to look like work is being done...
                  List<Show> results = await showsTaskResult;
                  // TODO: make sure the progress bar finishes

                  InterpretShowResults(results, tvShowFile);
               }
               catch (Exception ex)
               {
                  // TODO: Set status text to error
                  SetStatus(String.Format("An error occured renaming the file. {0}", ex.Message));
                  break;
               }

               // TODO: I believe here would be the successful case so display some success message.
               break;
            }
         }
         _view.VisualizeProgress(false);
      }