add image download setting

This commit is contained in:
Luke Pulverenti
2016-02-25 23:09:42 -05:00
parent 1661c21152
commit 2c3113ced7
4 changed files with 50 additions and 6 deletions

View File

@@ -729,6 +729,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
var recordingFileName = _fileSystem.GetValidFilename(RecordingHelper.GetRecordingName(timer, info)).Trim() + ".ts";
recordPath = Path.Combine(recordPath, recordingFileName);
recordPath = EnsureFileUnique(recordPath);
_fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
var recordingId = info.Id.GetMD5().ToString("N");
@@ -862,6 +863,24 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
}
private string EnsureFileUnique(string path)
{
var originalPath = path;
var index = 1;
while (_fileSystem.FileExists(path))
{
var parent = Path.GetDirectoryName(originalPath);
var name = Path.GetFileNameWithoutExtension(originalPath);
name += "-" + index.ToString(CultureInfo.InvariantCulture);
path = Path.ChangeExtension(Path.Combine(parent, name), Path.GetExtension(originalPath));
index++;
}
return path;
}
private async Task<IRecorder> GetRecorder()
{
if (GetConfiguration().EnableRecordingEncoding)