question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when uploading video - "AttributeError: 'NoneType' object has no attribute 'extension'"

See original GitHub issue

I cloned the repo and tried to run the example “upload-a-video.py”:

from instapy_cli import client
  
username = 'xxxxx'
password = 'xxxxx'
video = '../docs/video-sample-upload.mp4'
text = 'This will be the caption of your video.' + '\r\n' + 'You can also use hashtags! #hash #tag #now'

with client(username, password) as cli:
    cli.upload(video, text)

But I got an error in the console that said:

Reusing settings: ig.json
Traceback (most recent call last):
  File "upload-a-video.py", line 9, in <module>
    cli.upload(video, text)
  File "/Library/Python/2.7/site-packages/instapy_cli/cli.py", line 105, in upload
    media = Media(file)
  File "/Library/Python/2.7/site-packages/instapy_cli/media.py", line 29, in __init__
    self.check_type()
  File "/Library/Python/2.7/site-packages/instapy_cli/media.py", line 32, in check_type
    self.media_ext = filetype.guess(self.media_path).extension
AttributeError: 'NoneType' object has no attribute 'extension'

Any idea what I’m doing wrong?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
salahar9commented, Jul 18, 2019

@b3nab i have the solution, the issue’s origin is actually the filetype library and specifically this line at media.py self.media_ext = filetype.guess(self.media_path).extension filetype is returning None on some videos so to fix it you can use Magic instead of filetype PyPi: https://pypi.org/project/python-magic-bin/0.4.14/ or Pip: pip install python-magic-bin so now in the media.py first : import magic
then change the check_type function to this: `def check_type(self):

    self.media_ext = magic.from_file(self.media_path,mime=True)
    self.media_ext=  self.media_ext.split('/')[1]` 
0reactions
keenan14commented, Dec 30, 2019

Hey guys I have been having the same issue my code was: from instapy_cli import client

username = ‘testing211714’ password = ‘****’ image = ‘posts/keenan.png’ text = ‘This will be the caption of your photo.’ + ‘\r\n’ + ‘You can also use hashtags! #hash #tag #now’

with client(username, password) as cli: cli.upload(image, text)`

But recieved the error: (env) Ryans-MacBook-Pro:InstaAutomaterFirstTry ryankeenan$ python app.py [IG] not found cookie/cookie_file >> login as default Error parsing error response: Expecting value: line 1 column 1 (char 0) Error is >> Bad Request

Something went bad. Please retry or send an issue on https://github.com/b3nab/instapy-cli

Traceback (most recent call last): File “app.py”, line 9, in <module> cli.upload(image, text) File “/Users/ryankeenan/Desktop/git/InstaAutomaterFirstTry/env/lib/python3.7/site-packages/instapy_cli/cli.py”, line 153, in upload raise IOError(“Unable to upload.”) OSError: Unable to upload.

I followed @salahar9 advice and imported magic at media.py but the error just changed to: (env) Ryans-MacBook-Pro:InstaAutomaterFirstTry ryankeenan$ python app.py [IG] not found cookie/cookie_file >> login as default Error parsing error response: Expecting value: line 1 column 1 (char 0) Error is >> Bad Request

Something went bad. Please retry or send an issue on https://github.com/b3nab/instapy-cli

Traceback (most recent call last): File “app.py”, line 10, in <module> cli.upload(image, text) File “/Users/ryankeenan/Desktop/git/InstaAutomaterFirstTry/env/lib/python3.7/site-packages/instapy_cli/cli.py”, line 153, in upload raise IOError(“Unable to upload.”) OSError: Unable to upload. Does anyone see where I went wrong??

Read more comments on GitHub >

github_iconTop Results From Across the Web

"AttributeError: 'NoneType' object has no attribute 'extension ...
I cloned the repo and tried to run the example "upload-a-video.py": from instapy_cli import client username = 'xxxxx' password = 'xxxxx' video =...
Read more >
Instagram with instapy_cli: how to fix an error
Error when uploading video – “AttributeError: 'NoneType' object has no attribute 'extension'”. so I searched in the issues forum of ...
Read more >
Why do I get AttributeError: 'NoneType' object has no attribute ...
NoneType means that instead of an instance of whatever Class or Object you think you're working with, you've actually got None .
Read more >
[FIXED] AttributeError: 'NoneType' object has no attribute ...
Hence, AttributeError: 'NoneType' object has no attribute 'something' error occurs when the type of object you are referencing is None.
Read more >
AttributeError: 'NoneType' object has no attribute 'copy'
It sounds like cv2.imread() is expecting uploaded_file to be a string (the name of a file), but it's actually an object. It doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found