This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
/
spotify.go
79 lines (72 loc) · 2.59 KB
/
spotify.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package apps
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
"sync"
"github.com/fatih/color"
)
type spotifyResponse struct {
Status int `json:"status"`
Errors struct {
Email string `json:"email"`
} `json:"errors"`
Country string `json:"country"`
CanAcceptLicensesInOneStep bool `json:"can_accept_licenses_in_one_step"`
RequiresMarketingOptIn bool `json:"requires_marketing_opt_in"`
RequiresMarketingOptInText bool `json:"requires_marketing_opt_in_text"`
MinimumAge int `json:"minimum_age"`
CountryGroup string `json:"country_group"`
SpecificLicenses bool `json:"specific_licenses"`
TermsConditionsAcceptance string `json:"terms_conditions_acceptance"`
PrivacyPolicyAcceptance string `json:"privacy_policy_acceptance"`
SpotifyMarketingMessagesOption string `json:"spotify_marketing_messages_option"`
PretickEula bool `json:"pretick_eula"`
ShowCollectPersonalInfo bool `json:"show_collect_personal_info"`
UseAllGenders bool `json:"use_all_genders"`
UseOtherGender bool `json:"use_other_gender"`
DateEndianness int `json:"date_endianness"`
IsCountryLaunched bool `json:"is_country_launched"`
AllowedCallingCodes []struct {
CountryCode string `json:"country_code"`
CallingCode string `json:"calling_code"`
} `json:"allowed_calling_codes"`
PushNotifications bool `json:"push-notifications"`
}
func Spotify(wg *sync.WaitGroup, email string, showFalse bool) {
defer wg.Done()
var endpoint string = "https://spclient.wg.spotify.com/signup/public/v1/account"
data := url.Values{}
data.Set("validate", "1")
data.Set("email", email)
client := &http.Client{}
r, err := http.NewRequest("POST", endpoint, strings.NewReader(data.Encode())) // URL-encoded payload
if err != nil {
log.Fatal(err)
}
r.Header.Add("Content-Type", "application/x-www-form-urlencoded")
r.Header.Add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36")
res, err := client.Do(r)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 200 {
body, _ := ioutil.ReadAll(res.Body)
var response spotifyResponse
json.Unmarshal(body, &response)
if response.Status == 20 {
fmt.Println("Spotify \U0001f440")
} else {
if showFalse {
fmt.Println("Spotify", color.RedString(" [Not here!]"))
}
}
} else {
color.Red("Couldn't check Spotify!")
}
}