SHARE
TWEET

Untitled

WingsVixaOnTwitch May 26th, 2019 198 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import wx
  2. from InstagramAPI import InstagramAPI
  3. from time import sleep
  4. from requests import get
  5. from re import findall
  6. from os.path import abspath, join
  7.  
  8.  
  9. class LoginFrame(Frame):
  10.     def __init__(self):
  11.         super().__init__(title='Instauto', size=(300, 300))
  12.         self.button = wx.Button(self.panel, label='Login', size=(75, 25))
  13.         self.username_ctrl = PlaceholderTextCtrl(self.panel, size=(150, 20), placeholder="Username")
  14.         self.password_ctrl = PlaceholderTextCtrl(self.panel, size=(150, 20), placeholder="Password", style=wx.TE_PASSWORD)
  15.         png = wx.Image(resource_path("insta.png"), wx.BITMAP_TYPE_ANY).ConvertToBitmap()
  16.         wx.StaticBitmap(self.panel, -1, png, (50, 35), (png.GetWidth(), png.GetHeight()))
  17.  
  18.         self.configure_button()
  19.         self.configure_username_ctrl()
  20.         self.configure_password_ctrl()
  21.  
  22.     def configure_button(self):
  23.         self.button.Bind(wx.EVT_BUTTON, self.on_press)
  24.         self.button.SetPosition((112, 225))
  25.  
  26.     def configure_username_ctrl(self):
  27.         self.username_ctrl.SetPosition((75, 120))
  28.  
  29.     def configure_password_ctrl(self):
  30.         self.password_ctrl.SetPosition((75, 170))
  31.  
  32.     def on_press(self, event):
  33.         username = self.username_ctrl.GetValue()
  34.         password = self.password_ctrl.GetValue()
  35.         if username == "Username" or password == "Password":
  36.             wx.MessageBox('Nothing was entered.', 'Login Failed', wx.OK | wx.ICON_ERROR)
  37.             return
  38.  
  39.         if setup_api(username, password):
  40.             self.frame.Show()
  41.             self.Hide()
  42.         else:
  43.             wx.MessageBox('Login credentials are incorrect', 'Login Failed', wx.OK | wx.ICON_ERROR)
  44.  
  45.  
  46. class MainFrame(Frame):
  47.     def __init__(self):
  48.         super().__init__(title='Reptar', size=(500, 750))
  49.         self.placeholder_text = "Paste instagram links here..."
  50.         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)
  51.         self.button = wx.Button(self.panel, label='Start', size=(75, 25), pos=(212, 675))
  52.         self.gauge = wx.Gauge(self.panel, size=(450, 25), pos=(18, 635), style=wx.GA_HORIZONTAL)
  53.         self.gauge.Hide()
  54.  
  55.         self.configure_textbox()
  56.         self.configure_button()
  57.  
  58.     def configure_textbox(self):
  59.         self.textbox.SetBackgroundColour(wx.Colour((16, 18, 20)))
  60.         self.textbox.SetForegroundColour(wx.Colour((255, 255, 255)))
  61.  
  62.     def configure_button(self):
  63.         self.button.Bind(wx.EVT_BUTTON, self.on_press)
  64.         self.button.SetFocus()
  65.  
  66.     def on_press(self, event):
  67.         val = self.textbox.GetValue()
  68.         if not val or val == self.placeholder_text:
  69.             wx.MessageBox('No instagram links provided', 'Error', wx.OK | wx.ICON_ERROR)
  70.             return
  71.  
  72.         lines = val.split('\n')
  73.         links = []
  74.         for line in lines:
  75.             link = find(line)
  76.             if len(link) != 0:
  77.                 links.append(link[0])
  78.  
  79.         if not links:
  80.             wx.MessageBox('Could not find any links', 'Error', wx.OK | wx.ICON_ERROR)
  81.             return
  82.  
  83.         confirm = wx.MessageDialog(None, f'Confirm action: Like {len(links)} posts', 'Confirm', wx.YES_NO | wx.ICON_QUESTION)
  84.         result = confirm.ShowModal()
  85.  
  86.         if result == wx.ID_NO:
  87.             return
  88.  
  89.         self.gauge.SetValue(0)
  90.         self.gauge.Show()
  91.         self.gauge.SetRange(len(links))
  92.  
  93.         likes = len(links)
  94.  
  95.         for x, link in enumerate(links):
  96.             self.gauge.SetValue(x+1)
  97.             try:
  98.                 api.like(get_media_id(link))
  99.             except:
  100.                 likes -= 1
  101.                 continue
  102.             sleep(3)
  103.  
  104.         wx.MessageBox(f'Automation completed! {likes}/{len(links)} posts liked.', 'Success', wx.OK)
  105.         self.gauge.Hide()
  106.         self.textbox.SetValue("")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top