diff --git a/InstagramAPI/src/Constants.py b/InstagramAPI/src/Constants.py index 459edde..65e7c72 100644 --- a/InstagramAPI/src/Constants.py +++ b/InstagramAPI/src/Constants.py @@ -1,13 +1,17 @@ class Constants(object): """ Constant declarations. + https://github.com/mgp25/Instagram-API/blob/master/src/Constants.php """ API_URL = 'https://i.instagram.com/api/v1/' - VERSION = '9.2.0' - IG_SIG_KEY = '012a54f51c49aa8c5c322416ab1410909add32c966bbaa0fe3dc58ac43fd7ede' + VERSION = '27.0.0.7.97' + + IG_SIG_KEY = '109513c04303341a7daf27bb41b268e633b30dcc65a3fe14503f743176113869' EXPERIMENTS = 'ig_android_ad_holdout_16m5_universe,ig_android_progressive_jpeg,ig_creation_growth_holdout,ig_android_oppo_app_badging,ig_android_ad_remove_username_from_caption_universe,ig_android_enable_share_to_whatsapp,ig_android_direct_drawing_in_quick_cam_universe,ig_android_ad_always_send_ad_attribution_id_universe,ig_android_universe_video_production,ig_android_direct_plus_button,ig_android_ads_heatmap_overlay_universe,ig_android_http_stack_experiment_2016,ig_android_infinite_scrolling,ig_fbns_blocked,ig_android_post_auto_retry_v7_21,ig_fbns_push,ig_android_video_playback_bandwidth_threshold,ig_android_direct_link_preview,ig_android_direct_typing_indicator,ig_android_preview_capture,ig_android_feed_pill,ig_android_profile_link_iab,ig_android_story_caption,ig_android_network_cancellation,ig_android_histogram_reporter,ig_android_anrwatchdog,ig_android_search_client_matching,ig_android_follow_request_text_buttons,ig_android_feed_zoom,ig_android_drafts_universe,ig_android_disable_comment,ig_android_user_detail_endpoint,ig_android_os_version_blocking,ig_android_blocked_list,ig_android_event_creation,ig_android_high_res_upload_2,ig_android_2fac,ig_android_mark_reel_seen_on_Swipe_forward,ig_android_comment_redesign,ig_android_ad_sponsored_label_universe,ig_android_mentions_dismiss_rule,ig_android_disable_chroma_subsampling,ig_android_share_spinner,ig_android_video_reuse_surface,ig_explore_v3_android_universe,ig_android_media_favorites,ig_android_nux_holdout,ig_android_insta_video_universe,ig_android_search_null_state,ig_android_universe_reel_video_production,liger_instagram_android_univ,ig_android_direct_emoji_picker,ig_feed_holdout_universe,ig_android_direct_send_auto_retry_universe,ig_android_samsung_app_badging,ig_android_disk_usage,ig_android_business_promotion,ig_android_direct_swipe_to_inbox,ig_android_feed_reshare_button_nux,ig_android_react_native_boost_post,ig_android_boomerang_feed_attribution,ig_fbns_shared,ig_fbns_dump_ids,ig_android_react_native_universe,ig_show_promote_button_in_feed,ig_android_ad_metadata_behavior_universe,ig_android_video_loopcount_int,ig_android_inline_gallery_backoff_hours_universe,ig_android_rendering_controls,ig_android_profile_photo_as_media,ig_android_async_stack_image_cache,ig_video_max_duration_qe_preuniverse,ig_video_copyright_whitelist,ig_android_render_stories_with_content_override,ig_android_ad_intent_to_highlight_universe,ig_android_swipe_navigation_x_angle_universe,ig_android_disable_comment_public_test,ig_android_profile,ig_android_direct_blue_tab,ig_android_enable_share_to_messenger,ig_android_fetch_reel_tray_on_resume_universe,ig_android_promote_again,ig_feed_event_landing_page_channel,ig_ranking_following,ig_android_pending_request_search_bar,ig_android_feed_ufi_redesign,ig_android_pending_edits_dialog_universe,ig_android_business_conversion_flow_universe,ig_android_show_your_story_when_empty_universe,ig_android_ad_drop_cookie_early,ig_android_app_start_config,ig_android_fix_ise_two_phase,ig_android_ppage_toggle_universe,ig_android_pbia_normal_weight_universe,ig_android_profanity_filter,ig_ios_su_activity_feed,ig_android_search,ig_android_boomerang_entry,ig_android_mute_story,ig_android_inline_gallery_universe,ig_android_ad_remove_one_tap_indicator_universe,ig_android_view_count_decouple_likes_universe,ig_android_contact_button_redesign_v2,ig_android_periodic_analytics_upload_v2,ig_android_send_direct_typing_indicator,ig_android_ad_holdout_16h2m1_universe,ig_android_react_native_comment_moderation_settings,ig_video_use_sve_universe,ig_android_inline_gallery_no_backoff_on_launch_universe,ig_android_immersive_viewer,ig_android_discover_people_icon,ig_android_profile_follow_back_button,is_android_feed_seen_state,ig_android_dense_feed_unit_cards,ig_android_drafts_video_universe,ig_android_exoplayer,ig_android_add_to_last_post,ig_android_ad_remove_cta_chevron_universe,ig_android_ad_comment_cta_universe,ig_android_ad_chevron_universe,ig_android_ad_comment_cta_universe,ig_android_search_event_icon,ig_android_channels_home,ig_android_feed,ig_android_dv2_realtime_private_share,ig_android_non_square_first,ig_android_video_interleaved_v2,ig_android_video_cache_policy,ig_android_react_native_universe_kill_switch,ig_android_video_captions_universe,ig_android_follow_search_bar,ig_android_last_edits,ig_android_two_step_capture_flow,ig_android_video_download_logging,ig_android_share_link_to_whatsapp,ig_android_facebook_twitter_profile_photos,ig_android_swipeable_filters_blacklist,ig_android_ad_pbia_profile_tap_universe,ig_android_use_software_layer_for_kc_drawing_universe,ig_android_react_native_ota,ig_android_direct_mutually_exclusive_experiment_universe,ig_android_following_follower_social_context' LOGIN_EXPERIMENTS = 'ig_android_reg_login_btn_active_state,ig_android_ci_opt_in_at_reg,ig_android_one_click_in_old_flow,ig_android_merge_fb_and_ci_friends_page,ig_android_non_fb_sso,ig_android_mandatory_full_name,ig_android_reg_enable_login_password_btn,ig_android_reg_phone_email_active_state,ig_android_analytics_data_loss,ig_fbns_blocked,ig_android_contact_point_triage,ig_android_reg_next_btn_active_state,ig_android_prefill_phone_number,ig_android_show_fb_social_context_in_nux,ig_android_one_tap_login_upsell,ig_fbns_push,ig_android_phoneid_sync_interval' SIG_KEY_VERSION = '4' ANDROID_VERSION = 18 ANDROID_RELEASE = '4.3' + + diff --git a/InstagramAPI/src/Instagram.py b/InstagramAPI/src/Instagram.py index df547c7..a454317 100644 --- a/InstagramAPI/src/Instagram.py +++ b/InstagramAPI/src/Instagram.py @@ -67,7 +67,7 @@ def __init__(self, username, password, debug=False, IGDataPath=None, truncatedDe '' ) if not os.path.isdir(self.IGDataPath): - os.mkdir(self.IGDataPath, 0o777) + os.mkdir(self.IGDataPath, 0777) self.checkSettings(username) @@ -75,6 +75,46 @@ def __init__(self, username, password, debug=False, IGDataPath=None, truncatedDe self.setUser(username, password) + + def getUserLive(self): + """ + https://i.instagram.com/api/v1/live/ + Get user reels. + :return: User feed data + :raises: InstagramException + """ + # //feed/reels_tray/https://i.instagram.com/api/v1/ + + userFeed = self.http.request("feed/reels_tray/")[1] + + # ; + # "feed/live/")[1] + # "feed/user/"+str(usernameId)+"/reel_media/" + # + str(usernameId) + "/live/?rank_token=" + self.rank_token)[1] + + if userFeed['status'] != 'ok': + raise InstagramException(userFeed['message'] + "\n") + + return userFeed + + # Evil Funct + + def getUserStory(self, usernameId): + """ + + Get user story. + :type usernameId: str + :param usernameId: Username id + :return: User feed data + :raises: InstagramException + """ + userFeed = self.http.request("feed/user/" + str(usernameId) + "/story/?rank_token=" + self.rank_token)[1] + + if userFeed['status'] != 'ok': + raise InstagramException(userFeed['message'] + "\n") + + return userFeed + def setUser(self, username, password): """ Set the user. Manage multiple accounts. @@ -327,6 +367,8 @@ def getRankedRecipients(self): :rtype:list :return: Ranked recipients Data """ + print self.http.request('direct_v2/ranked_recipients/?show_threads=true') + ranked_recipients = RankedRecipientsResponse( self.http.request('direct_v2/ranked_recipients/?show_threads=true')[1] ) @@ -1166,18 +1208,18 @@ def getUserFeed(self, usernameId, maxid=None, minTimestamp=None): :return: User feed data :raises: InstagramException """ - userFeed = UserFeedResponse(self.http.request("feed/user/" + str(usernameId) + "/?rank_token=" + self.rank_token - + (("&max_id=" + str(maxid)) if maxid is not None else '') \ - + (("&min_timestamp=" + str( - minTimestamp)) if minTimestamp is not None else '') \ - + "&ranked_content=true" - )[1]) + userFeed = self.http.request("feed/user/" + str(usernameId) + "/?rank_token=" + self.rank_token + + (("&max_id=" + str(maxid)) if maxid is not None else '') \ + + (("&minTimestamp=" + str(minTimestamp)) if minTimestamp is not None else '') \ + + "&ranked_content=true" + )[1] - if not userFeed.isOk(): - raise InstagramException(userFeed.getMessage() + "\n") + if userFeed['status'] != 'ok': + raise InstagramException(userFeed['message'] + "\n") return userFeed + def getHashtagFeed(self, hashtagString, maxid=''): """ Get hashtag feed. diff --git a/InstagramAPI/src/http/Response/ExploreResponse.py b/InstagramAPI/src/http/Response/ExploreResponse.py index 3094a64..d1cb373 100644 --- a/InstagramAPI/src/http/Response/ExploreResponse.py +++ b/InstagramAPI/src/http/Response/ExploreResponse.py @@ -15,8 +15,10 @@ def __init__(self, response): self.num_results = response['num_results'] self.auto_load_more_enabled = response['auto_load_more_enabled'] self.more_available = response['more_available'] - self.next_max_id = response['next_max_id'] - self.max_id = response['max_id'] + if 'next_max_id' in response: + self.next_max_id = response['next_max_id'] + if 'max_id' in response: + self.max_id = response['max_id'] items = [] for item in response['items']: if 'media' in item and item['media']: diff --git a/InstagramAPI/src/http/Response/Objects/Item.py b/InstagramAPI/src/http/Response/Objects/Item.py index 2765c1c..c8585fa 100644 --- a/InstagramAPI/src/http/Response/Objects/Item.py +++ b/InstagramAPI/src/http/Response/Objects/Item.py @@ -64,8 +64,12 @@ def __init__(self, item): images.append(HdProfilePicUrlInfo(image)) self.image_versions2 = images - self.original_width = item['original_width'] - self.original_height = item['original_height'] + + if 'original_width' in item: + self.original_width = item['original_width'] + if 'original_height' in item: + self.original_height = item['original_height'] + if 'view_count' in item and item['view_count']: self.view_count = item['view_count'] diff --git a/InstagramAPI/src/http/Response/V2InboxResponse.py b/InstagramAPI/src/http/Response/V2InboxResponse.py index e17182d..a747dc5 100644 --- a/InstagramAPI/src/http/Response/V2InboxResponse.py +++ b/InstagramAPI/src/http/Response/V2InboxResponse.py @@ -9,16 +9,14 @@ def __init__(self, response): self.pending_requests_users = None self.inbox = None self.subscription = None - if self.STATUS_OK == response['status']: self.pending_requests_total = response['pending_requests_total'] self.seq_id = response['seq_id'] - self.pending_requests_users = response['pending_requests_users'] + #self.pending_requests_users = response['pending_requests_users'] self.inbox = Inbox(response['inbox']) - self.subscription = response['subscription'] + #self.subscription = response['subscription'] else: self.setMessage(response['message']) - self.setStatus(response['status']) def getPendingRequestsTotal(self): diff --git a/README.md b/README.md index c742412..16ca8d5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -*Please go through the [contribution guidelines](https://github.com/danleyb2/Instagram-API/blob/master/.github/CONTRIBUTING.md)*, +*Please go through the [contribution guidelines](https://github.com/danleyb2/Instagram-API/blob/master/.github/CONTRIBUTING.md)*, *just a translated Python implementation of this PHP [repository](https://github.com/mgp25/Instagram-API)* # ![logo](/examples/assets/instagram.png) Instagram Python [![License](https://poser.pugx.org/mgp25/instagram-php/license)](https://packagist.org/packages/mgp25/instagram-php) @@ -9,9 +9,9 @@ PYTHON [![Latest Stable Version](http://img.shields.io/pypi/v/instagram-python.s -This is Instagram's private API. It has all the features the Instagram app has, including media upload. +This is Instagram's private API. It has all the features the Instagram app has, including media upload. NEW -**Read the [wiki](https://github.com/danleyb2/Instagram-API/wiki)** and previous issues before opening a new one! Maybe your issue is already answered. +**Read the [wiki](https://github.com/danleyb2/Instagram-API/wiki)** and previous issues before opening a new one! Maybe your issue is already answered. **Wiki for the PHP code should be 90% applicable too because the code is just translated, not transformed** **Frequently Asked Questions:** [F.A.Q.](https://github.com/danleyb2/Instagram-API/wiki/FAQ) @@ -24,6 +24,8 @@ This is Instagram's private API. It has all the features the Instagram app has, ### PYPI +This is unofficial fork from danleyb2/Instagram-API + ```sh pip install instagram-python ``` @@ -37,7 +39,13 @@ instagram = Instagram(); If you want to test code that is in the master branch, which hasn't been pushed as a release, you can use Github. ```sh -pip install https://github.com/danleyb2/Instagram-API/archive/master.zip +pip install https://github.com/EvilTatur/Instagram-API/archive/master.zip +``` + +for upgrade: + +```sh +pip install https://github.com/EvilTatur/Instagram-API/archive/master.zip --upgrade ``` ## Examples @@ -45,9 +53,9 @@ pip install https://github.com/danleyb2/Instagram-API/archive/master.zip All examples can be found [here](https://github.com/danleyb2/Instagram-API/tree/master/examples) ## Why did i do the API? -For me, -*i love writing code*, -for him +For me, +*i love writing code*, +for him *After legal measures, Facebook, WhatsApp and Instagram blocked my accounts. In order to use Instagram on my phone i needed a new phone, as they banned my UDID, so that is basically why i made this API.*