Skip to content

Commit

Permalink
main: support specified Referrer
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Mar 7, 2018
1 parent 41691ca commit 0859cbe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ $ annie -c "name=value; name2=value2" https://www.bilibili.com/video/av20203945
$ annie -c cookies.txt https://www.bilibili.com/video/av20203945
```

### Use specified Referrer

You can use the `-r` option to tell Annie to use the given Referrer to request.

```console
$ annie -r https://www.bilibili.com/video/av20383055/ http://cn-scnc1-dx.acgvideo.com/...

...
```

### Debug Mode

You can use the `-d` option to see network request message.
Expand Down Expand Up @@ -147,6 +157,8 @@ Usage of annie:
-d Debug mode
-i Information only
-p Download playlist
-r string
Use specified Referrer
-v Show version
```

Expand Down
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var (
Cookie string
// Playlist download playlist
Playlist bool
// Refer use specified Referrer
Refer string
)

// FakeHeaders fake http headers
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func init() {
flag.BoolVar(&config.InfoOnly, "i", false, "Information only")
flag.StringVar(&config.Cookie, "c", "", "Cookie")
flag.BoolVar(&config.Playlist, "p", false, "Download playlist")
flag.StringVar(&config.Refer, "r", "", "Use specified Referrer")
}

func main() {
Expand Down
3 changes: 3 additions & 0 deletions request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func Request(
for k, v := range headers {
req.Header.Set(k, v)
}
if config.Refer != "" {
req.Header.Set("Referer", config.Refer)
}
res, err := client.Do(req)
if err != nil {
log.Print(url)
Expand Down

0 comments on commit 0859cbe

Please sign in to comment.