Exemplo n.º 1
0
func (self FilesystemExtractor) Names(epi *renamer.Episode) ([]string, error) {
	possibilities := []string{epi.Series}

	if util.IsDirectory(epi.Path) {
		// Check all subdirectories and the episodefile itepi for a suitable
		// series name
		episodepath := epi.Path

		// get the diff between epi.Path and epi.Episodefile so that we can
		// add one path element a time and extract the series
		subpath := epi.Episodefile[len(episodepath):]

		splits := strings.Split(subpath, "/")

		for _, part := range splits {
			if part == "" {
				continue
			}

			episodepath = path.Join(episodepath, part)

			subepisode, suberr := renamer.CreateEpisodeFromPath(episodepath)
			if suberr == nil {
				possibilities = append(possibilities, subepisode.Series)
			}
		}
	}

	return possibilities, nil
}
Exemplo n.º 2
0
func (s *ExtractorSuite) TestEpisodePossibleSeriesNamesFromFile(c *C) {
	extractor := FilesystemExtractor{}
	episode, _ := renamer.CreateEpisodeFromPath(s.FileWithPath("crmi"))

	names, err := extractor.Names(episode)
	c.Assert(names, DeepEquals, []string{"Criminal Minds"})
	c.Assert(err, IsNil)
}
Exemplo n.º 3
0
func (s *ExtractorSuite) TestEpisodePossibleSeriesNamesFromDirectory(c *C) {
	extractor := FilesystemExtractor{}
	episode, _ := renamer.CreateEpisodeFromPath(
		path.Dir(s.FileWithPath("rules_of_engagement")))

	names, err := extractor.Names(episode)
	c.Assert(names, DeepEquals, []string{
		"RoEG8p", "Rules of Engagement", "tvp egagement"})
	c.Assert(err, IsNil)
}
Exemplo n.º 4
0
func HandleInterestingEpisodes(entries []string) []*renamer.Episode {
	renameable_episodes := []*renamer.Episode{}

	for _, entry_path := range entries {

		episode, err := renamer.CreateEpisodeFromPath(entry_path)
		if err != nil {
			fmt.Printf("!!! '%s' - %s\n\n", entry_path, err)
			continue
		}

		episode.RemoveTrashwords()
		if !episode.HasValidEpisodeName() {
			episode.SetDefaultEpisodeName()
		}

		fmt.Printf("<<< %s\n", entry_path)
		fmt.Printf(">>> %s\n", episode.CleanedFileName())

		if !episode.CanBeRenamed() {
			fmt.Printf("!!! '%s' is currently not renameable\n\n", entry_path)
			continue
		}

		if AddToIndex {
			added, added_err := SeriesIndex.AddEpisode(episode)
			if !added {
				fmt.Printf("!!! couldn't be added to the index: %s\n\n", added_err)
				continue
			}
			fmt.Println("---> succesfully added to series index\n")
		}

		renameable_episodes = append(renameable_episodes, episode)
	}

	return renameable_episodes
}