2015-10-10 19:14:51 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2016-05-30 18:40:21 +00:00
|
|
|
import twitools
|
2015-10-10 19:14:51 +00:00
|
|
|
import tkinter, tkinter.messagebox, html.parser, os
|
|
|
|
|
2016-05-30 18:40:21 +00:00
|
|
|
two = twitools.twObject()
|
2015-10-10 19:14:51 +00:00
|
|
|
top = tkinter.Tk()
|
|
|
|
top.title("Tweet Deleter")
|
|
|
|
scrollbar = tkinter.Scrollbar(top)
|
|
|
|
scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
|
|
|
|
list = tkinter.Listbox(top, height=20, width=150, selectmode=tkinter.MULTIPLE, yscrollcommand=scrollbar.set)
|
|
|
|
scrollbar.config(command=list.yview)
|
|
|
|
|
|
|
|
def deleteTweets():
|
|
|
|
top.wm_withdraw()
|
|
|
|
tweets = list.curselection()
|
|
|
|
|
|
|
|
success = 0
|
|
|
|
fail = 0
|
|
|
|
|
|
|
|
for tweet in tweets:
|
|
|
|
id = int(list.get(tweet).rsplit(None, 1)[-1])
|
|
|
|
try:
|
|
|
|
print(id)
|
|
|
|
two.delete(id)
|
|
|
|
success += 1
|
|
|
|
except:
|
|
|
|
fail += 1
|
|
|
|
|
|
|
|
tkinter.messagebox.showinfo('Deleted tweets', 'Deleted %i tweets. %i errors.' % (success, fail))
|
|
|
|
top.destroy()
|
|
|
|
|
|
|
|
button = tkinter.Button(top, text="Delete", command=deleteTweets)
|
|
|
|
|
|
|
|
def unescapeText(text):
|
|
|
|
return html.parser.HTMLParser().unescape(text)
|
|
|
|
|
|
|
|
def addStatus(id, text):
|
|
|
|
element = "%s - %i" % (text, id)
|
|
|
|
list.insert(0, element.encode("UTF-8"))
|
|
|
|
|
|
|
|
def getTweets():
|
2016-05-30 18:40:21 +00:00
|
|
|
query = "from:" + twitools.twObject().whoami()
|
2015-10-10 19:14:51 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
timeline = two.search(query, 0)
|
|
|
|
except:
|
|
|
|
tkinter.messagebox.showerror('Error...', 'An error occurred. Most likely you hit a rate limit. Please try again later.')
|
|
|
|
exit()
|
|
|
|
|
|
|
|
for status in timeline:
|
|
|
|
addStatus(status.id, unescapeText(status.text))
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
getTweets()
|
|
|
|
list.pack()
|
|
|
|
button.pack()
|
|
|
|
top.mainloop()
|