Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,23 @@ You can use the `-start`, `-end` or `-items` option to specify the download rang
-items
File lines to download. Separated by commas like: 1,5,6,8-10
```
You can use the `-re` option to rename file with timestamp suffix
Comment thread
Snowmanazz marked this conversation as resolved.
Outdated

```console
$ lux -re "https://www.bilibili.com/video/BV1KF411Z7d9/"

Site: 哔哩哔哩 bilibili.com
Title: 每一种热爱都值得全力以赴!-1692149347
Type: video
Stream:
[32-7] -------------------
Quality: 清晰 480P avc1.64001F
Size: 17.88 MiB (18753237 Bytes)
# download with: lux -f 32-7 ...

17.88 MiB / 17.88 MiB [==================================================================================================================================] 3.74 MiB p/s 100.00% 5.0s
Comment thread
Snowmanazz marked this conversation as resolved.
Outdated

```

### Resume a download

Expand Down
12 changes: 12 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"sort"
"strings"
"time"

"github.com/fatih/color"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -152,6 +153,11 @@ func New() *cli.App {
Value: 10,
Usage: "The number of download thread (only works for multiple-parts video)",
},
&cli.BoolFlag{
Name: "rename",
Aliases: []string{"re"},
Usage: "Avoid duplicate names causing download failures; (name-timestamp)",
Comment thread
Snowmanazz marked this conversation as resolved.
Outdated
},

// Aria2
&cli.BoolFlag{
Expand Down Expand Up @@ -285,6 +291,12 @@ func download(c *cli.Context, videoURL string) error {
return err
}

if c.Bool("rename") {
for _, v := range data {
v.Title += fmt.Sprintf("-%v", time.Now().Unix())
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If more than one file is downloaded at a time, the timestamp is the same inside this loop

}
}

if c.Bool("json") {
e := json.NewEncoder(os.Stdout)
e.SetIndent("", "\t")
Expand Down