Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot detect post media type. skip #6243

Closed
MohakAoki opened this issue Jun 23, 2021 · 14 comments · Fixed by #6202 or #6346 · May be fixed by #6340
Closed

Cannot detect post media type. skip #6243

MohakAoki opened this issue Jun 23, 2021 · 14 comments · Fixed by #6202 or #6346 · May be fixed by #6340

Comments

@MohakAoki
Copy link

Hi.
Im working on windows and python 3.9 and latest instapy version.
my code:

from instapy import InstaPy

session = InstaPy(username="", password="")
session.login()
session.like_by_tags(["tag"], amount=1)

@Lrnvrybthksa
Copy link

try using

with smart_run(session):

instead of session.login()

@kabelklaus
Copy link

I have the same problem. I use smart_run. That's not the problem. I read, you must change everything in the like_util.py

@Desantnikov
Copy link

@kharazian
Copy link

kharazian commented Oct 3, 2021

It has solved, how ever it is appear recently again.
#6277 (comment)
could you plz check it again and help me to find out the problem.
thanks

@MohakAoki
Copy link
Author

It has solved, how ever it is appear recently again. #6277 (comment) could you plz check it again and help me to find out the problem. thanks

Sorry but i finished the project. i have no access to it right now.

@kharazian
Copy link

some instapy\like_util.py could change the problem. The class of the line 866 should change fro u7YqG to CzVzU

                if len(post_elem) == 2:
                    # Carousel or Video
                    post_category = element.find_element_by_xpath(
                        "//a[@href='/p/"
                        + post_href.split("/")[-2]
                        + "/']/child::div[@class='CzVzU']/child::div/*[name()='svg']"
                    ).get_attribute("aria-label")

@dannyarcher
Copy link

@MohakAoki @kharazian removing the class pedicate also works #6340

@fiederich12345
Copy link

Hey everyone,
I'm still not able to get InstaPy to work, I'm still getting this 'Cannot detect post media type' error. I have a very basic code setup that shall just like some posts based on a hashtag.

I've tried what you suggested in this forum post:

-Installed instapy using pip3
-copied the instapy folder to the location where I have my python script (I run Jupyter Notebook)
-Changed the line that @kharazian suggested (from u7YqG to CzVzU)
-I run the following code:


from instapy import InstaPy
from time import sleep
session = InstaPy(username="XXX", password="XXX")
sleep(7)
session.login()
session.like_by_tags(['xxx_hashtag'], amount=5, media='Video')


-I then accept 'All cookies' once Firefox opens
-In firefox, instagram then goes to my profile first, then to the first hashtag page, but stops there. This is when the error "Cannot detect post media type" shows up in Jupyter and the post, just like any further posts, are skipped.

I'm on Catalina 10.15.6 - thankful for any help..

@dannyarcher
Copy link

Try #6340

@fiederich12345
Copy link

Thanks, I've tried #6340 but it still didn't work. Here's a screenshot:
Screenshot 2021-10-08 at 13 27 31
:

@kharazian
Copy link

Thanks, I've tried #6340 but it still didn't work. Here's a screenshot: Screenshot 2021-10-08 at 13 27 31 :

what is your code? your hashtags? do you test there are reachable manually?

@dannyarcher
Copy link

@kharazian @fiederich12345 Did your browser openduring these sessions?

@fiederich12345
Copy link

Hello again,
thanks for your quick help, I actually got it to work now. Something seemed to be wrong with that hashtag, it now indeed works with a different hashtag. No idea why..

In case it doesn't work for you and you want a test hashtag that worked for me, try this:
session.like_by_tags(['funnyvideos'], amount=5, media='Video')

Best!

@elulcao
Copy link
Collaborator

elulcao commented Oct 11, 2021

The xpath has been updated, IG can do this all the time,
New formats has been added also, not only photos or carousel,

post_category = element.find_element_by_xpath(
                            "//a[@href='/p/"
                            + post_href.split("/")[-2]
                            + "/']/child::div[@class='u7YqG']/child::div/*[name()='svg']"
                        ).get_attribute("aria-label")

after fixing the xpath we should see something like:

INFO [2021-10-10 22:48:44] [internet]  Getting billie.vibes image list...
INFO [2021-10-10 22:49:12] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:12] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:12] [internet]  Post category: Video
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Video
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Video
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Video
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Carousel
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Carousel
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Video
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Video
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Carousel or Video
INFO [2021-10-10 22:49:13] [internet]  Post category: Clip
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Verifying media type: ['Photo', 'Carousel']
INFO [2021-10-10 22:49:13] [internet]  Found media type: Photo
INFO [2021-10-10 22:49:13] [internet]  Post [1/5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment