|
/* Get YouTube tags, number them and display each on its own line |
|
(Press F12 in your browser to see the results) |
|
|
|
@Creator: Eric Hepperle (CodeWizard13/CodeSlayer2010) |
|
@Date: 02/14/15 |
|
|
|
@Purpose: This is a totally revised version of my previous 2013 gist: |
|
GetYouTubeTagsAsCSV. In the almost 2 years since, YouTube has |
|
changed the way tags are stored, once again. Currently the |
|
tags are being held in the Meta value "keywords", so what I'many |
|
doing is grabbing the content, which is ALREADY IN CSV form. So, |
|
what else did I do to make this more useful? Not much... Just |
|
using a for loop to list each keyword (with quotes and |
|
preceding/trailing spaces stripped), numbered, on its own line. |
|
|
|
For some reason, YouTube isn't listing all the keywords in the |
|
meta tag; they are chopped off--probably using a max_character_count |
|
type of variable--and the last displayed keyword has an ellipsis |
|
appended. To go further, I discovered that the keywords are being |
|
stored as json, but I'm not a json expert and supper awaits, so |
|
grabbing *ALL* the keywords could be done if I could figure out how |
|
to handle the json... perhaps that will be the next revision. |
|
|
|
Overall, I'm pretty happy with how simple this was to write. Enjoy! :) |
|
*/ |
|
|
|
console.clear(); // clear console |
|
|
|
var result = $("meta[name='keywords']").attr('content'); |
|
|
|
// split result string into tags |
|
var tags = result.split(', '); |
|
|
|
// declare a variable to accumulate output |
|
var out = ''; |
|
|
|
console.log("I found the following " + tags.length + " YouTube tags:") // how many tags do I have? |
|
|
|
for (i=0;i<tags.length;++i) { |
|
out += i+1 + ": " + tags[i] + "\n"; |
|
|
|
} |
|
|
|
// output results |
|
console.log(out) |