stanvanrooy / instauto

Simple to use wrapper around the private Instagram API, written in Python.
https://instauto.readthedocs.io
MIT License
104 stars 24 forks source link

Post upload response returning Success: False #64

Closed Ethan0429 closed 4 years ago

Ethan0429 commented 4 years ago

Describe the bug Tested with both file types (.jpg and .mp4) and using the latest version of Instauto, I cannot get a post to upload from my account. from

final_post = ps.Post.create(
    path=post,
    source_type=st.WhereToPost.Feed,
    caption=my_caption
)

resp = client.post_post(final_post)
print("Success: ", resp.ok)

I get

Success:  False

path='PATH TO POSTS/posts/post.jpg' caption='test' (for clarity)

I get no errors of any kind, but I've tried multiple different files--each either .jpg or .mp4--but still the same result. Is there anyway to know what I'm doing wrong?

Expected behavior Successul post

marvic2409 commented 4 years ago

Add

import logging
logging.basicConfig()
logging.getLogger('').setLevel(logging.DEBUG)

To the beginning of your code and then post the full log here (Remove your username/password)

CombatCode commented 4 years ago

@marvic2409 here is the log

INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): i.instagram.com
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "POST /rupload_igphoto/1601745701.2885697_0_1520766894 HTTP/1.1" 400 103
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/rupload_igphoto/1601745701.2885697_0_1520766894, method: POST with data: 
 b'\x89PNG\r\n << CUTTED IMAGE >>'
