New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support of nfo when "Import existing series on Disk" #2096
Add support of nfo when "Import existing series on Disk" #2096
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for picking this up, the current solution needs some work before we can accept it though. I'm not sure how familiar you are with the codebase or C# in general, but please let us know if you have any questions and we'll try to assist.
@@ -153,7 +154,34 @@ private List<UnmappedFolder> GetUnmappedFolders(string path) | |||
foreach (string unmappedFolder in unmappedFolders) | |||
{ | |||
var di = new DirectoryInfo(unmappedFolder.Normalize()); | |||
results.Add(new UnmappedFolder { Name = di.Name, Path = di.FullName }); | |||
var fileNfoName = String.Format("{0}\\tvshow.nfo", di.FullName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Path.Combine
to join paths, which works on different operating systems, currently this would break on anything other than Windows.
@@ -153,7 +154,34 @@ private List<UnmappedFolder> GetUnmappedFolders(string path) | |||
foreach (string unmappedFolder in unmappedFolders) | |||
{ | |||
var di = new DirectoryInfo(unmappedFolder.Normalize()); | |||
results.Add(new UnmappedFolder { Name = di.Name, Path = di.FullName }); | |||
var fileNfoName = String.Format("{0}\\tvshow.nfo", di.FullName); | |||
if (File.Exists(fileNfoName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use DiskProvider.FileExists
so it can be mocked for unit tests.
else | ||
{ | ||
String tvid = node.InnerText; | ||
results.Add(new UnmappedFolder { Name = String.Format("tvdb:{0}", tvid), Path = di.FullName }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should still be the name, any additional information should be returned via a separate property, which also means the API and UI will need to be updated to pull in that information.
var fileNfoName = String.Format("{0}\\tvshow.nfo", di.FullName); | ||
if (File.Exists(fileNfoName)) | ||
{ | ||
try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic of pulling the ID from an NFO file should be pulled out to a separate method, possibly another class/interface so additional metadata types could be also be handled. It'd be worth looking at extending the existing metadata handling to be able to check for an existing file and check that file for an ID if the file doesn't exist or doesn't support storing an an ID Sonarr can use for a lookup it would return null.
I don't know why junit fail when I only edit javascript file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more things to address. Extracting the ID from the file in RootFolderServer still seems like the wrong approach, since it puts specific knowledge about the file there, when it otherwise shouldn't care. We'll need tests to validate the behaviour if it's going to stay here in RootFolderServiceFixture
.
As for the unit tests failing when you made a change to the JS it's because the whole test suite was re-run (it does that every build regardless of what changed).
@@ -30,9 +30,12 @@ module.exports = Marionette.CompositeView.extend({ | |||
|
|||
if (model) { | |||
var currentIndex = index; | |||
var folderName = model.get('folder').name; | |||
var termSearch = model.get('folder').name; | |||
if (typeof model.get('folder').id !== "undefined") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model.get('folder').id != null
(instead of the !==
you had before as !=
will catch undefined and null.
@@ -4,5 +4,6 @@ public class UnmappedFolder | |||
{ | |||
public string Name { get; set; } | |||
public string Path { get; set; } | |||
public string Id { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Id
is reserved for the Id
of the record, TvdbId
would be more accurate since that assumption is being made in the client. It should also be an integer instead of a string. Probably a nullable int so we don't return 0 if it's unknown.
XmlNode node = doc.DocumentElement.SelectSingleNode("/tvshow/id"); | ||
if (node != null) | ||
{ | ||
returnValue = node.InnerText; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return directly from here? This should also parse it to an integer to ensure it's valid.
After talking with @Taloth there are a couple things we want to improve here:
|
Database Migration
NO
Description
Add some code to read nfo when do "Importing existing series on Disk"
Todos
Issues Fixed or Closed by this PR
Fix issues #289