• R/O
  • SSH
  • HTTPS

instalikes: Commit


Commit MetaInfo

Revision5 (tree)
Zeit2019-06-06 11:43:07
Autorderekwildstar

Log Message

- Implementada a funcionalidade de seguir usuários selecionados
- Melhoria na seleção de filtro de conta empresarial
- Incluído filtro para verificar quantidade de mídias compartilhadas

Ändern Zusammenfassung

Diff

--- trunk/src/UDAMOPrincipal.pas (revision 4)
+++ trunk/src/UDAMOPrincipal.pas (revision 5)
@@ -44,11 +44,12 @@
4444 TInstagramUsers = array of TInstagramUser;
4545
4646 TRelation = (rUnknown,rMoreThan,rLessThan);
47+ TBusinessAccount = (baDontCare,baInclude,baExclude);
4748
4849 TAddFollowersParams = record
4950 UsersToRegister: Cardinal;
5051 IncludePrivate: Boolean;
51- IncludeBusinessAccount: Boolean;
52+ BusinessAccount: TBusinessAccount;
5253 IncludeVerified: Boolean;
5354 IncludeFollowedByViewer: Boolean;
5455 FollowingCount: Cardinal;
@@ -55,6 +56,8 @@
5556 FollowingRelation: TRelation;
5657 FollowersCount: Cardinal;
5758 FollowersRelation: TRelation;
59+ MediaCount: Cardinal;
60+ MediaRelation: TRelation;
5861 end;
5962
6063 EInstagram = Exception;
@@ -100,7 +103,7 @@
100103 ACTNSelectAll: TAction;
101104 ACTNSelectNone: TAction;
102105 ACTNSelectInverse: TAction;
103- ACTNLikeAll: TAction;
106+ ACTNFollowUsers: TAction;
104107 ACTNLikeLastest: TAction;
105108 ACTNAddUser: TAction;
106109 procedure FDCOBeforeConnect(Sender: TObject);
@@ -118,6 +121,7 @@
118121 procedure ACTNSelectInverseExecute(Sender: TObject);
119122 procedure ACTNLikeLastestExecute(Sender: TObject);
120123 procedure ACTNAddUserExecute(Sender: TObject);
124+ procedure ACTNFollowUsersExecute(Sender: TObject);
121125 private
122126 { Private declarations }
123127 FRequestsSoFar: Cardinal;
@@ -140,6 +144,7 @@
140144 procedure UpdateUser(const AInstagramUser: TInstagramUser); overload;
141145 procedure SelectFollowers(AUserId: String; AKRKDBGrid: TKRKDBGrid);
142146 procedure LikeLastMedia(const AKRKDBGridUser: TKRKDBGrid);
147+ procedure FollowUsers(const AKRKDBGridUser: TKRKDBGrid);
143148 procedure HandleModalResult(AInternalForm: TForm);
144149
145150 { Não revisadas }
@@ -178,6 +183,7 @@
178183 procedure Wait; { isso é gambi }
179184 function LoggedUser(out AInstagramUser: TInstagramUser): Boolean;
180185 function LikeMedia(AMediaId: String; ALike: Boolean = True): Boolean;
186+ function Follow(AUserId: String): Boolean;
181187
182188 { Colocar como privado não revisados }
183189 procedure GetFollowersPage(AUserId: String;
@@ -263,6 +269,14 @@
263269 ConfigureErrorHint('Blank Field','Please inform the profile name to add',FORMPrincipal.EDITProfile,True);
264270 end;
265271
272+procedure TDAMOPrincipal.ACTNFollowUsersExecute(Sender: TObject);
273+begin
274+ if FORMPrincipal.KRDGUser.SelectedRows.Count = 0 then
275+ ConfigureErrorHint('No user selected','Please select at least one user!',FORMPrincipal.KRDGUser,True)
276+ else
277+ FollowUsers(FORMPrincipal.KRDGUser);
278+end;
279+
266280 procedure TDAMOPrincipal.ACTNLikeLastestExecute(Sender: TObject);
267281 begin
268282 if FORMPrincipal.KRDGUser.SelectedRows.Count = 0 then
@@ -359,6 +373,7 @@
359373 // - /////////////////////////////////////////////////////////////////////
360374 finally
361375 FB.Close;
376+ FB.Free;
362377 end;
363378 end
364379 else
@@ -660,6 +675,58 @@
660675 Text := Sender.AsString;
661676 end;
662677
678+function TDAMOPrincipal.Follow(AUserId: String): Boolean;
679+var
680+ RO: TRequestOptions;
681+ RE: TResponse;
682+begin
683+ ZeroMemory(@RO,SizeOf(RO));
684+ ZeroMemory(@RE,SizeOf(RE));
685+
686+ RO.AutoClearSSLState := True;
687+ RO.Content := TStringStream.Create('1=1');// Satisfazendo o Krakatoa :)
688+
689+ { InternetOpen }
690+ RO.InternetOpenParams.Agent := 'InstaLikes S2';
691+ RO.InternetOpenParams.AccessType := INTERNET_OPEN_TYPE_PRECONFIG;
692+
693+ { InternetConnect }
694+ RO.InternetConnectParams.ServerName := PChar('https://www.instagram.com/web/friendships/' + AUserId + '/follow/');
695+
696+ RO.InternetConnectParams.Service := INTERNET_SERVICE_HTTP;
697+
698+ { HttpOpenRequest }
699+ RO.HttpOpenRequestParams.Verb := 'POST';
700+ RO.HttpOpenRequestParams.ConnectTimeout := 30000;
701+ RO.HttpOpenRequestParams.SendTimeout := 30000;
702+ RO.HttpOpenRequestParams.ReceiveTimeout := 30000;
703+ RO.HttpOpenRequestParams.AcceptTypes := TStringList.Create;
704+ RO.HttpOpenRequestParams.AcceptTypes.Text := '*/*';
705+ RO.HttpOpenRequestParams.AutoDetectHTTPS := True;
706+ RO.HttpOpenRequestParams.Headers := TStringList.Create;
707+ RO.HttpOpenRequestParams.Headers.Add('content-type: application/x-www-form-urlencoded');
708+ RO.HttpOpenRequestParams.Headers.Add('x-csrftoken: ' + HeaderValue(FCSRFToken));
709+// RO.HttpOpenRequestParams.Headers.Add('referer: https://www.instagram.com/neymarjr');
710+ RO.HttpOpenRequestParams.Flags := INTERNET_FLAG_NO_CACHE_WRITE or INTERNET_FLAG_PRAGMA_NOCACHE;
711+
712+ { HttpSendRequest }
713+ RO.HttpSendRequestParams.IgnoreInvalidCertificateCA := True;
714+
715+ RE.Content := TStringStream.Create('');
716+ try
717+ Request(RO, RE);
718+ UpdateRequestsSoFar;
719+
720+ Result := True;
721+// Result := TStringStream(RE.Content).DataString = '{"result": "requested", "status": "ok"}';
722+ finally
723+ RE.Content.Free;
724+ RO.HttpOpenRequestParams.Headers.Free;
725+ RO.HttpOpenRequestParams.AcceptTypes.Free;
726+ RO.Content.Free;
727+ end;
728+end;
729+
663730 procedure TDAMOPrincipal.AddFollowers(const AUserId: String; AParams: TAddFollowersParams);
664731 var
665732 NPT: String;
@@ -672,7 +739,10 @@
672739 Registered: Word;
673740 Page: Word;
674741 begin
675- UseExtendedFilters := (AParams.FollowersCount > 0) or (AParams.FollowingCount > 0) or AParams.IncludeBusinessAccount;
742+ UseExtendedFilters := (AParams.FollowersCount > 0)
743+ or (AParams.FollowingCount > 0)
744+ or (AParams.MediaCount > 0)
745+ or (Byte(AParams.BusinessAccount) > 0);
676746
677747 if AParams.UsersToRegister = 0 then
678748 raise EInstagram.Create('Por favor informe a quantidade de usuários a registrar');
@@ -724,9 +794,18 @@
724794 begin
725795 UserInfo(Followers[i].UserName,Followers[i]);
726796
727- // Se não for para incluir perfis empresariais e o perfil for empresarial, pula
728- if (not AParams.IncludeBusinessAccount) and Followers[i].IsBusinessAccount then
729- Continue;
797+ case AParams.BusinessAccount of
798+ // Se for para incluir perfis empresariais e o perfil for empresarial, pula
799+ baInclude: begin
800+ if not Followers[i].IsBusinessAccount then
801+ Continue;
802+ end;
803+ // Se não for para incluir perfis empresariais e o perfil for empresarial, pula
804+ baExclude: begin
805+ if Followers[i].IsBusinessAccount then
806+ Continue;
807+ end;
808+ end;
730809
731810 if AParams.FollowingCount > 0 then
732811 case AParams.FollowingRelation of
@@ -755,6 +834,21 @@
755834 Continue;
756835 end;
757836 end;
837+
838+ if AParams.MediaCount > 0 then
839+ case AParams.MediaRelation of
840+ rMoreThan: begin
841+ // Se o número de midias precisar ser maior que o parâmetro, mas for menor, pula
842+ if Followers[i].MediasTotal < AParams.MediaCount then
843+ Continue;
844+ end;
845+ rLessThan: begin
846+ // Se o número de mídias precisar ser menor que o parâmetro, mas for maior, pula
847+ if Followers[i].MediasTotal > AParams.MediaCount then
848+ Continue;
849+ end;
850+ end;
851+
758852 end;
759853
760854 if AddUser(Followers[i],AUserId) then
@@ -775,6 +869,7 @@
775869 Application.MessageBox('Operation finalized!','Success!',MB_ICONINFORMATION);
776870 finally
777871 FB.Close;
872+ FB.Free; // O FormBlender não é autodestrutível. Veja comentário sobre o Action := caFree;
778873 end;
779874 end;
780875
@@ -960,6 +1055,7 @@
9601055 UpdateRUR(AHeaders);
9611056 UpdateURLGen(AHeaders);
9621057 UpdateCSRFToken(AHeaders);
1058+// UpdateRolloutHash()
9631059 end;
9641060
9651061 procedure TDAMOPrincipal.UpdateRequestsSoFar;
@@ -1409,6 +1505,63 @@
14091505 end;
14101506 end;
14111507
1508+procedure TDAMOPrincipal.FollowUsers(const AKRKDBGridUser: TKRKDBGrid);
1509+var
1510+ BM: TBookmark;
1511+ FB: TKRKFormBlender;
1512+ FS: TFORMStatus;
1513+ Followed: Word;
1514+begin
1515+ TKRKFormBlender.ShowMe(TForm(AKRKDBGridUser.Owner),TFORMStatus,FB);
1516+ try
1517+ while not FB.InternalFormVisible do
1518+ Application.ProcessMessages;
1519+
1520+ FS := TFORMStatus(FB.InternalFormInstance);
1521+ FS.LABETitle.Caption := 'Following users...';
1522+ FS.LABEStatus.Caption := '0 / ' + AKRKDBGridUser.SelectedRows.Count.ToString;
1523+ FS.Update;
1524+ // - ///////////////////////////////////////////////////////////////////////
1525+ FStopProcessing := False;
1526+
1527+ with AKRKDBGridUser.DataSource.DataSet do
1528+ begin
1529+ DisableControls;
1530+ BM := Bookmark;
1531+ try
1532+ Followed := 0;
1533+ First;
1534+ while not EOF do
1535+ begin
1536+ if AKRKDBGridUser.SelectedRows.CurrentRowSelected then
1537+ begin
1538+ if Follow(FDTAUserid.AsString) then
1539+ Inc(Followed);
1540+
1541+ FS.LABEStatus.Caption := Followed.ToString + ' / ' + AKRKDBGridUser.SelectedRows.Count.ToString;
1542+ FS.Update;
1543+ end;
1544+
1545+ Next;
1546+ end;
1547+ finally
1548+ Bookmark := BM;
1549+ EnableControls;
1550+ end;
1551+ end;
1552+ // - ///////////////////////////////////////////////////////////////////////
1553+ if Followed = AKRKDBGridUser.SelectedRows.Count then
1554+ Application.MessageBox('Operation finalized!','Success!',MB_ICONINFORMATION)
1555+ else if Followed = 0 then
1556+ Application.MessageBox('Operation failed. No user was followed','Fail!',MB_ICONERROR)
1557+ else
1558+ Application.MessageBox('Operation finalized! Some users wasn''t followed','Success! (pero no mucho)',MB_ICONWARNING)
1559+ finally
1560+ FB.Close;
1561+ FB.Free; // O FormBlender não é autodestrutível. Veja comentário sobre o Action := caFree;
1562+ end;
1563+end;
1564+
14121565 procedure TDAMOPrincipal.LikeLastMedia(const AKRKDBGridUser: TKRKDBGrid);
14131566 var
14141567 BM: TBookmark;
@@ -1476,8 +1629,35 @@
14761629 // - ///////////////////////////////////////////////////////////////////////
14771630 Application.MessageBox('Operation finalized!','Success!',MB_ICONINFORMATION);
14781631 finally
1479- FB.Close; { Action = caFree}
1632+ FB.Close;
1633+ FB.Free; // O FormBlender não é autodestrutível. Veja comentário sobre o Action := caFree;
14801634 end;
14811635 end;
14821636
1637+//neymarjr
1638+//https://www.instagram.com/web/friendships/26669533/follow/
1639+//
1640+//_nakedwitch_
1641+//https://www.instagram.com/web/friendships/10178708069/follow/
1642+//
1643+//:authority: www.instagram.com
1644+//:method: POST
1645+//:path: /web/friendships/10178708069/follow/
1646+//:scheme: https
1647+//accept: */*
1648+//accept-encoding: gzip, deflate, br
1649+//accept-language: pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7
1650+//cache-control: no-cache
1651+//content-length: 0
1652+//content-type: application/x-www-form-urlencoded
1653+//cookie: mid=WTwgTAALAAEG3-DlXp-Pl-AT1OYz; mcd=3; fbm_124024574287414=base_domain=.instagram.com; shbid=10819; shbts=1559698631.3146431; rur=FRC; fbsr_124024574287414=nDFI1WH5k3vX8pSxqrpCHTRHS4g5ef_ZoqAOQCMMQ44.eyJjb2RlIjoiQVFENjloLW5VWFlEOWhoV24wMWdsYkY1T25kazV3V0kwNEN5MTkyYVBheERDamZsR0REYXRsaXVISEduSmJzNXI4SEJJXzBpd1dVQ1BVSEJTTmRXU25lckZfbGQyR2xtWHpBWlhabnRrQzg3cmpBYXNBRWU1XzZNUlZsRFl5N1p4S3FjRFJRclZGLTBTa0l2Skh3Y0FwU211NDFIVDBNUjNCWDQ5eU56NkN4Wkc1dTNfQVBmT2o2RG9FbzNsOVYwZEs5dHJXZmhnYkZjVDB4SzRyWVI0bkg4Q2VoY1J3Z0VnM0pid1VQb0tuY0xLUDBvVHNDOUwxOVA4blJReWxKUFZuYXhrb1cyTS1wMzlTTm9tZWNGb2hySU9pMHdVZzNvc0g0SURyUXA4NDBSRzhGTEJKUlJsY0Zqamd6U254eHQzanciLCJ1c2VyX2lkIjoiNjg0NDcxOTIzIiwiYWxnb3JpdGhtIjoiSE1BQy1TSEEyNTYiLCJpc3N1ZWRfYXQiOjE1NTk2OTg4NzJ9; csrftoken=z0AWYYAIcu40OcpltZqtq9FHsF5TrIyN; ds_user_id=1355122894; sessionid=1355122894%3Alp0w7wSzJNayEy%3A17; urlgen="{\"187.112.20.96\": 10429\054 \"177.207.5.72\": 18881\054 \"187.113.108.57\": 18881}:1hYKw7:spYTfWoyH5Hzy8HkKFZdUGRYOD4"
1654+//origin: https://www.instagram.com
1655+//pragma: no-cache
1656+//referer: https://www.instagram.com/_nakedwitch_/
1657+//user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36 OPR/60.0.3255.109
1658+//x-csrftoken: z0AWYYAIcu40OcpltZqtq9FHsF5TrIyN
1659+//x-ig-app-id: 936619743392459
1660+//x-instagram-ajax: e6864ac8b8b5
1661+//x-requested-with: XMLHttpRequest
1662+
14831663 end.
--- trunk/src/UFORMAddUserParams.pas (revision 4)
+++ trunk/src/UFORMAddUserParams.pas (revision 5)
@@ -14,7 +14,6 @@
1414 PNGBCancel: TPngBitBtn;
1515 LAEDUsersToRegister: TLabeledEdit;
1616 GRBXExtended: TGroupBox;
17- CHBXIncludeBusinessAcount: TCheckBox;
1817 CBBXFollowingRelation: TComboBox;
1918 CBBXFollowersRelation: TComboBox;
2019 EDITFollowingCount: TEdit;
@@ -25,6 +24,10 @@
2524 CHBXIncludeVerified: TCheckBox;
2625 CHBXIncludeFollowedByViewer: TCheckBox;
2726 BEVE1: TBevel;
27+ LABEMediaCount: TLabel;
28+ CBBXMediaRelation: TComboBox;
29+ EDITMediaCount: TEdit;
30+ RAGRBusinessAccount: TRadioGroup;
2831 procedure PNGBOKClick(Sender: TObject);
2932 procedure FormCreate(Sender: TObject);
3033 private
@@ -76,18 +79,17 @@
7679 else
7780 FAddFollowersParams.FollowingRelation := rLessThan;
7881
79- FAddFollowersParams.IncludeBusinessAccount := CHBXIncludeBusinessAcount.Checked;
82+ FAddFollowersParams.MediaCount := StrToIntDef(EDITMediaCount.Text,0);
8083
84+ if CBBXMediaRelation.ItemIndex = 0 then
85+ FAddFollowersParams.MediaRelation := rMoreThan
86+ else
87+ FAddFollowersParams.MediaRelation := rLessThan;
88+
89+ FAddFollowersParams.BusinessAccount := TBusinessAccount(RAGRBusinessAccount.ItemIndex);
90+
8191 ModalResult := mrOk;
8292 end;
83-
84-
85-
86-
87-
88-// FollowingRelation: TRelation;
89-// FollowersRelation: TRelation;
90-
9193 end;
9294
9395 end.
--- trunk/src/UFORMPrincipal.pas (revision 4)
+++ trunk/src/UFORMPrincipal.pas (revision 5)
@@ -47,7 +47,7 @@
4747 PNGSSelectAll: TPngSpeedButton;
4848 PNGSSelectNone: TPngSpeedButton;
4949 PNGSSelectInverse: TPngSpeedButton;
50- PNGSLikeAll: TPngSpeedButton;
50+ PNGSFollowUsers: TPngSpeedButton;
5151 PNGSLikeLastest: TPngSpeedButton;
5252 STBAMedias: TStatusBar;
5353 PANLMedias: TPanel;
Show on old repository browser