Instapy: Is it time for a refactor?

Created on 17 Apr 2017  路  9Comments  路  Source: timgrossmann/InstaPy

I think we should refactor the code soon to better extract:

  • the selenium commands to browse IG.
  • the logic to decide if we should take an action.
  • each separate IG action (like, comment & follow).

I came to this conclusion because the current design does not allow using ClarifAI to determine if an image should be liked or not, only determine the comment to write. I have a branch to fix this but it only add more code while a real solution would be to refactor the app structure.

Also, a clear separation between component would allow us to port the app to act on 500px, flickr, YouTube, etc.. Another idea would be to add more AI to analyse images/tags/comments to determine the best course of action to take for each image.

Maybe this is too early and we should fold all of these under v2?

InstaPy_V1 discussion enhancement

Most helpful comment

The Chrome locale already forces It to load in en-us, check the code.

All 9 comments

I agree with you. Loads of stuffs are getting bunched together in the like_util.

I'm interested in the "more AI to analyse" what are you thinking?

Also, you said to hold them for v2, why not v1? (actually, what's the current version, is there any?)
The refactored, cleaned and organised version could be v1.
Major new features goes into v2 (maybe with other ports that you mentioned).

Basically my idea AI would be to use machine learning to guess how much the account owner (me) would actually like the image/follow the user compared to just randomly pick the actioned images.

For example, I like to follow zombie/horror images. The problem is that these keywords are super heavily used on IG to describe pretty much anything but actual zombies. ClarifAI can help here (I did some test and it can identify zombies with some success) but instead of finding matches by comparing the searched for tags with those provided by ClarifAI, I would like the AI to do the analysis and predict the result.

Or the AI could be used to determine which comment to write, or if we should follow the user or not based on the follow back of previously followed users with similar profiles.

Obviously, there is a lot we can do but we need to have a solid foundation first and we are not there quite yet.

Could we do the refactor for v1? Sure, depends on @timgrossmann time table for a v1 release.

@AlainPilon @pekapa
I really like this Idea!

There currently is no version, since I have never thought that this tool would explode that much 馃槃

Yes this could definitely be a cleaned up V1.
Like @pekapa mentioned, I'd put the other services like YouTube&Co. in the second version, after we refactored and made this more modular.

With #131, we have only more account type.
Maybe it's time to refactor and think about the "anti-bot detection" feature.

I'm already working on the selectors for the itens, thinking that the page will always show up in en-US language.

@vlntdds, just load instagram with this url https://www.instagram.com/?hl=en-us
it forces en-US (might need to add the ?hl=en-us to other page loads as well)

The Chrome locale already forces It to load in en-us, check the code.

While splitting the FIFO unfollow form #74, I had an idea: why not use the page object pattern to structure the way we browse IG? By encapsulating each Selenium call inside a method, it would be trivial to maintain the alignement of the browser code with the site and much easier to maintain features.

For some info on this pattern: https://martinfowler.com/bliki/PageObject.html and the implementation in Nightwatch https://github.com/dwyl/learn-nightwatch

We would then have a class for each of IG pages, each one having a method corresponding to each possible click action on the page. The more I think about it, the more I am convinced it is the way to go!

I really like the idea of having classes for each IG page. I was thinking of having more classes but couldn't really grasp how, it makes a lot of sense to split them per page and have them full of actions.

I'll have a look at the resources you shared and get back to you later!

171

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deronsizemore picture deronsizemore  路  3Comments

tibor picture tibor  路  3Comments

Naramsim picture Naramsim  路  3Comments

ingorichter picture ingorichter  路  3Comments

CharlesCCC picture CharlesCCC  路  3Comments