Skip to content

Commit 6ecef53

Browse files
committed
solve issue #85 TypeError: slice indices must be integers or None or have an __index__ method
1 parent f5a5f3f commit 6ecef53

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

InstagramAPI.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ def uploadVideo(self, video, thumbnail, caption = None, upload_id = None):
170170
upload_job = body['video_upload_urls'][3]['job']
171171

172172
videoData = open(video, 'rb').read()
173-
request_size = math.floor(len(videoData) / 4)
173+
#solve issue #85 TypeError: slice indices must be integers or None or have an __index__ method
174+
request_size = int(math.floor(len(videoData) / 4))
174175
lastRequestExtra = (len(videoData) - (request_size * 3))
175176

176177
headers = copy.deepcopy(self.s.headers)

test_video.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Use text editor to edit the script and type in valid Instagram username/password
5+
6+
from InstagramAPI import InstagramAPI
7+
import urllib
8+
video_url = 'https://instagram.fmad3-2.fna.fbcdn.net/t50.2886-16/17157217_1660580944235536_866261046376005632_n.mp4' #a valid instagram video
9+
video_local_path = video_url.split("/")[-1]
10+
thumbnail_url = "https://instagram.fmad3-2.fna.fbcdn.net/t51.2885-15/e15/17075853_1759410394387536_3927726791665385472_n.jpg"
11+
thumbnail_local_path = thumbnail_url.split("/")[-1]
12+
13+
urllib.urlretrieve(video_url,video_local_path)
14+
urllib.urlretrieve(thumbnail_url,thumbnail_local_path)
15+
16+
user,pwd = 'user', 'password'
17+
18+
InstagramAPI = InstagramAPI(user,pwd)
19+
InstagramAPI.login() # login
20+
InstagramAPI.uploadVideo(video_local_path,thumbnail_local_path,caption="Tortuguero")

0 commit comments

Comments
 (0)