Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support older Borderlands games? #21

Open
theDanielJLewis opened this issue Sep 19, 2019 · 3 comments
Open

Support older Borderlands games? #21

theDanielJLewis opened this issue Sep 19, 2019 · 3 comments

Comments

@theDanielJLewis
Copy link

I'd love to see this also support Borderlands, Borderlands 2, and Borderlands: The Pre-Sequel. Perhaps the source of this seemingly broken script could help.

@squatto
Copy link
Contributor

squatto commented Oct 10, 2019

I'm pretty sure the SHIFT codes from the earlier games can be redeemed through the same form on Borderlands.com can't they? The codes would just have to be pulled from the other Orcz.com pages. Want me to add this @matt1484?

@squatto
Copy link
Contributor

squatto commented Oct 11, 2019

I just checked this on the just-released BL2 codes (here) and you can redeem them through Borderlands.com:

image

The only thing that changes is the offer_title value (BL2 = "willow2")

@matt1484 - on a different topic (specifically PR #25) check out the response in the image above: is_active=false again. I wonder what their actual intention for that field is?

@wagnerscastle
Copy link

wagnerscastle commented Apr 2, 2020

This change lets you automate the SHiFT codes for all games. Terrible hack but has been working for a bit. Thanks to @squatto for figuring out that the codes work.

diff --git a/client.go b/client.go
index 80e5102..b17da96 100644
--- a/client.go
+++ b/client.go
@@ -8,6 +8,7 @@ import (
 	"io/ioutil"
 	. "net/http"
 	"net/http/cookiejar"
+	"os"
 
 	"github.com/PuerkitoBio/goquery"
 	"github.com/thedevsaddam/gojsonq"
@@ -149,6 +150,17 @@ func NewBl3Client() (*Bl3Client, error) {
 	}, nil
 }
 
+func (client *Bl3Client) LoadLocalConfig(configFilePath string) error {
+	configFile, err := os.Open(configFilePath)
+	defer configFile.Close()
+	if err != nil {
+		return errors.New("Failed to get config")
+	}
+	jsonParser := json.NewDecoder(configFile)
+	jsonParser.Decode(&client.Config)
+	return nil
+}
+
 func (client *Bl3Client) Login(username string, password string) error {
 	data := map[string]string{
 		"username": username,
diff --git a/cmd/main.go b/cmd/main.go
index 86f8a16..164a243 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -235,10 +235,12 @@ func main() {
 	password := ""
 	singleShiftCode := ""
 	allowInactive := false
+	gameVersion := ""
 	flag.StringVar(&username, "e", "", "Email")
 	flag.StringVar(&username, "email", "", "Email")
 	flag.StringVar(&password, "p", "", "Password")
 	flag.StringVar(&password, "password", "", "Password")
+	flag.StringVar(&gameVersion, "game", "", "Game to update (1,2,3,ps) default:3")
 	flag.StringVar(&singleShiftCode, "shift-code", "", "Single SHIFT code to redeem")
 	flag.BoolVar(&allowInactive, "allow-inactive", false, "Attempt to redeem SHIFT codes even if they are inactive?")
 	flag.Parse()
@@ -266,6 +268,29 @@ func main() {
 		printError(err)
 		return
 	}
+	err = client.LoadLocalConfig("config.json")
+	if err != nil {
+		printError(err)
+		return
+	}
+	if gameVersion != "" {
+		if gameVersion == "1" {
+			client.Config.Shift = client.Config.Shift1
+			fmt.Print("borderlands goty . . ")
+		} else if gameVersion == "2" {
+			client.Config.Shift = client.Config.Shift2
+			fmt.Print("borderlands 2 . . ")
+		} else if gameVersion == "ps" {
+			client.Config.Shift = client.Config.ShiftPS
+			fmt.Print("borderlands Pre-sequel . . ")
+		} else if gameVersion == "3" {
+			fmt.Print("borderlands 3 . . ")
+			gameVersion = ""
+		} else {
+			fmt.Println("invalid game version. must be '1', '2', '3', or 'ps'")
+			return
+		}
+	}
 
 	client.Config.Shift.AllowInactive = allowInactive
 
@@ -285,7 +310,7 @@ func main() {
 
 	doShift(client, singleShiftCode)
 
-	if singleShiftCode == "" {
+	if singleShiftCode == "" && gameVersion == "" {
 		doVip(client)
 	}
 
diff --git a/config.json b/config.json
index 03c585f..f1d96d1 100644
--- a/config.json
+++ b/config.json
@@ -27,5 +27,23 @@
         "codeInfoUrl": "https://api.2k.com/borderlands/code/",
         "userInfoUrl": "https://api.2k.com/borderlands/users/me",
         "gameCodename": "oak"
+    },
+    "shiftConfig1": {
+        "codeListUrl": "https://shift.orcicorn.com/tags/borderlands/index.json",
+        "codeInfoUrl": "https://api.2k.com/borderlands/code/",
+        "userInfoUrl": "https://api.2k.com/borderlands/users/me",
+        "gameCodename": "mopane"
+    },
+    "shiftConfig2": {
+        "codeListUrl": "https://shift.orcicorn.com/tags/borderlands2/index.json",
+        "codeInfoUrl": "https://api.2k.com/borderlands/code/",
+        "userInfoUrl": "https://api.2k.com/borderlands/users/me",
+        "gameCodename": "willow2"
+    },
+    "shiftConfigPS": {
+        "codeListUrl": "https://shift.orcicorn.com/tags/presequel/index.json",
+        "codeInfoUrl": "https://api.2k.com/borderlands/code/",
+        "userInfoUrl": "https://api.2k.com/borderlands/users/me",
+        "gameCodename": "cork"
     }
 }
diff --git a/utils.go b/utils.go
index 90aa2b6..5cc2648 100644
--- a/utils.go
+++ b/utils.go
@@ -27,4 +27,7 @@ type Bl3Config struct {
 	SessionHeader       string            `json:"sessionHeader"`
 	Vip                 VipConfig         `json:"vipConfig"`
 	Shift               ShiftConfig       `json:"shiftConfig"`
+	Shift1              ShiftConfig       `json:"shiftConfig1"`
+	Shift2              ShiftConfig       `json:"shiftConfig2"`
+	ShiftPS             ShiftConfig       `json:"shiftConfigPS"`
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants