// OrganizeFile stores the videos in the video library func (o *Organizer) organizeFile(filePath string, log *logrus.Entry) error { log = log.WithField("file_path", filePath) log.Debug("organize file") // Create a file file := polochon.NewFileWithConfig(filePath, o.config.File) // Check if file really exists if !file.Exists() { log.Warning("the file has been removed") return nil } // Check if file is a video if !file.IsVideo() { log.Debug("the file is not a video") return nil } // Check if file is ignored if file.IsIgnored() { log.Debug("the file is ignored") return nil } // Check if file is symlink if file.IsSymlink() { log.Debug("the file is a symlink") return nil } // Check if file is ignored if file.IsExcluded() { log.Debug("the file is excluded") return file.Ignore() } // Guess the video inforamtion video, err := file.Guess(o.config.Movie, o.config.Show, log) if err != nil { errors.LogErrors(log, err) return file.Ignore() } // Get video details if err := video.GetDetails(log); err != nil { errors.LogErrors(log, err) if errors.IsFatal(err) { return file.Ignore() } } // Store the video if err := o.library.Add(video, log); err != nil { errors.LogErrors(log, err) return file.Ignore() } // Get subtitle if err := video.GetSubtitle(log); err != nil { errors.LogErrors(log, err) } // Notify o.Notify(video, log) return nil }