public async Task <ActionResult <Download> > CreateDownloaderItem(Downloader downloader) { await _downloadersService.ValidateDownloader(downloader); _context.Downloaders.Add(downloader); await _context.SaveChangesAsync(); return(CreatedAtAction( nameof(GetDownloadById), new { id = downloader.DownloaderId }, downloader)); }
public async Task <ActionResult <Download> > AddToken([FromBody] Token token) { var savedToken = _context.Tokens.Add(token); await _context.SaveChangesAsync(); return(Ok(savedToken)); }
public async Task ParseFile(int fileId, bool force) { var file = await _downloadsService.GetFile(fileId); if (file == null || (file.Parsed && !force)) { return; } else if (file.Download.Type == DownloadType.Show) { Console.WriteLine(file.Name); var parsed = _parserService.ParseTitle(file.Name); if (parsed != null && parsed.SeriesTitle != null) { _logger.LogInformation($"Parsed Show {parsed.SeriesTitle} {parsed.SeasonNumber}x{parsed.EpisodeNumbers.FirstOrDefault()}"); var id = await _showService.tvdbIdByTitle(parsed.SeriesTitle); var show = await _showService.getShowByTvdbId(id); file.Show = show; file.Parsed = true; file.Episode = show.Episodes.FirstOrDefault(e => e.Season == parsed.SeasonNumber && e.Number == parsed.EpisodeNumbers.FirstOrDefault()); await _dbContext.SaveChangesAsync(); } } Console.WriteLine(file.Download.Type); }
public async ValueTask <Download> AddDownload(Download download) { var downloadSaved = await _dbContext.Downloads.AddAsync(download); await _dbContext.SaveChangesAsync(); return(downloadSaved.Entity); }