forked from digitalocean/sample-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
39 lines (36 loc) · 1.5 KB
/
server.py
File metadata and controls
39 lines (36 loc) · 1.5 KB
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
import os
import http.server
import socketserver
from http import HTTPStatus
from instagrapi import Client
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self):
client = Client()
client.set_proxy("https://GKDM5x6q5UxLsSGc:wifi;in;tripleplay;;@proxy.soax.com:9000")
# client.load_settings("session.json")
client.delay_range = [2, 5]
client.login("rgsp.amm", "ie5HN>Z~f6AGg@#")
client.dump_settings("session.json")
client.get_timeline_feed()
user_id = client.user_id_from_username("iamhardikpahwa")
medias = client.user_medias(user_id)
result = {}
i = 0
for media in medias:
if i >= 10:
break
paths = []
if media.media_type == 1:
paths.append(client.photo_download(media.pk))
elif media.media_type == 2 and media.product_type == "feed":
paths.append(client.video_download(media.pk))
elif media.media_type == 2 and media.product_type == "igtv":
paths.append(client.video_download(media.pk))
elif media.media_type == 2 and media.product_type == "clips":
paths.append(client.video_download(media.pk))
elif media.media_type == 8:
for path in client.album_download(media.pk):
paths.append(path)
result[media.pk] = paths
print(f"https://instagram.com/p/{media.code}/", paths)
i += 1