Skip to content

Commit

Permalink
isort
Browse files Browse the repository at this point in the history
  • Loading branch information
subzeroid committed Dec 25, 2023
1 parent f800a78 commit ab588a5
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 34 deletions.
4 changes: 2 additions & 2 deletions instagrapi/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
Collection,
Comment,
DirectMedia,
Guide,
DirectMessage,
DirectResponse,
DirectShortThread,
DirectThread,
Guide,
Hashtag,
Highlight,
Location,
Media,
MediaXma,
MediaOembed,
MediaXma,
ReplyMessage,
Resource,
Story,
Expand Down
6 changes: 3 additions & 3 deletions instagrapi/image_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT

import os
import io
import os
import re
import tempfile
import shutil
import tempfile

try:
from PIL import Image
Expand Down Expand Up @@ -189,8 +189,8 @@ def prepare_video(
choose ultrafast when you are in a hurry and file size does not matter.
:return:
"""
from moviepy.video.fx.all import crop, resize
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.fx.all import resize, crop

min_size = kwargs.pop("min_size", (612, 320))
progress_bar = True if kwargs.pop("progress_bar", None) else False
Expand Down
21 changes: 15 additions & 6 deletions instagrapi/mixins/challenge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import hashlib
import json
import random
import time
from enum import Enum
from typing import Dict
import random

import requests

Expand Down Expand Up @@ -122,7 +122,11 @@ def challenge_resolve_contact_form(self, challenge_url: str) -> bool:
"Mobile Safari/537.36 %s" % self.user_agent,
"upgrade-insecure-requests": "1",
"sec-fetch-dest": "document",
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept": (
"text/html,application/xhtml+xml,application/xml;q=0.9,"
"image/webp,image/apng,*/*;q=0.8,"
"application/signed-exchange;v=b3;q=0.9"
),
"x-requested-with": "com.instagram.android",
"sec-fetch-site": "none",
"sec-fetch-mode": "navigate",
Expand Down Expand Up @@ -408,7 +412,8 @@ def challenge_resolve_simple(self, challenge_url: str) -> bool:
)
else:
raise ChallengeError(
f'ChallengeResolve: Choice "email" or "phone_number" (sms) not available to this account {self.last_json}'
f'ChallengeResolve: Choice "email" or "phone_number" '
f"(sms) not available to this account {self.last_json}"
)
wait_seconds = 5
for attempt in range(24):
Expand All @@ -434,7 +439,9 @@ def challenge_resolve_simple(self, challenge_url: str) -> bool:
# 'flow_render_type': 3,
# 'bloks_action': 'com.instagram.challenge.navigation.take_challenge',
# 'cni': 18226879502000588,
# 'challenge_context': '{"step_name": "change_password", "cni": 18226879502000588, "is_stateless": false, "challenge_type_enum": "PASSWORD_RESET"}',
# 'challenge_context': '{"step_name": "change_password",
# "cni": 18226879502000588, "is_stateless": false,
# "challenge_type_enum": "PASSWORD_RESET"}',
# 'challenge_type_enum_str': 'PASSWORD_RESET',
# 'status': 'ok'}
wait_seconds = 5
Expand Down Expand Up @@ -483,7 +490,8 @@ def challenge_resolve_simple(self, challenge_url: str) -> bool:
)
else:
raise ChallengeError(
f'ChallengeResolve: Choice "email" or "phone_number" (sms) not available to this account {self.last_json}'
f'ChallengeResolve: Choice "email" or "phone_number" (sms) '
f"not available to this account {self.last_json}"
)
wait_seconds = 5
for attempt in range(24):
Expand Down Expand Up @@ -525,6 +533,7 @@ def challenge_resolve_simple(self, challenge_url: str) -> bool:
return True
else:
raise ChallengeUnknownStep(
f'ChallengeResolve: Unknown step_name "{step_name}" for "{self.username}" in challenge resolver: {self.last_json}'
f'ChallengeResolve: Unknown step_name "{step_name}" for '
f'"{self.username}" in challenge resolver: {self.last_json}'
)
return True
6 changes: 3 additions & 3 deletions instagrapi/mixins/direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import re
import time
from pathlib import Path
from typing import List, Dict, Optional, Tuple
from typing import Dict, List, Optional, Tuple

from instagrapi.exceptions import ClientNotFoundError, DirectThreadNotFound
from instagrapi.extractors import (
extract_direct_media,
extract_direct_message,
extract_user_short,
extract_direct_thread,
extract_direct_short_thread,
extract_direct_thread,
extract_user_short,
)
from instagrapi.types import (
DirectMessage,
Expand Down
2 changes: 1 addition & 1 deletion instagrapi/mixins/fbsearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict, Tuple, Union
from typing import Dict, List, Tuple, Union

from instagrapi.extractors import (
extract_hashtag_v1,
Expand Down
13 changes: 9 additions & 4 deletions instagrapi/mixins/hashtag.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import json
import base64
import json
from typing import List, Tuple

from instagrapi.utils import dumps
from instagrapi.exceptions import ClientUnauthorizedError, ClientLoginRequired
from instagrapi.exceptions import ClientError, HashtagNotFound, WrongCursorError
from instagrapi.exceptions import (
ClientError,
ClientLoginRequired,
ClientUnauthorizedError,
HashtagNotFound,
WrongCursorError,
)
from instagrapi.extractors import (
extract_hashtag_gql,
extract_hashtag_v1,
extract_media_v1,
)
from instagrapi.types import Hashtag, Media
from instagrapi.utils import dumps


class HashtagMixin:
Expand Down
2 changes: 1 addition & 1 deletion instagrapi/mixins/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
LocationNotFound,
WrongCursorError,
)
from instagrapi.extractors import extract_location, extract_media_v1, extract_guide_v1
from instagrapi.extractors import extract_guide_v1, extract_location, extract_media_v1
from instagrapi.types import Guide, Location, Media

tab_keys_a1 = ("edge_location_to_top_posts", "edge_location_to_media")
Expand Down
16 changes: 13 additions & 3 deletions instagrapi/mixins/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
PhotoNotUpload,
)
from instagrapi.extractors import extract_media_v1
from instagrapi.image_util import prepare_image
from instagrapi.types import (
Location,
Media,
Expand All @@ -29,7 +30,6 @@
Usertag,
)
from instagrapi.utils import date_time_original, dumps
from instagrapi.image_util import prepare_image

try:
from PIL import Image
Expand Down Expand Up @@ -303,7 +303,14 @@ def photo_configure(
"camera_model": self.device.get("model", ""),
"camera_make": self.device.get("manufacturer", ""),
"scene_type": "?",
"nav_chain": "8rL:self_profile:4,ProfileMediaTabFragment:self_profile:5,UniversalCreationMenuFragment:universal_creation_menu:7,ProfileMediaTabFragment:self_profile:8,MediaCaptureFragment:tabbed_gallery_camera:9,Dd3:photo_filter:10,FollowersShareFragment:metadata_followers_share:11",
"nav_chain": (
"8rL:self_profile:4,ProfileMediaTabFragment:self_profile:5,"
"UniversalCreationMenuFragment:universal_creation_menu:7,"
"ProfileMediaTabFragment:self_profile:8,"
"MediaCaptureFragment:tabbed_gallery_camera:9,"
"Dd3:photo_filter:10,"
"FollowersShareFragment:metadata_followers_share:11"
),
"date_time_original": date_time_original(time.localtime()),
"date_time_digitalized": date_time_original(time.localtime()),
"creation_logger_session_id": self.client_session_id,
Expand Down Expand Up @@ -458,7 +465,10 @@ def photo_configure_to_story(
medias = medias.copy()
story_sticker_ids = []
data = {
"text_metadata": '[{"font_size":40.0,"scale":1.0,"width":611.0,"height":169.0,"x":0.51414347,"y":0.8487708,"rotation":0.0}]', # REMOVEIT
"text_metadata": (
'[{"font_size":40.0,"scale":1.0,"width":611.0,"height":169.0,'
'"x":0.51414347,"y":0.8487708,"rotation":0.0}]'
), # REMOVEIT
"supported_capabilities_new": json.dumps(config.SUPPORTED_CAPABILITIES),
"has_original_sound": "1",
"camera_session_id": self.client_session_id,
Expand Down
12 changes: 6 additions & 6 deletions instagrapi/mixins/private.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
ClientConnectionError,
ClientError,
ClientForbiddenError,
PrivateAccount,
UserNotFound,
ProxyAddressIsBlocked,
InvalidTargetUser,
InvalidMediaId,
MediaUnavailable,
ClientJSONDecodeError,
ClientNotFoundError,
ClientRequestTimeout,
ClientThrottledError,
FeedbackRequired,
InvalidMediaId,
InvalidTargetUser,
LoginRequired,
MediaUnavailable,
PleaseWaitFewMinutes,
PrivateAccount,
ProxyAddressIsBlocked,
RateLimitError,
SentryBlock,
TwoFactorRequired,
UnknownError,
UserNotFound,
VideoTooLongException,
)
from instagrapi.utils import dumps, generate_signature, random_delay
Expand Down
2 changes: 1 addition & 1 deletion instagrapi/mixins/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from requests.packages.urllib3.util.retry import Retry

from instagrapi.exceptions import (
ClientUnauthorizedError,
ClientBadRequestError,
ClientConnectionError,
ClientError,
Expand All @@ -23,6 +22,7 @@
ClientLoginRequired,
ClientNotFoundError,
ClientThrottledError,
ClientUnauthorizedError,
)
from instagrapi.utils import random_delay

Expand Down
7 changes: 4 additions & 3 deletions instagrapi/mixins/track.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import Any, Dict
import shutil
from pathlib import Path
from typing import Any, Dict
from urllib.parse import urlparse

import requests

from instagrapi.exceptions import ClientError, TrackNotFound
from instagrapi.extractors import extract_track
from instagrapi.types import Track
from instagrapi.utils import json_value
from instagrapi.exceptions import ClientError, TrackNotFound


class TrackMixin:
Expand All @@ -25,7 +25,8 @@ def track_download_by_url(
filename: str, optional
Filename for the track
folder: Path, optional
Directory in which you want to download the track, default is "" and will download the files to working directory
Directory in which you want to download the track,
default is "" and will download the files to working directory
Returns
-------
Expand Down
1 change: 0 additions & 1 deletion instagrapi/mixins/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from instagrapi.types import Relationship, RelationshipShort, User, UserShort
from instagrapi.utils import json_value


MAX_USER_COUNT = 200


Expand Down

0 comments on commit ab588a5

Please sign in to comment.