HEADERS: 
{'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '1533kbps', 'x-ig-bandwidth-speed-kbps': '3833.970', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': 'e9ccf31d-5415-49e0-87e5-6c17b7de7b07', 'x-ig-android-id': 'android-541549e087e56c17', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X3iq5AABAAE2zjY8lMGOUfwwJxms', 'ig-u-rur': 'FRC', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:eyJkc191c2VyX2lkIjoiMjc2MDk3NTMwMzIiLCJzZXNzaW9uaWQiOiIyNzYwOTc1MzAzMiUzQUJNU2NjNU9UNGhnVkc4JTNBMiIsInNob3VsZF91c2VfaGVhZGVyX292ZXJfY29va2llcyI6ZmFsc2V9', 'connection': 'close', 'x-pigeon-session-id': 'b879a1ac-773d-447d-8eab-6341d66be14f', 'x-pigeon-rawclienttime': '1601745701.291', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com', 'x-fb-photo-waterfall-id': '35e9ec17-5eda-4c23-8ecb-78fc30666aa8', 'x-entity-length': '674855', 'x-entity-name': '1601745701.2885697_0_1520766894', 'x-instagram-rupload-params': '
{"upload_id": "1601745701.2885697", "media_type": 1, "retry_context": "
{\\"num_reupload\\": 0, \\"num_step_auto_retry\\": 0, \\"num_step_manual_retry\\": 0}", "xsharing_user_ids": "[]", "image_compression": "
{\\"lib_name\\": \\"moz\\", \\"lib_version\\": \\"3.1.m\\", \\"quality\\": \\"80\\"}"}', 'x-entity-type': 'image//tmp_sc', 'offset': '0', 'scene_capture_type': 'standard', 'creation_logger_session_id': 'e84e2ab5-9921-4751-b97e-1a957ebf53e5', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
RESPONSE: b'
{"debug_info":
{"retriable":false,"type":"ProcessingFailedError","message":"Request processing failed"}}'
******************** END REQUEST ********************
DEBUG:urllib3.connectionpool:Resetting dropped connection: i.instagram.com
DEBUG:urllib3.connectionpool:https://i.instagram.com:443 "POST /api/v1/media/configure/ HTTP/1.1" 400 46
DEBUG:instauto.api.actions.request:Sent request to https://i.instagram.com/api/v1/media/configure/, method: POST with data: 

 {'ig_sig_key_version': '4', 'signed_body': 'SIGNATURE.
 {"scene_capture_type": "", "timezone_offset": "0", "media_folder": "Pictures", "source_type": "4", "device_id": "e9ccf31d-5415-49e0-87e5-6c17b7de7b07", "caption": "This is an example. Follow me!", "upload_id": "1601745701.2885697", "suggested_venue_position": -1, "device": 
 {"manufacturer": "samsung", "model": "beyond1", "android_version": 29, "android_release": "10"}, "edits": 
 {"crop_original_size": [722, 1052], "crop_center": [0.0, 0.0], "crop_zoom": 1.0}, "extra": 
 {"source_width": 722, "source_height": 1052}, "is_suggested_venue": false, "multi_sharing": "-1", "_uid": "27609753032", "_uuid": "2cfb9ee8-1420-4e2e-abd2-6f36823405e2", "_csrftoken": "pVtnSR51QAKxvg6KUG8Lf2V1tcr9h1Sw"}'}
DEBUG:instauto.api.actions.request:******************** START REQUEST ********************
METHOD: POST
URL: https://i.instagram.com/api/v1/media/configure/
DATA: 
{'ig_sig_key_version': '4', 'signed_body': 'SIGNATURE.
{"scene_capture_type": "", "timezone_offset": "0", "media_folder": "Pictures", "source_type": "4", "device_id": "e9ccf31d-5415-49e0-87e5-6c17b7de7b07", "caption": "This is an example. Follow me!", "upload_id": "1601745701.2885697", "suggested_venue_position": -1, "device": 
{"manufacturer": "samsung", "model": "beyond1", "android_version": 29, "android_release": "10"}, "edits": 
{"crop_original_size": [722, 1052], "crop_center": [0.0, 0.0], "crop_zoom": 1.0}, "extra": 
{"source_width": 722, "source_height": 1052}, "is_suggested_venue": false, "multi_sharing": "-1", "_uid": "27609753032", "_uuid": "2cfb9ee8-1420-4e2e-abd2-6f36823405e2", "_csrftoken": "pVtnSR51QAKxvg6KUG8Lf2V1tcr9h1Sw"}'}
HEADERS: 
{'x-cm-bandwidth-kbps': '-1.000', 'x-cm-latency': '-1.000', 'x-ads-opt-out': '0', 'x-ig-app-locale': 'nl_NL', 'x-ig-app-startup-country': 'NL', 'x-ig-device-locale': 'nl_NL', 'x-ig-mapped-locale': 'nl_NL', 'x-ig-connection-speed': '2643kbps', 'x-ig-bandwidth-speed-kbps': '1865.416', 'x-ig-bandwidth-totalbytes-b': '0', 'x-ig-bandwidth-totaltime-ms': '0', 'x-ig-www-claim': '0', 'x-ig-device-id': 'e9ccf31d-5415-49e0-87e5-6c17b7de7b07', 'x-ig-android-id': 'android-541549e087e56c17', 'x-ig-connection-type': 'WIFI', 'x-ig-capabilities': '3brTvw8=', 'x-ig-app-id': '567067343352427', 'user-agent': 'Instagram 148.0.0.33.121 Android (29/10; 560dpi; 1440x2891; samsung; SM-973F; SM-973F; exynos9820; nl_NL; 227298996)', 'accept-language': 'nl_NL, en_US', 'x-mid': 'X3iq5AABAAE2zjY8lMGOUfwwJxms', 'ig-u-rur': 'FRC', 'accept-encoding': 'gzip', 'x-fb-http-engine': 'Liger', 'authorization': 'Bearer IGT:2:eyJkc191c2VyX2lkIjoiMjc2MDk3NTMwMzIiLCJzZXNzaW9uaWQiOiIyNzYwOTc1MzAzMiUzQUJNU2NjNU9UNGhnVkc4JTNBMiIsInNob3VsZF91c2VfaGVhZGVyX292ZXJfY29va2llcyI6ZmFsc2V9', 'connection': 'close', 'x-pigeon-session-id': 'b879a1ac-773d-447d-8eab-6341d66be14f', 'x-pigeon-rawclienttime': '1601745702.66', 'x-bloks-version-id': '5da07fc1b20eb4c7d1b2e6146ee5f197072cbbd193d2d1eb3bb4e825d3c39e28', 'x-bloks-is-layout-rtl': 'False', 'host': 'i.instagram.com', 'retry_context': '
{"num_reupload": 0, "num_step_auto_retry": 0, "num_step_manual_retry": 0}', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
RESPONSE: b'
{"message": "Missing info.", "status": "fail"}'
******************** END REQUEST ********************
marvic2409 commented 4 years ago

Hmm, comparing your output to mine it looks like the only difference is that your image type is "tmp_sc" while mine is "jpeg". Maybe try re-encoding your image to a jpeg format. Also remember that Instagram has strict rules on the dimensions of an image that you can upload. Here is the help page on image dimensions https://ey.workplace.com/help/instagram/1631821640426723. In addition, if this doesn't fix your issue, could you include the code that is returned by the image (You can post the log file here)

CombatCode commented 4 years ago

@marvic2409 bingo, previously I was testing two images but third one works fine

CombatCode commented 4 years ago

so png images gives issue like this one

marvic2409 commented 4 years ago

A possible solution code-wise to this would be to include an image formatting mechanism to make it compatible with Instagram. I will communicate with stanvanrooy on this, but for now it seems that you will need to format the images as a jpeg with dimensions which are supported.

stanvanrooy commented 4 years ago

Good find. Converting the image in instauto isn't the solution.

If the Instagram API indeed only accepts jpegs, we should make instauto also only accepts jpegs.

I'll try uploading a png to Instagram using the app and see how it is handled.

marvic2409 commented 4 years ago

Yeah I just tried it and it looks like it just converts it to a jpeg with a background of whatever your current theme is.

stanvanrooy commented 4 years ago

Okay, thanks. Then we should just raise an exception when someone tries uploading a PNG with instauto.

Let them take care of converting it, that's out of scope for instauto.