Skip to content

Commit 385da86

Browse files
committed
optimizations
1 parent 0ab41b6 commit 385da86

File tree

7 files changed

+63
-85
lines changed

7 files changed

+63
-85
lines changed

README.md

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ensta)]()
44
[![Downloads](https://static.pepy.tech/badge/ensta)](https://pepy.tech/project/ensta)
55

6-
<!--![Instagram](https://img.shields.io/badge/Instagram-%23E4405F.svg?style=for-the-badge&logo=Instagram&logoColor=white)-->
7-
86
![Logo](https://raw.githubusercontent.com/diezo/Ensta/master/assets/image.jpg)
97

108
Ensta is a simple, reliable and up-to-date python package for Instagram API.
@@ -34,9 +32,9 @@ Read the [**Pre-Requisites**](https://github.com/diezo/Ensta/wiki/Pre%E2%80%90re
3432
Fetching profile info by username:
3533

3634
```python
37-
from ensta import Host
35+
from ensta import Web
3836

39-
host = Host(username, password)
37+
host = Web(username, password)
4038

4139
profile = host.profile("leomessi")
4240

@@ -45,12 +43,6 @@ print(profile.is_private)
4543
print(profile.profile_picture_url_hd)
4644
```
4745

48-
<!--## Bypass IP Restrictions
49-
If you're being rate limited when using Ensta on your home network or Ensta doesn't work when you deploy your app to the cloud, you should consider using a reputed proxy. Here's how to do that:
50-
1. Visit [abcproxy](https://www.abcproxy.com/?code=O4H3OC0O) and apply coupon ```O4H3OC0O``` for additional discount.
51-
2. Buy a residential SOCKS5 proxy there.
52-
3. Configure Ensta to use that proxy. See the [**Supported Actions**](https://github.com/diezo/ensta?tab=readme-ov-file#supported-actions) section.-->
53-
5446
## Features
5547
These features use the **Mobile API**.
5648

@@ -487,9 +479,9 @@ mobile.clear_bio_links()
487479
<summary>Upload Reel</summary><br>
488480

489481
```python
490-
from ensta import Host
482+
from ensta import Web
491483

492-
host = Host(username, password)
484+
host = Web(username, password)
493485

494486
video_id = host.upload_video_for_reel("Video.mp4", thumbnail="Thumbnail.jpg")
495487

@@ -503,26 +495,12 @@ host.pub_reel(
503495

504496
<details>
505497

506-
<summary>Check Username Availability</summary><br>
507-
508-
```python
509-
from ensta import Guest
510-
511-
guest = Guest()
512-
513-
print(guest.username_availability("theusernameiwant"))
514-
```
515-
516-
</details>
517-
518-
<details>
519-
520-
<summary>Fetch Profile Data</summary><br>
498+
<summary>Fetch Web Profile Data</summary><br>
521499

522500
```python
523-
from ensta import Host
501+
from ensta import Web
524502

525-
host = Host(username, password)
503+
host = Web(username, password)
526504
profile = host.profile("leomessi")
527505

528506
print(profile.full_name)
@@ -537,9 +515,9 @@ print(profile.follower_count)
537515
<summary>Fetch Someone's Feed</summary><br>
538516

539517
```python
540-
from ensta import Host
518+
from ensta import Web
541519

542-
host = Host(username, password)
520+
host = Web(username, password)
543521
posts = host.posts("leomessi", 100) # Want full list? Set count to '0'
544522

545523
for post in posts:
@@ -554,9 +532,9 @@ for post in posts:
554532
<summary>Fetch Post's Likers</summary><br>
555533

556534
```python
557-
from ensta import Host
535+
from ensta import Web
558536

559-
host = Host(username, password)
537+
host = Web(username, password)
560538

561539
post_id = host.get_post_id("https://www.instagram.com/p/Czr2yLmroCQ/")
562540
likers = host.likers(post_id)
@@ -579,9 +557,9 @@ for user in likers.users:
579557
Requires login, and has many features.
580558

581559
```python
582-
from ensta import Host
560+
from ensta import Web
583561

584-
host = Host(username, password)
562+
host = Web(username, password)
585563
profile = host.profile("leomessi")
586564

587565
print(profile.biography)

README_OLD.md

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Read the [**Pre-Requisites**](https://github.com/diezo/Ensta/wiki/Pre%E2%80%90re
3434
Fetching profile info by username:
3535

3636
```python
37-
from ensta import Host
37+
from ensta import Web
3838

39-
host = Host(username, password)
39+
host = Web(username, password)
4040

4141
profile = host.profile("leomessi")
4242

@@ -64,9 +64,9 @@ When you should use a proxy:
6464
- You're deploying Ensta to the cloud. (Instagram blocks requests from IPs of cloud providers, so a proxy must be used)
6565

6666
```python
67-
from ensta import Host
67+
from ensta import Web
6868

69-
host = Host(
69+
host = Web(
7070
username,
7171
password,
7272
proxy={
@@ -87,13 +87,13 @@ Ensta uses the same proxy settings as the **requests** module.
8787
We recommend using your email address to sign in. But if you have multiple accounts created on the same email address, you may consider using your username instead.
8888

8989
```python
90-
from ensta import Host
90+
from ensta import Web
9191

9292
# Recommended
93-
host = Host(email, password)
93+
host = Web(email, password)
9494

9595
# This also works
96-
host = Host(username, password)
96+
host = Web(username, password)
9797
```
9898

9999
</details>
@@ -107,9 +107,9 @@ Ensta will automatically save your login session in a file named ```ensta-sessio
107107
But, if you wish to load a session manually, you can use the **SessionHost Class** instead of **Host Class** by passing your session data (which is stored inside ```ensta-session.json```) as a string.
108108

109109
```python
110-
from ensta import SessionHost
110+
from ensta import WebSession
111111

112-
host = SessionHost(session_data)
112+
host = WebSession(session_data)
113113
```
114114

115115
</details>
@@ -121,12 +121,12 @@ host = SessionHost(session_data)
121121
**Authenticator App**
122122

123123
```python
124-
from ensta import Host
124+
from ensta import Web
125125

126126
# The key you got from Instagram when setting up your Authenticator App
127127
key = "R65I7XTTHNHTQ2NKMQL36NCWKNUPBSDG"
128128

129-
host = Host(
129+
host = Web(
130130
username, # or email
131131
password,
132132
totp_token=key
@@ -142,9 +142,9 @@ host = Host(
142142
<summary>Upload Photo (Single Post)</summary><br>
143143

144144
```python
145-
from ensta import Host
145+
from ensta import Web
146146

147-
host = Host(username, password)
147+
host = Web(username, password)
148148

149149
upload = host.upload_image("Picture.jpg")
150150

@@ -158,9 +158,9 @@ host.pub_photo(upload, caption="Travelling 🌆")
158158
<summary>Upload Multiple Medias (Single Post)</summary><br>
159159

160160
```python
161-
from ensta import Host
161+
from ensta import Web
162162

163-
host = Host(username, password)
163+
host = Web(username, password)
164164

165165
upload1 = host.upload_image("First.jpg")
166166
upload2 = host.upload_image("Second.jpg")
@@ -176,9 +176,9 @@ host.pub_carousel([upload1, upload2, upload3], caption="Travelling 🌆")
176176
<summary>Upload Reel</summary><br>
177177

178178
```python
179-
from ensta import Host
179+
from ensta import Web
180180

181-
host = Host(username, password)
181+
host = Web(username, password)
182182

183183
video_id = host.upload_video_for_reel("Video.mp4", thumbnail="Thumbnail.jpg")
184184

@@ -209,9 +209,9 @@ print(guest.username_availability("theusernameiwant"))
209209
<summary>Fetch Profile Data</summary><br>
210210

211211
```python
212-
from ensta import Host
212+
from ensta import Web
213213

214-
host = Host(username, password)
214+
host = Web(username, password)
215215
profile = host.profile("leomessi")
216216

217217
print(profile.full_name)
@@ -226,9 +226,9 @@ print(profile.follower_count)
226226
<summary>Username to UserID, and vice versa.</summary><br>
227227

228228
```python
229-
from ensta import Host
229+
from ensta import Web
230230

231-
host = Host(username, password)
231+
host = Web(username, password)
232232

233233
username = host.get_username(427553890)
234234
uid = host.get_uid("leomessi")
@@ -243,9 +243,9 @@ print(username, uid)
243243
<summary>Follow / Unfollow Users</summary><br>
244244

245245
```python
246-
from ensta import Host
246+
from ensta import Web
247247

248-
host = Host(username, password)
248+
host = Web(username, password)
249249

250250
print(host.follow("leomessi"))
251251
print(host.unfollow("leomessi"))
@@ -258,9 +258,9 @@ print(host.unfollow("leomessi"))
258258
<summary>Generate Followers / Followings List</summary><br>
259259

260260
```python
261-
from ensta import Host
261+
from ensta import Web
262262

263-
host = Host(username, password)
263+
host = Web(username, password)
264264

265265
followers = host.followers("leomessi", count=100) # Want full list? Set count to '0'
266266
followings = host.followings("leomessi", count=100) # Want full list? Set count to '0'
@@ -279,9 +279,9 @@ for user in followings:
279279
<summary>Switch Account Type - Public/Private</summary><br>
280280

281281
```python
282-
from ensta import Host
282+
from ensta import Web
283283

284-
host = Host(username, password)
284+
host = Web(username, password)
285285

286286
print(host.switch_to_public_account())
287287
print(host.switch_to_private_account())
@@ -294,9 +294,9 @@ print(host.switch_to_private_account())
294294
<summary>Fetch Someone's Feed</summary><br>
295295

296296
```python
297-
from ensta import Host
297+
from ensta import Web
298298

299-
host = Host(username, password)
299+
host = Web(username, password)
300300
posts = host.posts("leomessi", 100) # Want full list? Set count to '0'
301301

302302
for post in posts:
@@ -311,9 +311,9 @@ for post in posts:
311311
<summary>Add Comment on Posts</summary><br>
312312

313313
```python
314-
from ensta import Host
314+
from ensta import Web
315315

316-
host = Host(username, password)
316+
host = Web(username, password)
317317

318318
post_id = host.get_post_id("https://www.instagram.com/p/Czr2yLmroCQ/")
319319

@@ -327,9 +327,9 @@ host.comment("Looks great!", post_id)
327327
<summary>Like/Unlike Posts</summary><br>
328328

329329
```python
330-
from ensta import Host
330+
from ensta import Web
331331

332-
host = Host(username, password)
332+
host = Web(username, password)
333333

334334
post_id = host.get_post_id("https://www.instagram.com/p/Czr2yLmroCQ/")
335335

@@ -344,9 +344,9 @@ host.unlike(post_id)
344344
<summary>Fetch Post's Likers</summary><br>
345345

346346
```python
347-
from ensta import Host
347+
from ensta import Web
348348

349-
host = Host(username, password)
349+
host = Web(username, password)
350350

351351
post_id = host.get_post_id("https://www.instagram.com/p/Czr2yLmroCQ/")
352352
likers = host.likers(post_id)
@@ -377,9 +377,9 @@ mobile.change_profile_picture("image.jpg")
377377
<summary>Edit Biography, Display Name</summary><br>
378378

379379
```python
380-
from ensta import Host
380+
from ensta import Web
381381

382-
host = Host(username, password)
382+
host = Web(username, password)
383383

384384
host.change_display_name("Lionel Messi")
385385
host.change_bio("Athlete")
@@ -392,9 +392,9 @@ host.change_bio("Athlete")
392392
<summary>Fetch Your Email, Gender, Birthday, etc.</summary><br>
393393

394394
```python
395-
from ensta import Host
395+
from ensta import Web
396396

397-
host = Host(username, password)
397+
host = Web(username, password)
398398
me = host.private_info()
399399

400400
print(me.email)
@@ -579,9 +579,9 @@ mobile.clear_bio_links()
579579
Requires login, and has many features.
580580

581581
```python
582-
from ensta import Host
582+
from ensta import Web
583583

584-
host = Host(username, password)
584+
host = Web(username, password)
585585
profile = host.profile("leomessi")
586586

587587
print(profile.biography)

ensta/Authentication.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from json import JSONDecodeError
1010
from .PasswordEncryption import PasswordEncryption
1111
from .lib.Exceptions import (AuthenticationError, NetworkError)
12-
from .SessionHost import SessionHost
12+
from .WebSession import WebSession
1313

1414

1515
def new_session_id(
@@ -197,7 +197,7 @@ def new_session_id(
197197
"user_id": user_id,
198198
"ig_did": ig_did,
199199
"identifier": user_identifier,
200-
"username": SessionHost(
200+
"username": WebSession(
201201
json.dumps({
202202
"session_id": session_id,
203203
"rur": rur,
@@ -236,7 +236,7 @@ def new_session_id(
236236
"user_id": user_id,
237237
"ig_did": ig_did,
238238
"identifier": user_identifier,
239-
"username": SessionHost(
239+
"username": WebSession(
240240
json.dumps({
241241
"session_id": session_id,
242242
"rur": rur,

0 commit comments

Comments
 (0)