Reformated some files

pull/3113/head
kay.one 14 years ago
parent 63bd972af9
commit 8b7c624d09

@ -2,33 +2,28 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using Ninject; using Ninject;
using NLog; using NLog;
using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using PetaPoco; using PetaPoco;
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class DiskScanProvider public class DiskScanProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly string[] MediaExtentions = new[] { ".mkv", ".avi", ".wmv", ".mp4" }; private static readonly string[] MediaExtentions = new[] {".mkv", ".avi", ".wmv", ".mp4"};
private readonly IDatabase _database;
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
private readonly EpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly SeriesProvider _seriesProvider;
private readonly MediaFileProvider _mediaFileProvider; private readonly MediaFileProvider _mediaFileProvider;
private readonly IDatabase _database; private readonly SeriesProvider _seriesProvider;
[Inject] [Inject]
public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider, public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider,
SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider, SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider,
IDatabase database) IDatabase database)
{ {
_diskProvider = diskProvider; _diskProvider = diskProvider;
_episodeProvider = episodeProvider; _episodeProvider = episodeProvider;
@ -40,7 +35,6 @@ namespace NzbDrone.Core.Providers
public DiskScanProvider() public DiskScanProvider()
{ {
} }
/// <summary> /// <summary>
@ -92,7 +86,7 @@ namespace NzbDrone.Core.Providers
return null; return null;
} }
var size = _diskProvider.GetSize(filePath); long size = _diskProvider.GetSize(filePath);
//If Size is less than 50MB and contains sample. Check for Size to ensure its not an episode with sample in the title //If Size is less than 50MB and contains sample. Check for Size to ensure its not an episode with sample in the title
if (size < 40000000 && filePath.ToLower().Contains("sample")) if (size < 40000000 && filePath.ToLower().Contains("sample"))
@ -106,7 +100,7 @@ namespace NzbDrone.Core.Providers
if (parseResult == null) if (parseResult == null)
return null; return null;
parseResult.CleanTitle = series.Title;//replaces the nasty path as title to help with logging parseResult.CleanTitle = series.Title; //replaces the nasty path as title to help with logging
//Stores the list of episodes to add to the EpisodeFile //Stores the list of episodes to add to the EpisodeFile
var episodes = new List<Episode>(); var episodes = new List<Episode>();
@ -155,7 +149,7 @@ namespace NzbDrone.Core.Providers
episodeFile.Quality = parseResult.Quality.QualityType; episodeFile.Quality = parseResult.Quality.QualityType;
episodeFile.Proper = parseResult.Quality.Proper; episodeFile.Proper = parseResult.Quality.Proper;
episodeFile.SeasonNumber = parseResult.SeasonNumber; episodeFile.SeasonNumber = parseResult.SeasonNumber;
var fileId = Convert.ToInt32(_database.Insert(episodeFile)); int fileId = Convert.ToInt32(_database.Insert(episodeFile));
//This is for logging + updating the episodes that are linked to this EpisodeFile //This is for logging + updating the episodes that are linked to this EpisodeFile
string episodeList = String.Empty; string episodeList = String.Empty;
@ -169,21 +163,18 @@ namespace NzbDrone.Core.Providers
episodeList); episodeList);
return episodeFile; return episodeFile;
} }
public virtual bool RenameEpisodeFile(EpisodeFile episodeFile) public virtual bool RenameEpisodeFile(EpisodeFile episodeFile)
{ {
if (episodeFile == null) if (episodeFile == null)
throw new ArgumentNullException("episodeFile"); throw new ArgumentNullException("episodeFile");
var series = _seriesProvider.GetSeries(episodeFile.SeriesId); var series = _seriesProvider.GetSeries(episodeFile.SeriesId);
var ext = _diskProvider.GetExtension(episodeFile.Path); string ext = _diskProvider.GetExtension(episodeFile.Path);
var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId); var episodes = _episodeProvider.GetEpisodesByFileId(episodeFile.EpisodeFileId);
var newFileName = _mediaFileProvider.GetNewFilename(episodes, series.Title, episodeFile.Quality); string newFileName = _mediaFileProvider.GetNewFilename(episodes, series.Title, episodeFile.Quality);
var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, ext); var newFile = _mediaFileProvider.CalculateFilePath(series, episodes.First().SeasonNumber, newFileName, ext);
@ -199,9 +190,8 @@ namespace NzbDrone.Core.Providers
} }
/// <summary> /// <summary>
/// Removes files that no longer exist from the database /// Removes files that no longer exist on disk from the database
/// </summary> /// </summary>
/// <param name = "files">list of files to verify</param> /// <param name = "files">list of files to verify</param>
public virtual void CleanUp(List<EpisodeFile> files) public virtual void CleanUp(List<EpisodeFile> files)
@ -238,6 +228,5 @@ namespace NzbDrone.Core.Providers
Logger.Debug("{0} media files were found in {1}", mediaFileList.Count, path); Logger.Debug("{0} media files were found in {1}", mediaFileList.Count, path);
return mediaFileList; return mediaFileList;
} }
} }
} }

@ -5,7 +5,6 @@ using System.Linq;
using Ninject; using Ninject;
using NLog; using NLog;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
@ -16,9 +15,9 @@ namespace NzbDrone.Core.Providers
public class MediaFileProvider public class MediaFileProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly EpisodeProvider _episodeProvider;
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly IDatabase _database; private readonly IDatabase _database;
private readonly EpisodeProvider _episodeProvider;
[Inject] [Inject]
public MediaFileProvider(EpisodeProvider episodeProvider, ConfigProvider configProvider, IDatabase database) public MediaFileProvider(EpisodeProvider episodeProvider, ConfigProvider configProvider, IDatabase database)
@ -28,15 +27,9 @@ namespace NzbDrone.Core.Providers
_database = database; _database = database;
} }
public MediaFileProvider() { } public MediaFileProvider()
{
}
public virtual void Update(EpisodeFile episodeFile) public virtual void Update(EpisodeFile episodeFile)
{ {
@ -70,7 +63,7 @@ namespace NzbDrone.Core.Providers
public virtual FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention) public virtual FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention)
{ {
var path = series.Path; string path = series.Path;
if (series.SeasonFolder) if (series.SeasonFolder)
{ {
path = Path.Combine(path, "Season " + seasonNumber); path = Path.Combine(path, "Season " + seasonNumber);
@ -81,15 +74,14 @@ namespace NzbDrone.Core.Providers
return new FileInfo(path); return new FileInfo(path);
} }
public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality) public virtual string GetNewFilename(IList<Episode> episodes, string seriesTitle, QualityTypes quality)
{ {
var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SeparatorStyle); var separatorStyle = EpisodeSortingHelper.GetSeparatorStyle(_configProvider.SeparatorStyle);
var numberStyle = EpisodeSortingHelper.GetNumberStyle(_configProvider.NumberStyle); var numberStyle = EpisodeSortingHelper.GetNumberStyle(_configProvider.NumberStyle);
var episodeNames = episodes[0].Title; string episodeNames = episodes[0].Title;
var result = String.Empty; string result = String.Empty;
if (_configProvider.SeriesName) if (_configProvider.SeriesName)
{ {
@ -139,11 +131,5 @@ namespace NzbDrone.Core.Providers
Logger.Debug("New File Name is: {0}", result.Trim()); Logger.Debug("New File Name is: {0}", result.Trim());
return result.Trim(); return result.Trim();
} }
} }
} }
Loading…
Cancel
Save