Skip to content

Commit

Permalink
Randomize device ID if none is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakkin committed Jun 3, 2024
1 parent 46cfb08 commit 3807dce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Options:
Start downloading from the oldest segment rather than the newest
--access-token-device-id value
Device ID to send when acquiring an access token (optional)
If no device ID is specified, one will be generated randomly
--access-token-oauth value
OAuth token to send when acquiring an access token (optional)
--access-token-platform string
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func main() {
hideWindow()
}

if accessTokenDeviceID.string == nil {
accessTokenDeviceID.Set(randDeviceID())
}

externalCommand, externalArgs := len(flag.Args()) > 1, len(flag.Args()) > 2

username := flag.Arg(0)
Expand Down
7 changes: 6 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"math/rand"
"os"
"runtime/debug"
"strings"
Expand Down Expand Up @@ -85,7 +86,7 @@ func init() {
flag.StringVar(&accessTokenPlayerType, "access-token-player-type", accessTokenPlayerTypeDefault, "The player type to send when acquiring an access token")
flag.Var(&accessTokenPlayerBackend, "access-token-player-backend", "The player backend to send when acquiring an access token (optional)")
flag.Var(&accessTokenOAuth, "access-token-oauth", "OAuth token to send when acquiring an access token (optional)")
flag.Var(&accessTokenDeviceID, "access-token-device-id", "Device ID to send when acquiring an access token (optional)")
flag.Var(&accessTokenDeviceID, "access-token-device-id", "Device ID to send when acquiring an access token (optional)\n\tIf no device ID is specified, one will be generated randomly")
}

func printVersion() {
Expand Down Expand Up @@ -213,3 +214,7 @@ func printGroups(playlists []playlistInfo) {
fmt.Fprintln(os.Stderr)
}
}

func randDeviceID() string {
return fmt.Sprintf("%16x", rand.Uint64())
}

0 comments on commit 3807dce

Please sign in to comment.