Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alpkeskin
GitHub Repository: alpkeskin/mosint
Path: blob/master/v3/pkg/social/spotify/spotify.go
689 views
1
/*
2
Copyright © 2023 github.com/alpkeskin
3
*/
4
package spotify
5
6
import (
7
"encoding/json"
8
"fmt"
9
"io"
10
"net/http"
11
12
"github.com/alpkeskin/mosint/v3/internal/spinner"
13
"github.com/fatih/color"
14
)
15
16
type Spotify struct {
17
Exists bool
18
}
19
20
type response struct {
21
Status int `json:"status"`
22
Errors struct {
23
Email string `json:"email"`
24
} `json:"errors"`
25
Country string `json:"country"`
26
CanAcceptLicensesInOneStep bool `json:"can_accept_licenses_in_one_step"`
27
RequiresMarketingOptIn bool `json:"requires_marketing_opt_in"`
28
RequiresMarketingOptInText bool `json:"requires_marketing_opt_in_text"`
29
MinimumAge int `json:"minimum_age"`
30
CountryGroup string `json:"country_group"`
31
SpecificLicenses bool `json:"specific_licenses"`
32
TermsConditionsAcceptance string `json:"terms_conditions_acceptance"`
33
PrivacyPolicyAcceptance string `json:"privacy_policy_acceptance"`
34
SpotifyMarketingMessagesOption string `json:"spotify_marketing_messages_option"`
35
PretickEula bool `json:"pretick_eula"`
36
ShowCollectPersonalInfo bool `json:"show_collect_personal_info"`
37
UseAllGenders bool `json:"use_all_genders"`
38
UseOtherGender bool `json:"use_other_gender"`
39
UsePreferNotToSayGender bool `json:"use_prefer_not_to_say_gender"`
40
ShowNonRequiredFieldsAsOptional bool `json:"show_non_required_fields_as_optional"`
41
DateEndianness int `json:"date_endianness"`
42
IsCountryLaunched bool `json:"is_country_launched"`
43
AllowedCallingCodes []struct {
44
CountryCode string `json:"country_code"`
45
CallingCode string `json:"calling_code"`
46
} `json:"allowed_calling_codes"`
47
PushNotifications bool `json:"push-notifications"`
48
}
49
50
func New() *Spotify {
51
return &Spotify{}
52
}
53
54
func (s *Spotify) Check(email string) {
55
spinner := spinner.New("Spotify Account Checking")
56
spinner.Start()
57
58
url := fmt.Sprintf("https://spclient.wg.spotify.com/signup/public/v1/account?validate=1&email=%s", email)
59
req, err := http.NewRequest("GET", url, nil)
60
61
if err != nil {
62
spinner.StopFail()
63
spinner.SetMessage(err.Error())
64
return
65
}
66
67
req.Header.Add("User-Agent", "Mozilla/5.0 (Linux; Android 10; SM-G960F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.120 Mobile Safari/537.36")
68
client := &http.Client{}
69
resp, err := client.Do(req)
70
71
if err != nil {
72
spinner.StopFail()
73
spinner.SetMessage(err.Error())
74
return
75
}
76
77
defer resp.Body.Close()
78
body, err := io.ReadAll(resp.Body)
79
80
if err != nil {
81
spinner.StopFail()
82
spinner.SetMessage(err.Error())
83
return
84
}
85
86
var r response
87
err = json.Unmarshal(body, &r)
88
89
if err != nil {
90
spinner.StopFail()
91
spinner.SetMessage(err.Error())
92
return
93
}
94
95
if r.Status != 20 {
96
s.Exists = false
97
spinner.Stop()
98
return
99
}
100
101
s.Exists = true
102
spinner.Stop()
103
}
104
105
func (i *Spotify) Print() {
106
if i.Exists {
107
fmt.Println(color.GreenString("[+]"), "Spotify Account Exists", color.GreenString("\u2714"))
108
return
109
}
110
fmt.Println(color.RedString("[!]"), "Spotify Account Not Exists", color.RedString("\u2718"))
111
}
112
113