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 cant, at least, those same recommended videos wouldnt show up twice.
Few days ago, I was having enough of YouTubes 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 didnt even realize.
Anyway, this is what the script, yt-reco, will generate HTML as you see on the right. The layout isnt perfect, but its good enough for me to read. Its quick and clean. To be fair, YouTubes webpage is relatively quick to render, but still couldnt 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 isnt exactly as same as YouTube homepage. For some reason, the returned JSON doesnt include all the data. For instance, if someone likes a video, you can see who does that on YouTube, but the API doesnt include the user who does the like action. Like isnt 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