mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 10:32:35 +01:00
Fixed: Pneumatic now has a watch folder (for importing strm files)
This commit is contained in:
parent
e67136ae64
commit
57448fd29a
@ -49,15 +49,14 @@ public override string Download(RemoteEpisode remoteEpisode)
|
||||
title = FileNameBuilder.CleanFileName(title);
|
||||
|
||||
//Save to the Pneumatic directory (The user will need to ensure its accessible by XBMC)
|
||||
var filename = Path.Combine(Settings.NzbFolder, title + ".nzb");
|
||||
var nzbFile = Path.Combine(Settings.NzbFolder, title + ".nzb");
|
||||
|
||||
_logger.Debug("Downloading NZB from: {0} to: {1}", url, filename);
|
||||
_httpProvider.DownloadFile(url, filename);
|
||||
_logger.Debug("Downloading NZB from: {0} to: {1}", url, nzbFile);
|
||||
_httpProvider.DownloadFile(url, nzbFile);
|
||||
|
||||
_logger.Debug("NZB Download succeeded, saved to: {0}", filename);
|
||||
_logger.Debug("NZB Download succeeded, saved to: {0}", nzbFile);
|
||||
|
||||
var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", filename, title);
|
||||
_diskProvider.WriteAllText(Path.Combine(_configService.DownloadedEpisodesFolder, title + ".strm"), contents);
|
||||
WriteStrmFile(title, nzbFile);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -72,7 +71,40 @@ public bool IsConfigured
|
||||
|
||||
public override IEnumerable<DownloadClientItem> GetItems()
|
||||
{
|
||||
return new DownloadClientItem[0];
|
||||
foreach (var videoFile in _diskProvider.GetFiles(Settings.StrmFolder, SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
if (Path.GetExtension(videoFile) != ".strm")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var title = FileNameBuilder.CleanFileName(Path.GetFileName(videoFile));
|
||||
|
||||
var historyItem = new DownloadClientItem
|
||||
{
|
||||
DownloadClient = Definition.Name,
|
||||
DownloadClientId = Definition.Name + "_" + Path.GetFileName(videoFile) + "_" + _diskProvider.FileGetLastWriteUtc(videoFile).Ticks,
|
||||
Title = title,
|
||||
|
||||
TotalSize = _diskProvider.GetFileSize(videoFile),
|
||||
|
||||
OutputPath = videoFile
|
||||
};
|
||||
|
||||
if (_diskProvider.IsFileLocked(videoFile))
|
||||
{
|
||||
historyItem.Status = DownloadItemStatus.Downloading;
|
||||
}
|
||||
else
|
||||
{
|
||||
historyItem.Status = DownloadItemStatus.Completed;
|
||||
}
|
||||
|
||||
historyItem.RemoteEpisode = GetRemoteEpisode(historyItem.Title);
|
||||
if (historyItem.RemoteEpisode == null) continue;
|
||||
|
||||
yield return historyItem;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RemoveItem(String id)
|
||||
@ -98,6 +130,7 @@ public override DownloadClientStatus GetStatus()
|
||||
protected override void Test(List<ValidationFailure> failures)
|
||||
{
|
||||
failures.AddIfNotNull(TestWrite(Settings.NzbFolder, "NzbFolder"));
|
||||
failures.AddIfNotNull(TestWrite(Settings.StrmFolder, "StrmFolder"));
|
||||
}
|
||||
|
||||
private ValidationFailure TestWrite(String folder, String propertyName)
|
||||
@ -121,5 +154,28 @@ private ValidationFailure TestWrite(String folder, String propertyName)
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void WriteStrmFile(String title, String nzbFile)
|
||||
{
|
||||
String folder;
|
||||
|
||||
if (Settings.StrmFolder.IsNullOrWhiteSpace())
|
||||
{
|
||||
folder = _configService.DownloadedEpisodesFolder;
|
||||
|
||||
if (folder.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new DownloadClientException("Strm Folder needs to be set for Pneumatic Downloader");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
folder = Settings.StrmFolder;
|
||||
}
|
||||
|
||||
var contents = String.Format("plugin://plugin.program.pneumatic/?mode=strm&type=add_file&nzb={0}&nzbname={1}", nzbFile, title);
|
||||
_diskProvider.WriteAllText(Path.Combine(folder, title + ".strm"), contents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using FluentValidation;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common.Disk;
|
||||
using NzbDrone.Core.Annotations;
|
||||
using NzbDrone.Core.ThingiProvider;
|
||||
using NzbDrone.Core.Validation.Paths;
|
||||
@ -12,8 +11,8 @@ public class PneumaticSettingsValidator : AbstractValidator<PneumaticSettings>
|
||||
{
|
||||
public PneumaticSettingsValidator()
|
||||
{
|
||||
//Todo: Validate that the path actually exists
|
||||
RuleFor(c => c.NzbFolder).IsValidPath();
|
||||
RuleFor(c => c.StrmFolder).IsValidPath();
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,9 +20,12 @@ public class PneumaticSettings : IProviderConfig
|
||||
{
|
||||
private static readonly PneumaticSettingsValidator Validator = new PneumaticSettingsValidator();
|
||||
|
||||
[FieldDefinition(0, Label = "Nzb Folder", Type = FieldType.Path)]
|
||||
[FieldDefinition(0, Label = "Nzb Folder", Type = FieldType.Path, HelpText = "This folder will need to be reachable from XBMC")]
|
||||
public String NzbFolder { get; set; }
|
||||
|
||||
[FieldDefinition(1, Label = "Strm Folder", Type = FieldType.Path, HelpText = ".strm files in this folder will be import by drone")]
|
||||
public String StrmFolder { get; set; }
|
||||
|
||||
public ValidationResult Validate()
|
||||
{
|
||||
return Validator.Validate(this);
|
||||
|
Loading…
Reference in New Issue
Block a user