diff --git a/instapy_cli/cli.py b/instapy_cli/cli.py index d80382e..0bb6a10 100644 --- a/instapy_cli/cli.py +++ b/instapy_cli/cli.py @@ -138,9 +138,10 @@ def upload(self, file, caption='', story=False): except Exception as e: - print('Error is >>\n ' + str(e)) - print('\nSomething went bad.\nPlease retry or send an issue on https://github.com/b3nab/instapy-cli\n') + # print('Error is >>\n ' + str(e)) + # print('\nSomething went bad.\nPlease retry or send an issue on https://github.com/b3nab/instapy-cli\n') upload_completed = False + raise IOError(str(e), '\nSomething went bad.\nPlease retry or send an issue on https://github.com/b3nab/instapy-cli\n') finally: # media_status = 'YES' if media.isDownloaded() else 'NO' diff --git a/instapy_cli/media.py b/instapy_cli/media.py index 48df57d..1925920 100644 --- a/instapy_cli/media.py +++ b/instapy_cli/media.py @@ -25,15 +25,20 @@ def __init__(self, file, ratio='post'): # if file is a local file else: self.media_path = file - + self.check_type() - + def check_type(self): - self.media_ext = filetype.guess(self.media_path).extension - + ext = filetype.guess(self.media_path) + if None is self.media_ext: + absolute_path = os.path.abspath(self.media_path) + self.media_ext = os.path.splitext(absolute_path)[-1].replace(".", "") + else: + self.media_ext = ext.extension + def is_image(self): return True if self.media_ext in ['jpg', 'png', 'gif'] else False - + def is_video(self): return True if self.media_ext in ['mp4', 'mov', 'avi'] else False