Closed NicoRulli closed 1 year ago
What is in uploadPath
and caption
? show a full example so i can reproduce it
upload path is just where the file is stored. And caption is just a string to get posted along with the clip.
downloadPath = "/Users/Shared/InstagramAutomated/downloadedPosts"
uploadPath = downloadPath + "/" + files[1]
caption = f"Check out this post by {poster}! \nTag your Friends and comment below! \n . \n . \n . \n . \n . \n . \n . \n . \n #billfish #bluemarlin #sailfish #centerconsole #simrad #furuno #sailfishing #fishing #gamefish #sportfishing #pelagicgirl #pelagicworldwide #fishingteam #tuna #bluefin #jigging #trolling #offshore #swordfish #panamafishing #spearfishing #bahamasfishing #catchandcook #saltlife #catchoftheday #pescasub #floridawildlife #floridakeys"
What is files[1]
? what file format? what size is it? send me a link so I can download it
It isn't working with any clip I give it. files[1] just gets the first thing in the folder. I just noticed above the traceback there are these printouts: Analyzing CLIP file "/Users/Shared/InstagramAutomated/downloadedPosts/bviral_3130934838894907221.mp4" Generating thumbnail "/Users/Shared/InstagramAutomated/downloadedPosts/bviral_3130934838894907221.mp4.jpg"...
I believe the thumbnail is the issue? is .mp4.jpg a thing?
Maybe I don't know, print out your files[1]
and understand what you are passing
files[1] is the file name. below are printouts and the results: print(uploadPath) print(files[1])
/Users/Shared/InstagramAutomated/downloadedPosts/david_lassley_3070250373240527167.mp4 david_lassley_3070250373240527167.mp4
The inputs for the clip_upload function I am giving are file path, and caption. therefore to get upload path I am taking the download path, adding a / and adding the filename.
I checked on your media "david_lassley - 3070250373240527167" and everything works fine, there are no bugs in instagrapi, read the documentation and understand your logic in code
>>> m = cl.media_info_v1(3070250373240527167)
>>> m.video_url
HttpUrl('https://scontent-fra3-1.cdninstagram.com/o1/v/t16/f1/m82/5F4B7CF98D40545273D8CE04923C6997_video_dashinit.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5jbGlwcy5iYXNlbGluZSJ9&_nc_ht=scontent-fra3-1.cdninstagram.com&_nc_cat=103&vs=746381633688636_1854852436&_nc_vs=HBksFQIYT2lnX3hwdl9yZWVsc19wZXJtYW5lbnRfcHJvZC81RjRCN0NGOThENDA1NDUyNzNEOENFMDQ5MjNDNjk5N192aWRlb19kYXNoaW5pdC5tcDQVAALIAQAVABgkR09sUU1SUXVWSmtmSEQwWkFGUkJpLUpwc0hGSWJxX0VBQUFGFQICyAEAKAAYABsAFQAAJtC8rKCRqu4%2FFQIoAkMzLBdANV2yLQ5WBBgSZGFzaF9iYXNlbGluZV8xX3YxEQB1%2FgcA&_nc_rid=e4f8792553&ccb=9-4&oh=00_AfDL36hsXo4QdS-Am8sLM-hF-72WfQQHAD5o5O2MzDzWBw&oe=64BFF91D&_nc_sid=fc8dfb', )
>>> p = cl.video_download_by_url(m.video_url)
PosixPath('/home/adw0rd/instagrapi/5F4B7CF98D40545273D8CE04923C6997_video_dashinit.mp4')
>>> cl.clip_upload(p, "TEST")
Analyzing CLIP file "/home/adw0rd/instagrapi/5F4B7CF98D40545273D8CE04923C6997_video_dashinit.mp4"
Generating thumbnail "/home/adw0rd/instagrapi/5F4B7CF98D40545273D8CE04923C6997_video_dashinit.mp4.jpg"...
Media(pk='3153884565907717291', id='3153884565907717291_60682366263', code='CvE2U19hDyr', taken_at=datetime.datetime(2023, 7, 24, 9, 52, 56, tzinfo=datetime.timezone.utc), media_type=2, ....
I am using the function 'clip_upload' correctly as I am giving it a path and caption but it isn't uploading therefore there is likely an issue. I will attempt to re-code my project to work the way you did it.
Here is my new code to download and upload in the way that you have it:
media_type = cl.media_info(Mlpk).dict()['media_type']
product_type = cl.media_info(Mlpk).dict()['product_type']
m = cl.media_info(Mlpk)
url = m.video_url
downloadPath = "/Users/Shared/InstagramAutomated/downloadedPosts"
print("media type: " + str(media_type)) print("Attempting to download...")
if media_type == 1: #picture
p = cl.photo_download_by_url(m.video_url)
if media_type == 2 and product_type == 'clips': p = cl.clip_download_by_url(m.video_url) #Reel
if media_type == 2 and product_type == 'feed': #Video
p = cl.video_download_by_url(m.video_url)
if media_type == 2 and product_type == 'igtv': #IGTV
p = cl.igtv_download_by_url(m.video_url)
if media_type == 8: #Album
p = cl.album_download(url,downloadPath)
poster = "@" + str(cl.media_user(Mlpk).dict()['username']) location = cl.media_info(Mlpk).dict()['location']
if location != None: location = str(location['name']) caption = "Check out this post by " + poster + " out near " + location + "! \nTag your Friends and comment below! \n . \n . \n . \n . \n . \n . \n . \n . \n #billfish #bluemarlin #sailfish #centerconsole #simrad #furuno #sailfishing #fishing #gamefish #sportfishing #pelagicgirl #pelagicworldwide #fishingteam #tuna #bluefin #jigging #trolling #offshore #swordfish #panamafishing #spearfishing #bahamasfishing #catchandcook #saltlife #catchoftheday #pescasub #floridawildlife #floridakeys"
else: caption = f"Check out this post by {poster}! \nTag your Friends and comment below! \n . \n . \n . \n . \n . \n . \n . \n . \n #billfish #bluemarlin #sailfish #centerconsole #simrad #furuno #sailfishing #fishing #gamefish #sportfishing #pelagicgirl #pelagicworldwide #fishingteam #tuna #bluefin #jigging #trolling #offshore #swordfish #panamafishing #spearfishing #bahamasfishing #catchandcook #saltlife #catchoftheday #pescasub #floridawildlife #floridakeys"
files = os.listdir(downloadPath) print() print("Attempting to Upload...")
if media_type == 1: #picture cl.photo_upload(p, caption)
if media_type == 2 and product_type == 'clips': #Reel cl.clip_upload(p, caption)
if media_type == 2 and product_type == 'feed': #Video cl.video_upload(p, caption)
if media_type == 2 and product_type == 'igtv': #IGTV cl.igtv_upload(p, caption)
if media_type == 8: #Album cl.album_upload(p, caption)
and here is the exact traceback:
Analyzing CLIP file "/Users/Shared/InstagramAutomated/163282740_1206051646680168_5382345465419626433_n.mp4"
Generating thumbnail "/Users/Shared/InstagramAutomated/163282740_1206051646680168_5382345465419626433_n.mp4.jpg"...
Traceback (most recent call last):
File "/Users/Shared/InstagramAutomated/file2.py", line 234, in
I am getting the same error.
Can you tell me why this is happening? it is downloading fine but the upload is the issue. I am giving it the path the way you gave it and the caption is a string. I don't know why this isn't working considering I am essentially copying your code.
start from simple to complex, this is basic knowledge in programming
first use my code as it works i tested on myself
then add your logic until you hit the problem
I just posted to the still-open post with 11 lines of code that doesn't work. lets chat there and find the issue out.
I am trying to upload a reel and I am getting the error instagrapi.exceptions.ClipNotUpload: Unknown ({'response': None})
To Reproduce if media_type == 2 and product_type == 'clips': #Reel cl.clip_upload(uploadPath, caption)
Traceback Traceback (most recent call last): File "/Users/Shared/InstagramAutomated/file2.py", line 223, in
cl.clip_upload(uploadPath, caption)
File "/Users/nicolasrulli/Library/Python/3.9/lib/python/site-packages/instagrapi/mixins/clip.py", line 144, in clip_upload
raise ClipNotUpload(response=self.last_response, **self.last_json)
instagrapi.exceptions.ClipNotUpload: Unknown ({'response': None})
Can someone explain what the issue is? I am downloading a clip from instagram and trying to upload it to my own account.