|
@ -44,13 +44,18 @@ func Index(path string, results chan FileList, oldFileList *FileList) { |
|
|
var wg sync.WaitGroup |
|
|
var wg sync.WaitGroup |
|
|
|
|
|
|
|
|
bar := progressbar.NewOptions(len(fileList), |
|
|
bar := progressbar.NewOptions(len(fileList), |
|
|
progressbar.OptionSetDescription("Scanning files + metadata..."), |
|
|
|
|
|
progressbar.OptionShowCount(), |
|
|
progressbar.OptionShowCount(), |
|
|
progressbar.OptionShowIts()) |
|
|
progressbar.OptionShowIts()) |
|
|
|
|
|
|
|
|
for _, video := range fileList { |
|
|
for _, video := range fileList { |
|
|
wg.Add(1) |
|
|
wg.Add(1) |
|
|
go func(video os.FileInfo) { |
|
|
go func(video os.FileInfo) { |
|
|
|
|
|
if len(filepath.Ext(video.Name())) < 1 { |
|
|
|
|
|
wg.Done() |
|
|
|
|
|
_ = bar.Add(1) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
extension := filepath.Ext(video.Name())[1:] |
|
|
extension := filepath.Ext(video.Name())[1:] |
|
|
// check if extension is one of valid yt-dlp extensions, if not ignore file
|
|
|
// check if extension is one of valid yt-dlp extensions, if not ignore file
|
|
|
switch extension { |
|
|
switch extension { |
|
@ -79,6 +84,7 @@ func Index(path string, results chan FileList, oldFileList *FileList) { |
|
|
oldFileList.RUnlock() |
|
|
oldFileList.RUnlock() |
|
|
|
|
|
|
|
|
wg.Done() |
|
|
wg.Done() |
|
|
|
|
|
_ = bar.Add(1) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -112,11 +118,12 @@ func Index(path string, results chan FileList, oldFileList *FileList) { |
|
|
if !bar.IsFinished() { |
|
|
if !bar.IsFinished() { |
|
|
_ = bar.Finish() |
|
|
_ = bar.Finish() |
|
|
} |
|
|
} |
|
|
|
|
|
_ = bar.Close() |
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("Finished scan.") |
|
|
|
|
|
|
|
|
results <- FL |
|
|
results <- FL |
|
|
close(results) |
|
|
close(results) |
|
|
|
|
|
|
|
|
fmt.Println("\nArchive scan finished.") |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func filenameToID(filename string) string { |
|
|
func filenameToID(filename string) string { |
|
|