YouTube CFC Updated

I've "formally" released the new version of my YouTube CFC to it's RIAForge home. This new version doesn't have a one to one relation to the older API so I've included the old code in the zip as well. Right now it supports:

  • Various 'top' video feeds (most popular, etc)
  • Videos by category, keyword, or both
  • Videos by user
  • Comments for a video
  • Playlists for a user
  • Videos for a playlist

And of course the big one - video upload.

The major things left to do include posting new comments and updating video information. Hopefully I can get the YouTube API Blog folks to notice.

Comments

Bob's Gravatar Hey Ray, this is great - thank you! I was wondering if you planned to add a GetVideo function akin to the one in the CFC with the first API, so that you could grab all of the data about a specific video.

Regardless, this is really helpful - thank you!
# Posted By Bob | 4/19/08 11:00 PM
Geoff's Gravatar Great CFC Ray! I have a quick question about error trapping on cfhttp.

I'm always concerned about timeouts / problems connecting to third party services - how would getVideos() tell the calling app "sorry, I couldn't contact the youtube website"

Could (should?) you change getVideos() to return a struct - one key has the results recordset, and one key has a "statuscode" message maybe?

Then put a timeout on the cfhttp call, and try/catch it?

just a thought...
# Posted By Geoff | 4/20/08 6:40 AM
Raymond Camden's Gravatar I should have more error handling, but no, I don't believe in returning structs like that. I know some folks do - but in my mind, if an error occurs, I should cfthrow. However, I like to throw my own error, using a common type and message format, so you can look for it in the code that calls my cfc.
# Posted By Raymond Camden | 4/20/08 8:42 AM
Raymond Camden's Gravatar @Bob - the odd thing is that what getVideo used to do is mostly contained in the get* feeds. Ie, when you get a list of videos, it contains the same info, per video, that a singular getVideo would contain. I believe. I don't believe - and I have to research this more - that you can get just ONE video based on ID. I meant to actually look into that last night but forgot. I'll make that my next priority.
# Posted By Raymond Camden | 4/20/08 8:45 AM
Bob's Gravatar Thanks Ray. This morning I just used CFHTTP to grab and then XMLParse() to parse the individual video XML page at http://gdata.youtube.com/feeds/api/videos/(videoID). It's doing the job.
# Posted By Bob | 4/20/08 9:35 AM
Raymond Camden's Gravatar I didn't read the whole spec, but I do remember trying to find docs for getitng one video. Where did you find that? (I'm sure it works and I'll confirm/add it later, but I'd like to be sure it is SUPPOSED to work if you know what I mean.)
# Posted By Raymond Camden | 4/20/08 6:10 PM
Bob's Gravatar I actually used your CFC to pull the list of videos for the user. The ID column contained the feed URL for each video, which I pulled up in Firefox and found the detailed XML. So no, I can't confirm it's SUPPOSED to work.
# Posted By Bob | 4/20/08 9:19 PM
Raymond Camden's Gravatar I did some more looking last night, and it does seem to be kinda documented - when you look specifically at the Entry field it does talk about the links.

So I will add this later today.
# Posted By Raymond Camden | 4/21/08 8:28 AM
jason's Gravatar hi, great tool, but i can't seem to make it work.

trying the test2.cfm file in the youtubeapi1 folder and keep getting "Bad, unknown, or disabled dev_id specified."

i want to test the upload function and can't get started.

the cfc is installed and i have a valid dev key.

any advice or other documentation? where to start with uploads?

thanks!
# Posted By jason | 6/23/08 11:06 PM
Raymond Camden's Gravatar Don't use the youtubeapie1 folder. That's the older code. I include it for folks who may insist upon it - but in general don't support it anymore. Make sense?
# Posted By Raymond Camden | 6/24/08 2:50 AM
Louis Plante's Gravatar Hey Ray, excellent work on the api, i have one question though. I wanted to order the videos by the newest to the oldest. Here is the code that I'm using

<cfset yt = createObject("component", "assets.cfcs.youtube")>
<cfset pl = yt.getVideosByUser('marjenningstv')>

any suggestions?
# Posted By Louis Plante | 9/22/08 7:03 PM
Raymond Camden's Gravatar My CFC returns a query. If you want to re-order it, you can use a query of query. I can investigate, later on, adding sorting.

FYI - upload is currently broken. I hope to have it fixed w/n a week. It turns out there is a bug in CF that only gets exposed with the YT api.
# Posted By Raymond Camden | 9/22/08 7:48 PM
Greg E.'s Gravatar Hi Ray, Do you have any documentation or examples on uploading videos? This is what I have at this point and the results follow: (thanks for your help and this .cfc)

<cfinvoke component="youtube" method="init" returnvariable="yt"><cfinvokeargument name="devkey" value="#request.YouTubeDeveloperKey#"></cfinvoke>
   
<cfdump var="#yt.upload(video='#cffile.SERVERDIRECTORY#\#cffile.SERVERFILE#',title='Upload Test',description='Testing',categories='Education',keywords='YouTube ColdFusion')#">


Upload Result:
--------------
ErrorDetail: I/O Exception: Software caused connection abort: socket write error
Filecontent: Connection Failure
Mimetype: Unable to determine MIME type of file.
Statuscode: Connection Failure. Status code unavailable.
# Posted By Greg E. | 10/13/08 5:12 PM
Raymond Camden's Gravatar Greg - video uploads is currently broken. I have worked w/ Adobe and there IS a fix, but the fix involves a hot fix that is not yet released to the public. I'm going to bug them again about that and see when it will go public.

Long story short: You can't do the upload now- period. But you will be able to with a hotfix sometime in the (I would assume!) near future.
# Posted By Raymond Camden | 10/13/08 5:17 PM
aviva's Gravatar i found the hotfix:
http://kb.adobe.com/selfservice/viewContent.do?ext...

but i get an error when trying to upload:
the error is in your cfc, trying to read an error.

can you give an example of the code needed to upload a video?

Element ERRORS.ERROR.DOMAIN.XMLTEXT is undefined in RESXML.

The error occurred in /home/mylifesp/dev_html/my-account/youtube.cfc: line 691

689 :          <cfset resxml = xmlParse(result.fileContent)>
690 :          
691 :           <cfthrow message="YouTubeCFC Upload Error: Domain=#resxml.errors.error.domain.xmlText#, Code=#resxml.errors.error.code.xmlText#">
692 :       <cfelse>
# Posted By aviva | 11/30/08 4:29 PM
Raymond Camden's Gravatar The only real 'doc' for upload is by reading the CFC method and looking at the arguments. Can you show me how you tried to do an upload?
# Posted By Raymond Camden | 11/30/08 4:40 PM
Derek's Gravatar I noticed it says you need a dev key and YT username and pwd, but in the api docs it says

Both the Client ID and Developer Key should be provided in every API request (see Using a developer key and client ID). Each application/product should have its own unique Developer Key and Client ID.
http://code.google.com/apis/youtube/dashboard/prod...

Has it changed since the last update?
# Posted By Derek | 12/22/08 9:27 AM
Raymond Camden's Gravatar I think ClientID is the name of the 'tool' using the service, which in this case is my tool, and is hard coded in the CFC. So basically, you don't need to worry about it.
# Posted By Raymond Camden | 12/22/08 9:36 AM
Derek's Gravatar ahh..ok so they aren't tied together?
# Posted By Derek | 12/22/08 9:37 AM
Raymond Camden's Gravatar No, it's like your cell phone. Your phone number is unique to you, but your brand name is iPhone. So my code's "brand" is, um, whatever I used (probably something with Camden in it since I'm an egotistical twit), and the dev key is what you are responsible for.
# Posted By Raymond Camden | 12/22/08 9:40 AM
Derek's Gravatar ok, back again. This issue is related to just retrieving videos.
Everything was working at first. Then I started getting connection failures. I did some testing and by removing the V2 param, I got it working again.

