Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wx
- from InstagramAPI import InstagramAPI
- from time import sleep
- from requests import get
- from re import findall
- from os.path import abspath, join
- class LoginFrame(Frame):
- def __init__(self):
- super().__init__(title='Instauto', size=(300, 300))
- self.button = wx.Button(self.panel, label='Login', size=(75, 25))
- self.username_ctrl = PlaceholderTextCtrl(self.panel, size=(150, 20), placeholder="Username")
- self.password_ctrl = PlaceholderTextCtrl(self.panel, size=(150, 20), placeholder="Password", style=wx.TE_PASSWORD)
- png = wx.Image(resource_path("insta.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
- wx.StaticBitmap(self.panel, -1, png, (50, 35), (png.GetWidth(), png.GetHeight()))
- self.configure_button()
- self.configure_username_ctrl()
- self.configure_password_ctrl()
- def configure_button(self):
- self.button.Bind(wx.EVT_BUTTON, self.on_press)
- self.button.SetPosition((112, 225))
- def configure_username_ctrl(self):
- self.username_ctrl.SetPosition((75, 120))
- def configure_password_ctrl(self):
- self.password_ctrl.SetPosition((75, 170))
- def on_press(self, event):
- username = self.username_ctrl.GetValue()
- password = self.password_ctrl.GetValue()
- if username == "Username" or password == "Password":
- wx.MessageBox('Nothing was entered.', 'Login Failed', wx.OK | wx.ICON_ERROR)
- return
- if setup_api(username, password):
- self.frame.Show()
- self.Hide()
- else:
- wx.MessageBox('Login credentials are incorrect', 'Login Failed', wx.OK | wx.ICON_ERROR)
- class MainFrame(Frame):
- def __init__(self):
- super().__init__(title='Reptar', size=(500, 750))
- self.placeholder_text = "Paste instagram links here..."
- self.textbox = PlaceholderTextCtrl(self.panel, placeholder=self.placeholder_text, pcolor=wx.WHITE, color=wx.WHITE, size=(450, 600), pos=(18, 25), style=wx.TE_MULTILINE | wx.BORDER_NONE)
- self.button = wx.Button(self.panel, label='Start', size=(75, 25), pos=(212, 675))
- self.gauge = wx.Gauge(self.panel, size=(450, 25), pos=(18, 635), style=wx.GA_HORIZONTAL)
- self.gauge.Hide()
- self.configure_textbox()
- self.configure_button()
- def configure_textbox(self):
- self.textbox.SetBackgroundColour(wx.Colour((16, 18, 20)))
- self.textbox.SetForegroundColour(wx.Colour((255, 255, 255)))
- def configure_button(self):
- self.button.Bind(wx.EVT_BUTTON, self.on_press)
- self.button.SetFocus()
- def on_press(self, event):
- val = self.textbox.GetValue()
- if not val or val == self.placeholder_text:
- wx.MessageBox('No instagram links provided', 'Error', wx.OK | wx.ICON_ERROR)
- return
- lines = val.split('\n')
- links = []
- for line in lines:
- link = find(line)
- if len(link) != 0:
- links.append(link[0])
- if not links:
- wx.MessageBox('Could not find any links', 'Error', wx.OK | wx.ICON_ERROR)
- return
- confirm = wx.MessageDialog(None, f'Confirm action: Like {len(links)} posts', 'Confirm', wx.YES_NO | wx.ICON_QUESTION)
- result = confirm.ShowModal()
- if result == wx.ID_NO:
- return
- self.gauge.SetValue(0)
- self.gauge.Show()
- self.gauge.SetRange(len(links))
- likes = len(links)
- for x, link in enumerate(links):
- self.gauge.SetValue(x+1)
- try:
- api.like(get_media_id(link))
- except:
- likes -= 1
- continue
- sleep(3)
- wx.MessageBox(f'Automation completed! {likes}/{len(links)} posts liked.', 'Success', wx.OK)
- self.gauge.Hide()
- self.textbox.SetValue("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement