initial upload
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
13
.idea/fix_subs_in_nested_downloads.iml
generated
Normal file
13
.idea/fix_subs_in_nested_downloads.iml
generated
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true">
|
||||||
|
<buildTags>
|
||||||
|
<option name="os" value="linux" />
|
||||||
|
</buildTags>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/fix_subs_in_nested_downloads.iml" filepath="$PROJECT_DIR$/.idea/fix_subs_in_nested_downloads.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
64
fix_subs_in_nested_downloads.go
Normal file
64
fix_subs_in_nested_downloads.go
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func checkForSubsDir(dir []os.DirEntry) bool {
|
||||||
|
for _, item := range dir {
|
||||||
|
if strings.ToLower(item.Name()) == "subs" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func processSeason(seasonDir string) {
|
||||||
|
|
||||||
|
// Get files within each directory
|
||||||
|
seasonsDirList, err := os.ReadDir(seasonDir)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure there's a subs directory
|
||||||
|
if !checkForSubsDir(seasonsDirList) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, seasonsDirItems := range seasonsDirList {
|
||||||
|
fmt.Println(seasonsDirItems.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
topDir := "/mnt/z/From Scratch (2022) [tvdb-400691]/"
|
||||||
|
// Read in the top directory
|
||||||
|
topDirList, err := os.ReadDir(topDir)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Each of the seasons directories
|
||||||
|
for _, seasonsDir := range topDirList {
|
||||||
|
|
||||||
|
// Ensure there's a Sxx in the name (for the season number)
|
||||||
|
ensureSeason, _ := regexp.MatchString(`.[sS][0-9]{1,2}.`, seasonsDir.Name())
|
||||||
|
|
||||||
|
// Or if the folder is just called Season xx
|
||||||
|
if !ensureSeason {
|
||||||
|
ensureSeason, _ = regexp.MatchString(`[sS]eason\s[0-9]{1,2}`, seasonsDir.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the season if it is a season folder
|
||||||
|
if ensureSeason {
|
||||||
|
processSeason(topDir + seasonsDir.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user