func PathToStudio(path string, reader models.StudioReader, cache *Cache) (*models.Studio, error) {
	words := getPathWords(path)
	candidates, err := getStudios(words, reader, cache)

	if err != nil {
		return nil, err
	}

	var ret *models.Studio
	index := -1
	for _, c := range candidates {
		matchIndex := nameMatchesPath(c.Name.String, path)
		if matchIndex != -1 && matchIndex > index {
			ret = c
			index = matchIndex
		}

		aliases, err := reader.GetAliases(c.ID)
		if err != nil {
			return nil, err
		}

		for _, alias := range aliases {
			matchIndex = nameMatchesPath(alias, path)
			if matchIndex != -1 && matchIndex > index {
				ret = c
				index = matchIndex
			}
		}
	}

	return ret, nil
}
// PathToStudio returns the Studio that matches the given path.
// Where multiple matching studios are found, the one that matches the latest
// position in the path is returned.
PathToStudio returns the Studio that matches the given path.
Where multiple matching studios are found, the one that matches the latest
position in the path is returned.
// PathToStudio returns the Studio that matches the given path . // Where multiple matching studios are found the one that matches the latest // position in the path is returned .
func PathToStudio(path string, reader models.StudioReader, cache *Cache) (*models.Studio, error) {
	words := getPathWords(path)
	candidates, err := getStudios(words, reader, cache)
	if err != nil {
		return nil, err
	}
	var ret *models.Studio
	index := -1
	for _, c := range candidates {
		matchIndex := nameMatchesPath(c.Name.String, path)
		if matchIndex != -1 && matchIndex > index {
			ret = c
			index = matchIndex
		}
		aliases, err := reader.GetAliases(c.ID)
		if err != nil {
			return nil, err
		}
		for _, alias := range aliases {
			matchIndex = nameMatchesPath(alias, path)
			if matchIndex != -1 && matchIndex > index {
				ret = c
				index = matchIndex
			}
		}
	}
	return ret, nil
}
func PathToStudio ( path string , reader models . StudioReader , cache * Cache ) ( * models . Studio , error ) { words := getPathWords ( path ) candidates , err := getStudios ( words , reader , cache ) if err != nil { return nil , err } var ret * models . Studio index := - 1 for _ , c := range candidates { matchIndex := nameMatchesPath ( c . Name . String , path ) if matchIndex != - 1 && matchIndex > index { ret = c index = matchIndex } aliases , err := reader . GetAliases ( c . ID ) if err != nil { return nil , err } for _ , alias := range aliases { matchIndex = nameMatchesPath ( alias , path ) if matchIndex != - 1 && matchIndex > index { ret = c index = matchIndex } } } return ret , nil }
PathToStudio returns the Studio that matches the given path.
PathToStudio returns the Studio that matches the given path .