Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
fix #2
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Chen <i@iochen.com>
  • Loading branch information
Richard Chen committed Jun 20, 2021
1 parent 6904fbd commit 0bd07f5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ in **Console**
3. run(or build it yourself) **skillshare-dl**, with command like below
```bash
$ skillshare-dl -cookie cookie.txt -id 970659408
# or
$ skillshare-dl -cookie cookie.txt -id 970659408 -id 652554100 -id ...
```

## Thanks
Expand Down
27 changes: 25 additions & 2 deletions cmd/skillshare-dl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"

"github.com/kennygrant/sanitize"
Expand All @@ -17,17 +18,39 @@ import (
ssdl "github.com/iochen/skillshare-dl"
)

type idList []int

func (l *idList) String() string {
return "video id list"
}

func (l *idList) Set(value string) error {
v, err := strconv.Atoi(value)
if err != nil {
return err
}
*l = append(*l, v)
return nil
}

func main() {
var list idList
cf := flag.String("cookie", "cookie.txt", "the file stored cookie")
id := flag.Int("id", 626081699, "video id")
flag.Var(&list, "id", "video id")
flag.Parse()

bytes, err := ioutil.ReadFile(*cf)
if err != nil {
logrus.Fatal(err)
}

logrus.Error(Download(string(bytes), *id))
fmt.Println("Video ID List:", list)

for i := range list {
fmt.Printf("=========== Downloading %d ===========\n", i)
logrus.Error(Download(string(bytes), list[i]))
fmt.Printf("=========== Video %d has been downloaded! ===========\n", i)
}
}

func Download(cookie string, id int) error {
Expand Down

0 comments on commit 0bd07f5

Please sign in to comment.