From c799fb8e634a0031b6d8bee6f81cb78b619bf55d Mon Sep 17 00:00:00 2001 From: Bastard Operator Date: Sun, 7 Feb 2021 01:21:58 +0100 Subject: [PATCH] Renamed mirror to a module + added basic python3 http server --- __pycache__/igmirror.cpython-37.pyc | Bin 0 -> 2182 bytes mirror.py => igmirror.py | 10 ++++---- server.py | 37 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 __pycache__/igmirror.cpython-37.pyc rename mirror.py => igmirror.py (91%) create mode 100644 server.py diff --git a/__pycache__/igmirror.cpython-37.pyc b/__pycache__/igmirror.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..87ce2514b99759ba2ecca5f5d58c44228ff03ed9 GIT binary patch literal 2182 zcmZ`)&2!sC6yMdCW!X-e^doIyrsiuVDv6a8I+U~p+R)MiWI7FBa9}*Kjze@^;q+@n(Mw^bHg`kZu(};E#G1q(_aw3!3<^sx7i$P zF#84do2_p>WzZap#ZVWU>`eWbkRP+9vS)6c9;Da!4ms z(vluhSVdqJ-EuWG-{&&!2jiTJfQ2$t=19b;gc&Q0q9A6)s$6a*y$+ zJn`;|Y?nte_u@2{VPAy9)nP0|CcLvb!3`6NsfhX5DIVKGpqP0#!dj-p&wdCkKkViO&UmF@iud!KxRFXq70c_|u z^cnmt^cZXY(wyiA@0WT-r{qiW@a)7WjZ)idh~-i*jdP^bO5+-NviyKBr_%6d6T(_j zuZ)sZ<`l-2H6=@AV#@Jpohn@IYn>5Sj?#YQGPn9NHIMgPs zvQ?dy4OmT=;4C(`1ZyZkY3bBG2Yj)(Rp=MJi^UvISMP7H@bv1F>ubHs#X`S`M=M>% zcal)@mF{CvID4FrR>LHI$_qQqR--T)@M2+qf4?{LRxiqi#rc7hqkO~j{xjtjH^0e> zI7ve9a&N7>{2)$Qwx4&mzU{8B_13O-#nX*XuJqR2?pHk8%e+f#>uc~|@7|6D-^mWV zda~(TH=>A-WHEotSHBL^{y6OOnc!9$Wh_qn%Gu1)6kKq|=scH;($hgQA z-FMHZMTp@*gmBkk@Or}7RM^+zPgDZEg$9DSsY9ARH%h23!Z=zE$6RN9k#{ugrP? ztVT$MZwQ``1lFxLQ?&)MbI|fDKnS%ojsE**YjaRnPEd!Qq3yc0f!lNuYTxw7QRwf2ya+8^*0s3ZXLKa()=dCG$nt&tycm#Ff-UE<9W;M2oX3u-&?m9li zBA_eUGa=N#qO<(y`$roOKXf;idl%g!ELUz@TmYsT3HX%7Lg@*($vTc7)j$qGAl?O? zI)21^sI3XEtel4;8Yr_bvhhfn5H|71wG<6~9UcWJt{4)vUzLGDF(?_RayA5dd z!$ZL42KeI?_`-mGn|7%{jak*#VSsHDmmny7s~Cj}1aB4A&`LvVLSLW4dsk{;8*NK? zpy?W78JL2237Noyc5t6r&G?Ac<#bqS8PyJ-nfmPpbwp|(yc@QWAxBUkY3^;+0kFu`~Gd526 ZXXv{8JP;e;%zm2Pv@PcyyKP%G{R?C)8+-r& literal 0 HcmV?d00001 diff --git a/mirror.py b/igmirror.py similarity index 91% rename from mirror.py rename to igmirror.py index 369be8b..c28c2b6 100644 --- a/mirror.py +++ b/igmirror.py @@ -7,18 +7,18 @@ import json import os import re -def main(): - data = getig_user_data('shakira') - print(json.dumps(data, indent=4)) +def add_igaccount(acc_id): + data = getig_user_data(acc_id) + print(data) # get all profile data from user: # - display name # - bio description # - shared posts (images/videos) # - much more info... -def getig_user_data(user_id): +def getig_user_data(acc_id): return json.loads( - instagram_get('/{}/?__a=1'.format(user_id), 120000) + instagram_get('/{}/?__a=1'.format(acc_id), 120000) ) # runs a basic GET request emulating Tor Browser diff --git a/server.py b/server.py new file mode 100644 index 0000000..2309dfd --- /dev/null +++ b/server.py @@ -0,0 +1,37 @@ +from http.server import BaseHTTPRequestHandler, HTTPServer +import igmirror +import re + +hostName = "localhost" +serverPort = 8080 + +def update_igaccount(name): + print(name) + +class MyServer(BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header("Content-type", "application/json") + self.end_headers() + path = self.path.strip('/') + parts = path.split('/') + if len(parts) == 2: + # make sure account name contains only safe characters + accname = re.sub(r'[^a-zA-Z0-9_]+', '', parts[0]) + if parts[1].lower() == 'add': + igmirror.add_igaccount(accname) + elif parts[1].lower() == 'update': + update_igaccount(accname) + self.wfile.write(bytes('OK', "utf-8")) + +if __name__ == "__main__": + webServer = HTTPServer(('localhost', 8080), MyServer) + print("Server started http://%s:%s" % (hostName, serverPort)) + + try: + webServer.serve_forever() + except KeyboardInterrupt: + pass + + webServer.server_close() + print("Server stopped.")