Skip to content

Commit

Permalink
feat: Prioritising preferred extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
caffeine-addictt committed Apr 19, 2024
1 parent f5204ae commit 73eecd0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
"os"
"path/filepath"
"regexp"
"slices"
"strconv"
"strings"
"sync"

"github.com/caffeine-addictt/video-manager/src/utils"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

// Non URL similarity
Expand Down Expand Up @@ -262,7 +264,18 @@ var getCommand = &cobra.Command{
return
}

fileName += extensions[0]
resolved := false
for _, ext := range viper.GetStringSlice("preferred_extensions") {
if slices.Contains(extensions, ext) {
fileName += ext
resolved = true
break
}
}

if !resolved {
fileName += extensions[0]
}
}
downloadLocation := filepath.Clean(filepath.Join(dirPath, fileName))

Expand Down

0 comments on commit 73eecd0

Please sign in to comment.