YouTube = {} --YouTube Downloader Example Provided By: LunaStudios Software Inc. --If You Need Futhur Assistance Please Dont Hesitate To Contact Me: drummernath@live.co.uk --YouTube Video Download Function Called By: YouTube.Download("http://www.youtube.com/watch?v=NGI0jlz22Dg"); function YouTube.Download(link) Cancelled = false testvideo = HTTP.TestConnection(link, 20, 80, nil, nil); if testvideo == true then video_id = String.Find(link, "v=", 1, false); video_id = String.Mid(link, video_id+2, String.Find(link, "\r\n", 1, false)); video_path = HTTP.Submit(link, {}, SUBMITWEB_POST, 20, 80, nil, nil); tstart = String.Find(video_path, "rv.2.length_seconds", 1, false); tend = String.Find(video_path, ",", 1, false); tvalue = String.Mid(video_path, tstart+34, tend-1); if downloadpath == nil then --Download Path Is Set Here-------------------------------------------------- downloadpath = Dialog.FolderBrowse("Select Download Location:", "").."\\"..Math.Random(1, 1000000)..".flv" ----------------------------------------------------------------------------- end Window.SetSize(Application.GetWndHandle(), winsize.Width, winsize.Height); Progress.SetVisible("progress", true); Image.SetVisible("1", true); Image.SetVisible("2", true); Image.SetVisible("3", true); Image.SetVisible("4", true); Paragraph.SetVisible("filesize", true); Paragraph.SetVisible("transferspeed", true); Paragraph.SetVisible("secondsleft", true); Paragraph.SetVisible("fileprogress", true); Input.SetEnabled("url", false); WinButton.SetText("download_button", "Cancel"); HTTP.Download("http://www.youtube.com/get_video?video_id="..video_id.."&t="..tvalue.."", downloadpath, MODE_BINARY, 20, 80, nil, nil, DownloadCallback); Window.SetSize(Application.GetWndHandle(), winsize.Width, winsize.Height-25); WinButton.SetText("download_button", "Download"); Image.SetVisible("1", false); Image.SetVisible("2", false); Image.SetVisible("3", false); Image.SetVisible("4", false); Progress.SetVisible("progress", false); Paragraph.SetVisible("filesize", false); Paragraph.SetVisible("transferspeed", false); Paragraph.SetVisible("secondsleft", false); Paragraph.SetVisible("fileprogress", false); Input.SetEnabled("url", true); if Cancelled ~= true and File.DoesExist(downloadpath) == true then confirm = Dialog.Message("YouTube Downloader", "Video Downloaded, Play Now?", MB_YESNO, MB_ICONINFORMATION, MB_DEFBUTTON1); if confirm == 6 then Shell.Execute(downloadpath, "open", "", downloadpath, SW_SHOWNORMAL, false); end end elseif testvideo == false then Dialog.Message("YouTube Downloader", "Invalid URL", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end end --Download Callback Function function DownloadCallback(nDownloaded, nTotal, TransferRate, SecondLeft, SecondsLeftFormat, Message) progress = nDownloaded/nTotal*100 Progress.SetCurrentPos("progress", progress); Paragraph.SetText("filesize", String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true)); Paragraph.SetText("transferspeed", String.GetFormattedSize(TransferRate, FMTSIZE_AUTOMATIC, true)); Paragraph.SetText("secondsleft", SecondsLeftFormat); Paragraph.SetText("fileprogress", ""..String.GetFormattedSize(nDownloaded, FMTSIZE_AUTOMATIC, true).." / "..String.GetFormattedSize(nTotal, FMTSIZE_AUTOMATIC, true)..""); if(Cancelled)then if File.DoesExist(downloadpath) == true then File.Delete(downloadpath, true, false, true, nil); end return false; end end