youtube to mp4 stackoverflow

var links = new String();
var downlink = new String();
var has22 = new Boolean();
has22 = false;
var Marked = false;

var FMT_DATA = fmt_url_map;//This is html text that you have to grab. In case of extension it was readily available through:document.getElementsByTagName('script');

var StrSplitter1 = '%2C', StrSplitter2 = '%26', StrSplitter3 = '%3D';
if (FMT_DATA.indexOf(',') > -1) { //Found ,
    StrSplitter1 = ',';
    StrSplitter2 = (FMT_DATA.indexOf('&') > -1) ? '&' : '\\u0026';
    StrSplitter3 = '=';
}

var videoURL = new Array();
var FMT_DATA_PACKET = new Array();
var FMT_DATA_PACKET = FMT_DATA.split(StrSplitter1);

for (var i = 0; i < FMT_DATA_PACKET.length; i++) {
    var FMT_DATA_FRAME = FMT_DATA_PACKET[i].split(StrSplitter2);
    var FMT_DATA_DUEO = new Array();

    for (var j = 0; j < FMT_DATA_FRAME.length; j++) {
        var pair = FMT_DATA_FRAME[j].split(StrSplitter3);
        if (pair.length == 2) {
            FMT_DATA_DUEO[pair[0]] = pair[1];
        }
    }

    var url = (FMT_DATA_DUEO['url']) ? FMT_DATA_DUEO['url'] : null;

    if (url == null) continue;
    url = unescape(unescape(url)).replace(/\\\//g, '/').replace(/\\u0026/g, '&');
    var itag = (FMT_DATA_DUEO['itag']) ? FMT_DATA_DUEO['itag'] : null;
    var itag = (FMT_DATA_DUEO['itag']) ? FMT_DATA_DUEO['itag'] : null;
    if (itag == null) continue;
    var signature = (FMT_DATA_DUEO['sig']) ? FMT_DATA_DUEO['sig'] : null;
    if (signature != null) {
        url = url + "&signature=" + signature;
    }
    if (url.toLowerCase().indexOf('http') == 0) { // validate URL 

        if (itag == '5') {
            links += '<a href="' + url + '&title=' + username + title + quality240 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v240p">FLV (240p)</span></a>';
        }
        if (itag == '18') {
            links += '<a href="' + url + '&title=' + username + title + quality360 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v360p">MP4 (360p)</span></a>';
        }
        if (itag == '35') {
            links += '<a href="' + url + '&title=' + username + title + quality480 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v480p">FLV (480p)</span></a>';
        }
        if (itag == '22') {
            links += '<a href="' + url + '&title=' + username + title + quality720 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v720p">MP4 HD (720p)</span></a>';
        }
        if (itag == '37') {
            links += ' <a href="' + url + '&title=' + username + title + quality1080 + '"style="text-decoration:none"><span class="yt-uix-button-menu-item" id="v1080p">MP4 HD (1080p)</span></a>';
        }
        if (itag == '38') {
            links += '<a href="' + url + '&title=' + username + title + quality4k + '"style="text-decoration:none"><span class="yt-uix-button-menu-item"  id="v4k">MP4 HD (4K)</span></a>';
        }

        FavVideo();
        videoURL[itag] = url;
        console.log(itag);
    }
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source