Finally, I made it, now I can have no repeated and filtered recommendations. You can filter any way you like as long as you can code in Python. If you can’t, at least, those same recommended videos wouldn’t show up twice.
Few days ago, I was having enough of YouTube’s recommendation flaw, set my mind to see this through, telling me that I am going to write a script. Funny thing always happens, somehow YouTube GData API registration page is a 404. Fortunately, I kept googling and found out the recommendation is included in Activities list in JSON API v3. They probably have been there for long time, and I didn’t even realize.
Anyway, this is what the script, yt-reco, will generate HTML as you see on the right. The layout isn’t perfect, but it’s good enough for me to read. It’s quick and clean. To be fair, YouTube’s webpage is relatively quick to render, but still couldn’t compare to much simpler page like the output of this script.
Initially, I was only planning to extract recommendation, since there is no option to filter out by activity type in API request, why waste the data? Although, by default, this script will only process on recommendation, but you can supply your own filter function in a script. I am actually doing that, so I am using this script to give me not only the recommendation, but also activities from my subscriptions or whatever I see on YouTube homepage.
However, the output isn’t exactly as same as YouTube homepage. For some reason, the returned JSON doesn’t include all the data. For instance, if someone likes a video, you can see who does that on YouTube, but the API doesn’t include the user who does the like action. “Like” isn’t the only one, “subscribe” is another, and there might be more. Also “comment” is another weird activity. If a video gets comment multiple times, multi entires will show, but content of those comments never are included in returned data. Probably need additional API request for those if there is an API for that. Even so, I am not wasting time coding for that.
Currently, I am using it with cron like many others script of mine. For more detail, please read on Gist.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.