Search code examples
pythontwitter

Sorting Twitter API pages in favorites by time you favorited them not when they were created


Okay, so basically I'm trying to write a program that would go through my twitter favorite history and find pieces of media from them and then download them. I actually have a working model in Python using Tweepy that works it's just it only gets the tweets in order of when they were created. See, the thing is I don't want to download my whole favorite history every time, just up to the point of the last mass download, so at first, I set it up to stop when the tweets reached a certain date. Every time I downloaded I would record the date, but then I realized that sometimes I favorite tweets that are from a while ago, before the cut off date, but is still new to my favorites history. So I decided to try something else, I would record the tweet ID of the first tweet in the list from the last time I downloaded and then set it to stop there, and this would work fine if the api.favorites() returned it in the order it appears on your profile, but instead it auto sorts them by date, so if I fav a post form 2010, I would have to cycle threw all the back to 2010 before it would appear on one of my returned pages. When I looked threw the docs I found a little bit on sorting, but nothing on sorting the Fav Hist by when you faved the tweet. And the thing is I know it stores the order that you liked the tweets in, since that's how it displays it on your profile, even if it is just a table that they append to every time, it still works. I know I'm writing this program in python, but I'm good enough with Java and JavaScript to understand the guts of the API, it's how I got this far. Anyway if you have some suggestions or now how to do it please let me know, any help is appreciated! If all else fails I'll try using Selenium to go through my Twitter Favs from a user perspective...


Solution

  • I had the same issue and I found that you can't do this with the regular Twitter API. They have an enterprise API, which requires payment to access, and that will give you the time a tweet was favorited but it doesn't look cheap so it's probably not worth it.