Renamed mirror to a module + added basic python3 http server
This commit is contained in:
parent
02eff5188a
commit
c799fb8e63
Binary file not shown.
|
@ -7,18 +7,18 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def main():
|
def add_igaccount(acc_id):
|
||||||
data = getig_user_data('shakira')
|
data = getig_user_data(acc_id)
|
||||||
print(json.dumps(data, indent=4))
|
print(data)
|
||||||
|
|
||||||
# get all profile data from user:
|
# get all profile data from user:
|
||||||
# - display name
|
# - display name
|
||||||
# - bio description
|
# - bio description
|
||||||
# - shared posts (images/videos)
|
# - shared posts (images/videos)
|
||||||
# - much more info...
|
# - much more info...
|
||||||
def getig_user_data(user_id):
|
def getig_user_data(acc_id):
|
||||||
return json.loads(
|
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
|
# runs a basic GET request emulating Tor Browser
|
|
@ -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.")
|
Loading…
Reference in New Issue