b
This commit is contained in:
parent
204c73d46c
commit
c1b1138779
|
@ -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
|
new_filename := file.Filename + "." + trans_config.FileExtension
|
||||||
dest_filepath := *c.Args.Dest + "/"
|
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")
|
Msg("Skipping transcode as file already exists")
|
||||||
return
|
return
|
||||||
} else {
|
} 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)
|
output, err := transcoder.Transcode(file, trans_config, nil, dest_filepath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Str("output", output).Msg("Transcode Failed")
|
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 {
|
if *c.Args.Threads == 0 {
|
||||||
for _, file := range c.Files {
|
for _, file := range c.Files {
|
||||||
c._transcode_file(file, trans_preset.Config)
|
c._transcode_file(file, trans_preset.Config, false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
|
@ -228,7 +230,7 @@ func (c *CopyCommand) transcode_files() {
|
||||||
go func() {
|
go func() {
|
||||||
for file := range jobs {
|
for file := range jobs {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
c._transcode_file(file, trans_preset.Config)
|
c._transcode_file(file, trans_preset.Config, true)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
14
flake.lock
14
flake.lock
|
@ -18,16 +18,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1650647760,
|
"lastModified": 1660410996,
|
||||||
"narHash": "sha256-Ng8CGYLSTxeI+oEux0x+tSRA6K7ydoyfJNQf56ld+Uo=",
|
"narHash": "sha256-arkfX1YYFmwMyDTCguzoOI4epABC41FGQU4J1/G3/9M=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "b80f570a92d04e8ace67ff09c34aa48708a5c88c",
|
"rev": "70b6236f3cbc815f2cae8d597418c714cf83d1c8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixpkgs-unstable",
|
"ref": "release-22.05",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,11 @@
|
||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1649676176,
|
"lastModified": 1659877975,
|
||||||
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
description = "A tool for organising a music library";
|
description = "A tool for organising a music library";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/release-22.05";
|
||||||
utils.url = "github:numtide/flake-utils";
|
utils.url = "github:numtide/flake-utils";
|
||||||
flake-compat = {
|
flake-compat = {
|
||||||
url = "github:edolstra/flake-compat";
|
url = "github:edolstra/flake-compat";
|
||||||
|
|
|
@ -8,15 +8,6 @@ import (
|
||||||
"gitlab.com/ChaotiCryptidz/musicutil/types"
|
"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 {
|
func isValidFileExtension(filePath string) bool {
|
||||||
ext := strings.TrimPrefix(filepath.Ext(filePath), ".")
|
ext := strings.TrimPrefix(filepath.Ext(filePath), ".")
|
||||||
if ext == "mp3" {
|
if ext == "mp3" {
|
||||||
|
|
Loading…
Reference in a new issue