YouTubeCFC update and the most insane API you will see today...

This post is more than 2 years old.

I updated my YouTubeCFC component at lunch today. One change involves search. YouTube's API provides spelling suggestions for some search terms and I now return that in the call. Even cooler, you can tell the API to search again if no results were found and a suggestion was made.

The other change involves uploads. When you upload a video you provide keywords that describe the video. A user reported a bug with the upload feature that I couldn't replicate until I typed exactly what they had used. Turns out, YouTube's API has some rather... strong rules for keywords. Check out the docs:

Thetag contains a comma-separated list of words associated with a video. You must provide at least one keyword for each video in your feed. This field has a maximum length of 120 characters, including commas, and may contain all valid UTF-8 characters except < and >. In addition, each keyword must be at least two characters long and may not be longer than 25 characters.

Please note that individual keywords may not contain spaces. However, you can use spaces after the commas that separate keywords. For example, crazy,surfing,stunts and crazy, surfing, stunts are both valid values for this tag. However, crazy, surfing stunts is not valid. (The invalid value does not contain a comma between "surfing" and "stunts".)

If you can read that without your eyes bleeding, great. To me, this is horrible design. I couldn't imagine building a public facing wrapper to YouTube's service and telling the general public that. Shoot, most of the general public wouldn't get what a keyword is anyway.

So with that in mind, my CFC now has a method that will automatically 'massage' your keywords. If you dare to enter: "pizza ackbar trap lich king" as your keywords, the CFC will change it to the format YouTube prefers.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Francois Levesque posted on 11/13/2008 at 1:36 AM

hmmm, pizza lich king

8 and a half hours to go!

Comment 2 by Raymond Camden posted on 11/13/2008 at 1:37 AM

Heh, don't remind me. I'm actually happy no one has gotten me the expansion via the wishlist yet. I wouldn't have time to play before MAX. Anyway, I'm getting deep into Fallout 3 and Fable 2.

Comment 3 by Rick O posted on 11/13/2008 at 2:15 AM

Makes perfect sense to me. Their engine doesn't handle agglutinative terms. They don't want developers glossing over that fact and then submitting a bunch of garbage, so they build it into the API.

It comes down to accepting a search term like "lich king" and then silently failing and returning no results, or throwing an error. Since there are actually possible results, returning none is the wrong answer. An error of "nope, sorry, can't handle that" is the right thing because that is actually the case.

Comment 4 by Raymond Camden posted on 11/13/2008 at 2:21 AM

I disagree. Their API could easily do what I did - reformat the text. Think about it - right now they have placed the responsibility on the external site using their API. They have a restriction that is - you have to admit - something that the average user would have a great deal of trouble with. So those of us in the middle have to handle it.

I see no reason why lich king couldn't simply be turned into lich,king. Technically this is not the same as "lich king", but it gets the job done.

Comment 5 by ike posted on 11/13/2008 at 2:31 AM

That's just great! So "ColdFusion" as a product name works fine because it's one word, but "cold fusion" (as in the energy technology) is right out. For that matter "Transfer ORM" or "Ractor ORM" either... which are a pan to search on google because "transfer" and "reactor" are so common (minus the ORM)... Granted that on Youtube, you're search is likely to produce the Reactor ORM videos with keywords of "Reactor,ORM" and that's probably also true of "cold,fusion" ... still, I'm certain there are legitimate word-pairs that would fail on this design. Blech...

Comment 6 by Michael Sharman posted on 11/13/2008 at 3:10 AM

>Makes perfect sense to me. Their engine doesn't handle agglutinative terms.

That's my dictionary lookup for the day!

C'mon people admit it...how many of you also had to lookup "agglutinative"?

;)

Comment 7 by ike posted on 11/13/2008 at 3:17 AM

I just assumed it was a fancy way of saying "multi-word". ;)