https://twitter.com/twibeezy
This bot randomly selects a video from YouTube’s most popular video feed. A program scheduler runs it every two hours. From there the bot looks at several hundred comments and finds the comment with the most replies. Why was this comment the one with the most replies? What made it so evocative? Was it rude? Was it funny? Was it honest? Either way, the fact of the matter is that i not IS the most responded to comment at that instant, and it is telling of what matters to our society today, right now, in terms of the video content AND the comment.
I definitely laughed at some of the comments so far. One of them particularly reached out to me even, the one about women not being able to take their shirts off at sporting events. I mean personally, I wouldn’t feel comfortable doing it even if society accepted it, and I’d probably judge a woman who did…and all the men who didn’t stop staring…I mean, it makes me think. We as women by natural design are more guarded about our bodies because we are responsible for the after-effects regardless of whether or not the man also takes responsibility. That fact alone, that’s insane. Because of it, women by evolutionary traits are more protective of their bodies, and thus explains my inherent desire to not go around topless, because it IS, let’s face it, inviting to eyes. I don’t know why it’s different when men look than when women look, but it’s probably because men are bigger and honestly just generally more threatening to women are than women are to men. It’s crazy I’m thinking about any of this, and I don’t even know if I agree with it as I write, because I hate how it sounds. I like to think human minds have evolved far beyond the notion of ‘men will be men so it’s the woman’s responsibility to not get raped/harassed/stared at’, and that women should get to do whatever they want and not have it imply anything beyond what it is, such as, a woman taking off her freaking shirt when it’s hot, or even [I guess] shaking her tits at the camera with no feelings of being objectified, to support her team. HAA! That’s not possible now and I just personally don’t see it. Then again, I DID see a gif of a girl wildly shaking her tits at a camera…and it was NOT sexual AT ALL, because it was too funny and weird to be considered sexy…to me anyway. Another hilarious video of a naked woman was on Broad City, which also did not seem sexual at all. Maybe we ARE breaking the barriers?
The point is, this project ended up being a lot more fun than I had expected, and that’s awesome. Definitely thought-provoking when you ask yourself, why is that the comment people replied to most?
I’d say my bot falls under statement, as it IS kind of making a statement by taking other people’s statements and, in a way, might be de-contextualizing it depending on whether or not the commenter had been responding to someone else.
#Code Borrowed From https://developers.google.com/youtube/1.0/developers_guide_python
#Youtube Part
import urlparse
import gdata.youtube
import gdata.youtube.service
from HTMLParser import HTMLParser
import requests
import json
import random
#Twitter Part
import os, time
from twython import Twython
from StringIO import StringIO
#timestuff
from datetime import datetime
import os
from apscheduler.schedulers.blocking import BlockingScheduler
#Connect to Youtube
yt_service = gdata.youtube.service.YouTubeService()
#Code Borrowed From http://www.pythonforbeginners.com/api/using-the-youtube-api
# Get the feed
r = requests.get("http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=jsonc")
r.text
# Convert it to a Python dictionary
data = json.loads(r.text)
videoindex = random.randint(1, len(data['data']['items']))
# Loop through the result.
video_id = (data['data']['items'][videoindex]['id'])
url_data = "http://youtu.be/" + video_id
print"video_id"
print video_id
print"url_data"
print url_data
#Get Video
# url_data = urlparse.urlparse("https://www.youtube.com/watch?v=85P2iMHfzKw")
# query = urlparse.parse_qs(url_data.query)
# video_id = query["v"][0]
#Get Comment Feed
comment_feed = yt_service.GetYouTubeVideoCommentFeed(video_id=video_id)
#Connect to Twitter
APP_KEY='hnWvsJh1i2QQmdwfK7zsTmiof'
APP_SECRET='kXjUFcAfJRsmy81yvZe0Wcw1JdxGIi2ooeIgNVrbsnQhLeMOc8'
OAUTH_TOKEN='3060242525-9bL2kUpmn3omZAa1U0QVzKJfziFCu9fPyYnzAoj'
OAUTH_TOKEN_SECRET='tTVCoEwBKfOBLjU56NRyT4kbLwu2i7bBWKGlk2KMPDujN'
twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
contentTag = 'ns0:content'
replyTag = 'ns1:replycount'
getdata = []
comments = []
replyCount = []
#Parsed With HTMLParser: https://docs.python.org/3/library/html.parser.html
#Determine Comments and Reply Counts
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
# print("Encountered a start tag:", tag)
if (tag==contentTag):
# print("Encountered a start tag:", tag)
getdata.append(1)
elif (tag==replyTag):
# print("Encountered a start tag:", tag)
getdata.append(2)
# def handle_endtag(self, tag):
# print("Encountered an end tag :", tag)
def handle_data(self, data):
for x in xrange(len(getdata)):
if(getdata[x]==1):
comments.append(data)
getdata.pop(x)
elif(getdata[x]==2):
replyCount.append(data)
getdata.pop(x)
# print("Encountered some data :", data)
parser = MyHTMLParser()
while comment_feed is not None:
for comment_entry in comment_feed.entry:
parser.feed(comment_entry.ToString())
if(len(comments) > 300): break
next_link = comment_feed.GetNextLink()
if next_link is None:
comment_feed = None
else:
comment_feed = yt_service.GetYouTubeVideoCommentFeed(next_link.href)
maxReply = 0
index = 0
print "GETDATA:"
print len(getdata)
print''
print''
print "COMMENTS:"
print len(comments)
print''
print''
print"REPLIES:"
print len(replyCount)
print''
print''
# for c in xrange(len(comments)):
# print replyCount[c]
# print comments[c]
for c in xrange(len(comments)):
if (int(maxReply) < int(replyCount[c])):
# print "replyTag: ", replyTag
# print "replyCount[c]: ", replyCount[c]
maxReply = int(replyCount[c])
index = c
print "comment:"
print comments[index]
print "replycount"
print replyCount[index]
twitter.update_status(status=comments[index][:139-len(str(url_data))] + ' ' + str(url_data))