Hacker Fail

So, originally I wanted to make a blinking light toy that would give real time feedback of activity to my YouTube channel. I wanted the lights to blink when ever anyone viewed, rated, commented, or subscribed to any video on my channel. The Google/YouTube API simply isn’t interested in providing that data via API, probably because it already provides such excellent analytics. We did determine that we could get a count of views and get that blinky light to blink. This is as far as we got with the python.

import gdata.youtube.service
from xml.etree import ElementTree

yt_service = gdata.youtube.service.YouTubeService()
feed = yt_service.GetYouTubeVideoFeed(“https://gdata.youtube.com/feeds/api/users/emchartreuse/uploads“)
for entry in feed.entry
print entry.media.title.text
print entry.statistics.view_count

A few days later I got a letter from Google Adsense informing me that my account had been closed due to “click fraud”… and I went a little crazy…. Seriously, it kinda broke my brain temporarily (I hope). It didn’t help that I had just come down with a wicked cold and had a head full of snot and psudophed. Long story short, I lost my entire Google account for a few days (it got restored just in time for my Capstone presentation) and I also lost all will to understand the Google API any further.

My understanding of code is pretty limited and I just wasn’t understanding much of it.

Regardless it was a great class and I fully intend to play with my Arduino and learn more about electronics and sketches. Everything was extra stressful with my Capstone looming. I do believe that the hacker spirit thrives in the DIY Makers movement. If I ever get back home to Minneapolis, there’s a great makers space there that I’d love to get involved with. I think I just want to start with the basics and form a good foundational knowledge of how Arduino electronics work. And, of course, build a minty Atari Punk Console.

Serial to Arduino Code

Found a really great article that helped explain how this code should look

http://www.stealthcopter.com/blog/2010/02/python-interfacing-with-an-arduino/

Getting view data out of ‘video feed’

https://developers.google.com/youtube/1.0/developers_guide_python#UnderstandingVideos

I believe I need to make an array of all the videos I want to monitor using this syntax:

[entry URL syntax]

http://gdata.youtube.com/feeds/api/videos/videoID

[get entry syntax]

entry = yt_service.GetYouTubeVideoEntry(video_id=’ID STRING’)

And then use this syntax to get and print the view data:

def GetAndPrintVideoFeed(uri): yt_service = gdata.youtube.service.YouTubeService() feed = yt_service.GetYouTubeVideoFeed(uri) for entry in feed.entry: PrintEntryDetails(entry) # print ‘Video view count: %s’ % entry.statistics.view_count

So, I think I need to make that def statement for each video.

Professor to the rescue!

My professor gave the correct instructions to install Gdata! Watching it actually work was very exciting. I don’t know why these instructions are not the same as Google’s instructions.

Here is what you need to do.
Install Python 2.7
Download the gdata python library zip file, and unzip it.
Go to your control panel, and go to System and Security->System->Advanced System Settings
Click the Environment Variables button.
Find the “Path” variable under the list of System Variables and select it. For future reference, the “Path Variable” tells the computer where to look for executable programs when you type something on the command line.
Click edit.
At the end of the existing Path variable, type a semicolon, and then the directory where Python is installed (probably C:\Python27).
Click Ok to apply your changes.
Open a terminal and type “Python” to confirm that the interpreter is working. The interpreter should launch and display the >>> prompt.
Exit the interpreter by typing “exit()”
Navigate to the directory where the gdata library has been unpacked. To navigate on the command line type “cd” (for “change directory”) and then the name of the directory you want to move to. The library probably unpacked in the Downloads directory, so head there first. Then type “dir” to see the directory contents. Changeto the directory for the gdata library with “cd” (mine was called gdata-2.0.16). Type “dir” to see what is inside. You may see the library files, or you may see just another directory labeled “gdata-2.0.16.” If you see the files move to the next step. If you see another gdata directory, change into it and type dir again to make sure the files are in there.
Type “python setup.py install” to install the library.
When the install completes type “python” to run the interpreter, and then “import gdata” at the prompt to confirm the library is working.

I really thought that this would be a simple project but I was wrong. YouTube’s analytic GUI is amazing. I think it may be so good that they never considered why anyone would need to stream those stats. You make an app to generate an analytic zip file, but that is all. The YouTube data available allows you to build apps that can automate many of the things you would do through the YouTube interface and to data-mine other users. But it won’t provide you with your own stats in the way I need for this project. What I can do is extract views from an array of video IDs. I’ll talk about that in the next post

Adventures with the Python client and Gdata

Okay… first I installed Python    [Python 2.7.3 Windows X86-64 Installer (Windows AMD64 / Intel 64 / X86-64 binary [1] — does not include source)]

I installed Google Data Library for Python. I couldn’t get the library to install. I tried putting the folder in the Python folder. I tried doing this:

For Windows XP, pull up the Environment Variables for your profile: Control Panel > System Properties > Advanced > Environment Variables. From there, you can either create or edit the PYTHONPATH variable and add the location of your local library copy.

It’s not working. Now I’m at an impasse. So I deleted the library and the PYTHONPATH variable.

Again, downloaded gdata-2.0.16.zip , unzipped, placed the folder on my desktop, ran the install…. nothing. Uninstalled Python.

Installed the 32 bit version of Python [Python 2.7.3 Windows Installer (Windows binary — does not include source)] Put gdata directly on the C root directory.

Gdata still won’t install, don’t know what I’m doing wrong.

Downloaded and installed:  [Windows, download elementtree-1.2.6-20050316.win32.exe].

Time to email the prof.

Space Invader Gmail Notifier!

I found this project for an Arduino notifier made from a hacked Space Invader alarm clock (how cool is that?). On Grant Gibson’s blog he goes into great detail, including his sketch! This helped me visualize the sketch I’d have to write for the Arduino end of things. He even uses Python! What a break it was to find this, I think it’ll be a big help.

What the hell am I doing?

Hacking is always something I’ve wanted to understand better. I started using the internet before there was a WWW and yet there is so much I don’t understand. For my Arduino project, I though I’d like to make a widget that would help me understand the system I take for granted. I found an Arduino project for a blinky network monitor but I quickly got bogged down by the code. It was simply over my head for the time I had.

What I had been spending most of my time on was my Capstone project; my YouTube gaming channel. Watching my stats go up is ridiculously exciting. Sometimes I’ll leave the stat page open and refresh it to watch the numbers change. It’s so gratifying and such a positive feedback loop that I knew that had to be my Arduino project. I wanted blinky light real time stat updates. I wanted a LED to blink whenever someone viewed, rated, commented on, or subscribed to a video on my channel.

My idea is to wire 4 LEDs to the Arduino, one for each stat I wanted to watch; view, comment, subscribe, and rate. That seems simple enough… but how do 1) get that data from YouTube and 2) translate it to Arduino blinky lights? I’m not a programer and figuring out code is slightly terrifying to me. It feels almost like an irrational phobic reaction. It’s just stupid that someone who has played with computers since 1984 could be so intimidated by code. But I just have to push through it so I can be rewarded by what will no doubt be completely delightful.