ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.69k stars 1.47k forks source link

TypeError: upload_photo() missing 1 required positional argument: 'photo' #1204

Open KTK27YT opened 4 years ago

KTK27YT commented 4 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Purpose of your issue?


The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here: Python 3.8.0 Code:

`import os
import time
import random
from random import randint
from os import listdir
from os.path import isfile,join
from instabot import Bot
import instabot
import csv
import moviepy
from instabot import API
with open("db.csv","r", newline="") as f:
    reader = csv.reader(f)
    for line in reader:
        PhotoPath = line[4]
        Title = line[0]
        Author = line[1]
        Ups = line[2]
        subreddit = line[3]
        IGCaption = "Nice"
        print(IGCaption)
        print("Uploading a file via instabot....")
        photo = str(PhotoPath)
        print(photo)
        upload=API.upload_photo(PhotoPath,caption=IGCaption,force_resize=True,upload_id=None,from_video=False)`

Error/Debug Log:

2020-01-05 19:13:01,553 - INFO - Instabot Started
Nice
Uploading a file via instabot....
C:\Users\MYUSER\Desktop\Reddit-bot\Cache\gaming\The_siblings_from_Bioshock_Infinite.jpeg
Traceback (most recent call last):
  File "c:/Users/MYUSERDesktop/Reddit-bot/instagram.py", line 29, in <module>
    upload = API.upload_photo(PhotoPath,caption=IGCaption,force_resize=True,upload_id=None,from_video=False)
TypeError: upload_photo() missing 1 required positional argument: 'photo'
2020-01-05 19:13:03,614 - INFO - Total requests: 21

Describe your issue

I used bot.upload_photo() it works but i need the photo to be auto resized so it will be uploaded no matter what thats why i used the API import for it

fighterii commented 4 years ago

Thats not how object orientated programming works.

The first argument of upload_photo is self, second one is photo. So you definitely need an instance of class API (not the class itself).

I would recommend to initiate an instance of Bot and use this (as in the examples)

bot = Bot()
bot.api.upload_photo(PhotoPath,caption=IGCaption,force_resize=True,upload_id=None,from_video=False)

Uses the instance of API created within Bot.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.