fix filters

This commit is contained in:
Simon Vieille 2022-08-22 16:09:04 +02:00
parent ca4aff040e
commit 8847df2422
Signed by: deblan
GPG Key ID: 579388D585F70417
1 changed files with 15 additions and 14 deletions

29
main.go
View File

@ -240,7 +240,6 @@ func runShell(ctx *cli.Context, action string) error {
var files []File
json.Unmarshal([]byte(body), &files)
size := len(files)
for key, file := range files {
@ -285,14 +284,16 @@ func runShell(ctx *cli.Context, action string) error {
b, _ := strconv.Atoi(data[2])
if a > b {
for i := a - 1; i >= b-1; i-- {
result = append(result, files[i])
fmt.Println(i)
fmt.Printf("%+v\n", a)
fmt.Printf("%+v\n", b)
for i := a; i >= b; i-- {
result = append(result, files[size-i])
}
fmt.Printf("%+v\n", result)
} else {
for i := b - 1; i >= a-1; i-- {
result = append(result, files[i])
fmt.Println(i)
for i := a; i <= b; i++ {
result = append(result, files[size-i])
}
}
} else if isRange2 { // a-
@ -301,8 +302,8 @@ func runShell(ctx *cli.Context, action string) error {
a, _ := strconv.Atoi(data[1])
for i := a - 1; i >= 0; i-- {
result = append(result, files[i])
for i := a; i >= 1; i-- {
result = append(result, files[size-i])
fmt.Println(i)
}
} else if isRange3 { // a+
@ -311,8 +312,8 @@ func runShell(ctx *cli.Context, action string) error {
a, _ := strconv.Atoi(data[1])
for i := a - 1; i < len(files); i++ {
result = append(result, files[i])
for i := a; i <= size; i++ {
result = append(result, files[size-i])
fmt.Println(i)
}
} else {
@ -323,13 +324,13 @@ func runShell(ctx *cli.Context, action string) error {
if isInt {
value, _ := strconv.Atoi(word)
result = append(result, files[value-1])
result = append(result, files[size-value])
}
}
}
if len(result) == 0 {
fmt.Println("Empty list")
fmt.Println("Empty list, aborded!")
return nil
}
@ -346,7 +347,7 @@ func runShell(ctx *cli.Context, action string) error {
cmds = append(cmds, cmd)
} else {
for _, f := range result {
output := fmt.Sprintf("/home/simon/Videos/%s", f.Name)
output := fmt.Sprintf("/tmp/mu/%s", f.Name)
cmd := exec.Command("wget", "-o", "/dev/stdout", "-c", "--show-progress", "-O", output, f.Url)
cmds = append(cmds, cmd)
}