This commit is contained in:
ChaotiCryptidz 2022-08-14 11:13:23 +01:00
parent 204c73d46c
commit c1b1138779
No known key found for this signature in database
4 changed files with 14 additions and 21 deletions

View file

@ -182,7 +182,7 @@ func (c *CopyCommand) create_directories() {
}
}
func (c *CopyCommand) _transcode_file(file *types.File, trans_config *transcoder.TranscodeConfig) {
func (c *CopyCommand) _transcode_file(file *types.File, trans_config *transcoder.TranscodeConfig, is_threaded bool) {
new_filename := file.Filename + "." + trans_config.FileExtension
dest_filepath := *c.Args.Dest + "/"
@ -197,12 +197,14 @@ func (c *CopyCommand) _transcode_file(file *types.File, trans_config *transcoder
Msg("Skipping transcode as file already exists")
return
} else {
log.Info().Str("file", new_filename).Msg("Transcoding File")
log.Info().Str("file", new_filename).Msg("Transcoding")
}
output, err := transcoder.Transcode(file, trans_config, nil, dest_filepath)
if err != nil {
log.Fatal().Err(err).Str("output", output).Msg("Transcode Failed")
} else if is_threaded {
log.Info().Str("file", new_filename).Msg("Finished Transcoding")
}
}
@ -217,7 +219,7 @@ func (c *CopyCommand) transcode_files() {
}
if *c.Args.Threads == 0 {
for _, file := range c.Files {
c._transcode_file(file, trans_preset.Config)
c._transcode_file(file, trans_preset.Config, false)
}
} else {
var wg sync.WaitGroup
@ -228,7 +230,7 @@ func (c *CopyCommand) transcode_files() {
go func() {
for file := range jobs {
defer wg.Done()
c._transcode_file(file, trans_preset.Config)
c._transcode_file(file, trans_preset.Config, true)
}
}()
}

View file

@ -18,16 +18,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1650647760,
"narHash": "sha256-Ng8CGYLSTxeI+oEux0x+tSRA6K7ydoyfJNQf56ld+Uo=",
"lastModified": 1660410996,
"narHash": "sha256-arkfX1YYFmwMyDTCguzoOI4epABC41FGQU4J1/G3/9M=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b80f570a92d04e8ace67ff09c34aa48708a5c88c",
"rev": "70b6236f3cbc815f2cae8d597418c714cf83d1c8",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"ref": "release-22.05",
"repo": "nixpkgs",
"type": "github"
}
@ -41,11 +41,11 @@
},
"utils": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {

View file

@ -2,7 +2,7 @@
description = "A tool for organising a music library";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/release-22.05";
utils.url = "github:numtide/flake-utils";
flake-compat = {
url = "github:edolstra/flake-compat";

View file

@ -8,15 +8,6 @@ import (
"gitlab.com/ChaotiCryptidz/musicutil/types"
)
/*
def scan_for_music(src: str) -> list[File]:
files: list[File] = []
for format in supported_formats:
for path in Path(src).rglob("*." + format):
files.append(file_from_path(path, src))
return files
*/
func isValidFileExtension(filePath string) bool {
ext := strings.TrimPrefix(filepath.Ext(filePath), ".")
if ext == "mp3" {