~hrodude/mvw-dl

91e13380cd3aada3fbf0ff7473eff00b5250f608 — Georg Kaemmert 2 months ago c2d229d
created directories are now free of slashes (unix)
1 files changed, 10 insertions(+), 8 deletions(-)

M main.go
M main.go => main.go +10 -8
@@ 14,6 14,7 @@ import (
	"os"
	"bufio"
	"github.com/schollz/progressbar/v3"
	"mvw-dl/osspecific"
)

type Item struct {


@@ 87,6 88,7 @@ func dirExists(dir string) bool {

func mkdir(dir string) error {
	var err error

        if !dirExists(dir) {
                err := os.MkdirAll(dir, 0750)
                if err != nil {


@@ 98,13 100,13 @@ func mkdir(dir string) error {

func getItemDir(dir string, item *Item) string {
	translate := map[string]string{}
	translate["%t"] = item.Title
	translate["%c"] = item.Category
	translate["%C"] = item.Creator
	translate["%D"] = item.PubDate
	translate["%G"] = item.Guid.Text
	translate["%T"] = item.Text
	translate["%e"] = filepath.Ext(item.Link)
	translate["%t"] = osspecific.CleanFolderName(item.Title)
	translate["%c"] = osspecific.CleanFolderName(item.Category)
	translate["%C"] = osspecific.CleanFolderName(item.Creator)
	translate["%D"] = osspecific.CleanFolderName(item.PubDate)
	translate["%G"] = osspecific.CleanFolderName(item.Guid.Text)
	translate["%T"] = osspecific.CleanFolderName(item.Text)
	translate["%e"] = osspecific.CleanFolderName(filepath.Ext(item.Link))
	for k, v := range translate {
		dir = strings.Replace(dir, k, v, -1)
	}


@@ 187,7 189,7 @@ func main() {

	searchFlag := flag.String("s","","!Sender #Thema +Titel *Beschreibung")
	feedFlag := flag.String("f","","URI to feed")
	directoryFlag := flag.String("d","./%C/%c/%t%e","directory to safe content")
	directoryFlag := flag.String("d","./%C/%c/%t%e","directory to safe content, defaults to ./%C/%c/%t%e (./%Channel/%Category/%Titel%Extension)")
	flag.Parse()
	if len(*feedFlag) > 0 {
		processFeed(*feedFlag, *directoryFlag)