Skip to content

Instantly share code, notes, and snippets.

@michael01angelo
Forked from takien/youtubeID.js
Last active April 15, 2018 23:10
Show Gist options
  • Select an option

  • Save michael01angelo/42a60f50127d505ec1b1facb552dd492 to your computer and use it in GitHub Desktop.

Select an option

Save michael01angelo/42a60f50127d505ec1b1facb552dd492 to your computer and use it in GitHub Desktop.

Revisions

  1. michael01angelo renamed this gist Apr 15, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion get_youtube_id → get_youtube_id.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,6 @@ function get_youtube_id(url){
    return id;
    }


    /*
    Tested URLs:
  2. michael01angelo renamed this gist Apr 15, 2018. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions youtubeID.js → get_youtube_id
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    function get_youtube_id(url){
    id = '';
    id = '';

    url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
    url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);

    if(url[2] !== undefined) {
    id = url[2].split(/[^0-9a-z_\-]/i);
    id = id.toString();
    }
    else id = url;
    if(url[2] !== undefined) {
    id = url[2].split(/[^0-9a-z_\-]/i);
    id = id.toString();
    }
    else id = url;

    return id;
    return id;
    }


  3. michael01angelo revised this gist Apr 15, 2018. 1 changed file with 10 additions and 16 deletions.
    26 changes: 10 additions & 16 deletions youtubeID.js
    Original file line number Diff line number Diff line change
    @@ -1,26 +1,20 @@
    /**
    * Get YouTube ID from various YouTube URL
    * @author: takien
    * @url: http://takien.com
    * For PHP YouTube parser, go here http://takien.com/864
    */

    function YouTubeGetID(url){
    var ID = '';
    function get_youtube_id(url){
    id = '';

    url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);

    if(url[2] !== undefined) {
    ID = url[2].split(/[^0-9a-z_\-]/i);
    ID = ID[0];
    }
    else {
    ID = url;
    id = url[2].split(/[^0-9a-z_\-]/i);
    id = id.toString();
    }
    return ID;
    else id = url;

    return id;
    }


    /*
    * Tested URLs:
    Tested URLs:
    var url = 'http://youtube.googleapis.com/v/4e_kz79tjb8?version=3';
    url = 'https://www.youtube.com/watch?feature=g-vrec&v=Y1xs_xPb46M';
  4. takien revised this gist Apr 8, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion youtubeID.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ function YouTubeGetID(url){
    var ID = '';
    url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
    if(url[2] !== undefined) {
    ID = url[2].split(/[^0-9a-z_]/i);
    ID = url[2].split(/[^0-9a-z_\-]/i);
    ID = ID[0];
    }
    else {
  5. takien revised this gist Nov 17, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions youtubeID.js
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    * Get YouTube ID from various YouTube URL
    * @author: takien
    * @url: http://takien.com
    * For PHP YouTube parser, go here http://takien.com/864
    */

    function YouTubeGetID(url){
  6. takien revised this gist Nov 15, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion youtubeID.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    function YouTubeGetID(url){
    var ID = '';
    url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
    if(url[2] != undefined) {
    if(url[2] !== undefined) {
    ID = url[2].split(/[^0-9a-z_]/i);
    ID = ID[0];
    }
  7. takien created this gist Nov 15, 2012.
    34 changes: 34 additions & 0 deletions youtubeID.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    /**
    * Get YouTube ID from various YouTube URL
    * @author: takien
    * @url: http://takien.com
    */

    function YouTubeGetID(url){
    var ID = '';
    url = url.replace(/(>|<)/gi,'').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
    if(url[2] != undefined) {
    ID = url[2].split(/[^0-9a-z_]/i);
    ID = ID[0];
    }
    else {
    ID = url;
    }
    return ID;
    }


    /*
    * Tested URLs:
    var url = 'http://youtube.googleapis.com/v/4e_kz79tjb8?version=3';
    url = 'https://www.youtube.com/watch?feature=g-vrec&v=Y1xs_xPb46M';
    url = 'http://www.youtube.com/watch?feature=player_embedded&v=Ab25nviakcw#';
    url = 'http://youtu.be/Ab25nviakcw';
    url = 'http://www.youtube.com/watch?v=Ab25nviakcw';
    url = '<iframe width="420" height="315" src="http://www.youtube.com/embed/Ab25nviakcw" frameborder="0" allowfullscreen></iframe>';
    url = '<object width="420" height="315"><param name="movie" value="http://www.youtube-nocookie.com/v/Ab25nviakcw?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/Ab25nviakcw?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
    url = 'http://i1.ytimg.com/vi/Ab25nviakcw/default.jpg';
    url = 'https://www.youtube.com/watch?v=BGL22PTIOAM&feature=g-all-xit';
    url = 'BGL22PTIOAM';
    */