nickpettican / InstaBot

:robot: Automate your Instagram activity with InstaBot, a customisable bot that likes, follows and comments
Apache License 2.0
221 stars 51 forks source link

Problems loading JSON #2

Closed iflybrains closed 7 years ago

iflybrains commented 7 years ago

I have to say I'm pretty new to python but crawling through the code and usage.

When I run the script I get "could not open config file" But it's all there in the root folder.

What am I missing? couldn't find the answer in google :)

thanks a lot!

nickpettican commented 7 years ago

Thanks for the feedback @iflybrains, the problem is in the JSON object itself.

Make sure you use double quotes "" for each of the parameters, boolean values must be lower case (true or false) and include a comma after each line except for the last one. Further info on JSON here: https://www.w3schools.com/js/js_json_syntax.asp

To test if you have the right syntax you could write a small script like this:

import json

path = 'config.json'
raw = [line.strip() for line in open(path, 'r')]
config = json.loads(''.join(raw))
print json.dumps(config, indent=3)

And try until it works properly.

Also bear with me, there are still a few bugs that need to be fixed for it to work optimally.

iflybrains commented 7 years ago

Thanks for the reply! I'm learning a lot by trying and reading the script. Bugs don't bother me :)

Found out that textedit on the Mac uses different " -> thats why it didn't load the config. Now it loads the config but I get this:

--- InstaBot V 1.0.2 by nickpettican ---
--- Automate your Instagram activity ---

Traceback (most recent call last): File "/Users/martijnkort/Desktop/InstaBot-master/run.py", line 52, in main() File "/Users/martijnkort/Desktop/InstaBot-master/run.py", line 46, in main instabot = InstaBot(profile, data = data) File "/Users/martijnkort/Desktop/InstaBot-master/src/instabot.py", line 126, in init self.starting_operations() File "/Users/martijnkort/Desktop/InstaBot-master/src/instabot.py", line 141, in starting_operations self.create_delays() File "/Users/martijnkort/Desktop/InstaBot-master/src/instabot.py", line 246, in create_delays self.times = self.today_times() File "/Users/martijnkort/Desktop/InstaBot-master/src/instabot.py", line 268, in today_times str(self.params['bot_start_at']).replace('.', ':')).timestamp) File "/Library/Python/2.7/site-packages/arrow/api.py", line 23, in get return _factory.get(*args, **kwargs) File "/Library/Python/2.7/site-packages/arrow/factory.py", line 164, in get dt = parser.DateTimeParser(locale).parse_iso(arg) File "/Library/Python/2.7/site-packages/arrow/parser.py", line 110, in parse_iso return self._parse_multiformat(string, formats) File "/Library/Python/2.7/site-packages/arrow/parser.py", line 267, in _parse_multiformat raise ParserError('Could not match input to any of {0} on \'{1}\''.format(formats, string)) arrow.parser.ParserError: Could not match input to any of [u'YYYY-MM-DDTHH:mm'] on '2017-03-02T9:00'

reinstalled arrow. but that didn't help.

I'll dig deeper in coding :) Thanks again for your reply!

nickpettican commented 7 years ago

No problem :)!

This new issue is in the time input, you might have told the bot to start at 9:00, it needs to be 09:00 for arrow to parse it properly.

Thanks again for this, I'll include a small snippet to add a 0 if the user inputs 3 digits instead of 4.

iflybrains commented 7 years ago

awwww could have seen this myself :x HH:mm ..... haha glad you can do something with it!