So now the past couple of days it is no longer working on the prod server which is 7,0,2,142559 , but works fine on 8 from my home dev box.

Charset     [empty string]
ErrorDetail    Unknown host: gdata.youtube.com: gdata.youtube.com
Filecontent    Connection Failure
Header    [undefined struct element]
Mimetype    Unable to determine MIME type of file.
Responseheader    
struct [empty]
Statuscode    Connection Failure. Status code unavailable.
Text    YES

here is a test page I am using
http://justs10.com/videos/t.cfm

If anyone could help, be mucho appreciated.

Thanks,
D
# Posted By Derek | 1/15/09 8:50 AM
Raymond Camden's Gravatar Unfortunately this sounds like a Google/YT issue. I'm not sure what I can recommend for that. Removing the v2 param isn't a solution for me as I know I'm relying on some v2 stuff in some calls. You may want to check the network settings on production box.
# Posted By Raymond Camden | 1/15/09 9:08 AM
Lamar's Gravatar Ray - trying to use the upload capability but am a little clueless as to where to start. Any sample code you have for uploading?
# Posted By Lamar | 2/4/09 2:16 PM
Raymond Camden's Gravatar Wasn't there one in the zip?
# Posted By Raymond Camden | 2/4/09 2:18 PM
Raymond Camden's Gravatar Here is an example, with login/key info changed:

<cfset yt = createObject("component", "youtube")>
<cfset yt.setDeveloperKey("AI39n2n17CzpcDAt6GMrXc8z6DA")>
<cfset yt.login("cfjedimaster", "password")>
<cfset r = yt.upload(expandPath('./actual.mov'),'Test/Upload Jack-O-Latern','Playing/with Jack-O-Latern youtube aug29','Music','testing fun')>
<cfoutput>id=#r#</cfoutput>
# Posted By Raymond Camden | 2/4/09 2:22 PM