Skip to content

Feature Request: Completion of handle_exception.py with Full Example #1670

@LeilaSchooley

Description

@LeilaSchooley

Feature Request: Completion of handle_exceptions.py with Full Example

https://github.com/subzeroid/instagrapi/blob/master/examples/handle_exception.py

Is your feature request related to a problem? Please describe.
I have encountered difficulties while trying to implement exception handling in my project using Instagrapi. Specifically, the handle_exceptions.py file seems incomplete, and it lacks clear examples for integrating the update_client_settings, rebuild_client_settings, and freeze methods. This has made it challenging to effectively manage exceptions and maintain the stability of the client's state.

Describe the solution you'd like
I would greatly appreciate it if the Instagrapi team could complete the handle_exceptions.py file and provide a comprehensive example. This example should include fully implemented update_client_settings, rebuild_client_settings, and freeze methods.

Ideally, this example would be straightforward enough for users to easily run and adapt to their specific needs. The goal is to have a clear reference on how to handle various exceptions while maintaining the client's settings and state effectively.

Describe alternatives you've considered
I have tried piecing together the code from snippets found in the Telegram chat linked here #482 and other sources, but these are also incomplete and lack the context needed for full implementation.

def rebuild_client_settings(self, device):
        """Generate new session, change random device
        Help to reset Feedback Required
        """
        self.client_settings = self.build_client_settings(device)
        self.client = Client()
        self.client.login(self.username, self.password)
        return self.client_settings

    def build_client_settings(self, device=None):
        """Build device and user agent settings"""
        self.device = device
        if not self.device:
            # Assuming there is a method to get a random device
            self.device = self.get_random_device()  # Replace with actual method to get a random device
        self.client_settings = {
            'device_settings': self.device.settings,
            'user_agent': self.device.build_user_agent()
        }
        # Assuming there is a method to save these settings
        self.save_client_settings()  # Replace with actual method to save settings
        return self.client_settings

    def update_client_settings(self, settings):
        self.client_settings = settings
        # Assuming there is a method to save these settings
        self.save_client_settings()  # Replace with actual method to save settings
        return True

While I understand the concept behind these methods, having a complete, working example would significantly streamline the development process and reduce the potential for errors.

Additional context
I've noticed that there are others in the community facing similar challenges. Completing this part of the documentation and providing a full example would not only aid my project but also benefit the broader Instagrapi user community. It would enhance the usability of the library, especially for handling complex scenarios that require robust exception management.


Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions