From 6ecef5366d6441d342869bb0ff0b12fa63233125 Mon Sep 17 00:00:00 2001 From: xecgr Date: Wed, 8 Mar 2017 13:09:56 +0100 Subject: [PATCH] solve issue #85 TypeError: slice indices must be integers or None or have an __index__ method --- InstagramAPI.py | 3 ++- test_video.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test_video.py diff --git a/InstagramAPI.py b/InstagramAPI.py index 4efe24e..0360a0e 100644 --- a/InstagramAPI.py +++ b/InstagramAPI.py @@ -170,7 +170,8 @@ def uploadVideo(self, video, thumbnail, caption = None, upload_id = None): upload_job = body['video_upload_urls'][3]['job'] videoData = open(video, 'rb').read() - request_size = math.floor(len(videoData) / 4) + #solve issue #85 TypeError: slice indices must be integers or None or have an __index__ method + request_size = int(math.floor(len(videoData) / 4)) lastRequestExtra = (len(videoData) - (request_size * 3)) headers = copy.deepcopy(self.s.headers) diff --git a/test_video.py b/test_video.py new file mode 100644 index 0000000..d70aad3 --- /dev/null +++ b/test_video.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Use text editor to edit the script and type in valid Instagram username/password + +from InstagramAPI import InstagramAPI +import urllib +video_url = 'https://instagram.fmad3-2.fna.fbcdn.net/t50.2886-16/17157217_1660580944235536_866261046376005632_n.mp4' #a valid instagram video +video_local_path = video_url.split("/")[-1] +thumbnail_url = "https://instagram.fmad3-2.fna.fbcdn.net/t51.2885-15/e15/17075853_1759410394387536_3927726791665385472_n.jpg" +thumbnail_local_path = thumbnail_url.split("/")[-1] + +urllib.urlretrieve(video_url,video_local_path) +urllib.urlretrieve(thumbnail_url,thumbnail_local_path) + +user,pwd = 'user', 'password' + +InstagramAPI = InstagramAPI(user,pwd) +InstagramAPI.login() # login +InstagramAPI.uploadVideo(video_local_path,thumbnail_local_path,caption="Tortuguero")