Fix podcasts with / in the name
This commit is contained in:
committed by
Senan Kelly
parent
87cd303257
commit
f7772303b0
@@ -304,7 +304,8 @@ type Podcast struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Podcast) Fullpath(podcastPath string) string {
|
func (p *Podcast) Fullpath(podcastPath string) string {
|
||||||
return filepath.Join(podcastPath, filepath.Clean(p.Title))
|
sanitizedTitle := strings.ReplaceAll(p.Title, "/", "_")
|
||||||
|
return filepath.Join(podcastPath, filepath.Clean(sanitizedTitle))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Podcast) SID() *specid.ID {
|
func (p *Podcast) SID() *specid.ID {
|
||||||
|
|||||||
@@ -343,7 +343,8 @@ func (p *Podcasts) findUniqueEpisodeName(
|
|||||||
if _, err := os.Stat(podcastPath); os.IsNotExist(err) {
|
if _, err := os.Stat(podcastPath); os.IsNotExist(err) {
|
||||||
return filename
|
return filename
|
||||||
}
|
}
|
||||||
titlePath := fmt.Sprintf("%s%s", podcastEpisode.Title, filepath.Ext(filename))
|
sanitizedTitle := strings.ReplaceAll(podcastEpisode.Title, "/", "_")
|
||||||
|
titlePath := fmt.Sprintf("%s%s", sanitizedTitle, filepath.Ext(filename))
|
||||||
podcastPath = path.Join(podcast.Fullpath(p.PodcastBasePath), titlePath)
|
podcastPath = path.Join(podcast.Fullpath(p.PodcastBasePath), titlePath)
|
||||||
if _, err := os.Stat(podcastPath); os.IsNotExist(err) {
|
if _, err := os.Stat(podcastPath); os.IsNotExist(err) {
|
||||||
return titlePath
|
return titlePath
|
||||||
@@ -353,7 +354,8 @@ func (p *Podcasts) findUniqueEpisodeName(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func findEpisode(base, filename string, count int) string {
|
func findEpisode(base, filename string, count int) string {
|
||||||
testFile := fmt.Sprintf("%s (%d)%s", filename, count, filepath.Ext(filename))
|
noExt := strings.TrimSuffix(filename, filepath.Ext(filename))
|
||||||
|
testFile := fmt.Sprintf("%s (%d)%s", noExt, count, filepath.Ext(filename))
|
||||||
podcastPath := path.Join(base, testFile)
|
podcastPath := path.Join(base, testFile)
|
||||||
if _, err := os.Stat(podcastPath); os.IsNotExist(err) {
|
if _, err := os.Stat(podcastPath); os.IsNotExist(err) {
|
||||||
return testFile
|
return testFile
|
||||||
|
|||||||
Reference in New Issue
Block a user