Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCtype html>
- <html lang="vi">
- <head>
- <title>Download mp3</title>
- <meta charset="utf-8">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- </head>
- <body>
- <a id="download-mp3" href="javascript:;" data-id="VEqnueVkl-8">TαΊ£i</a>
- <div id="progress" style="display:none;">
- <span id="progress_text">Checking video syntax</span>
- <span id="progress_animation">...</span>
- </div>
- <a id="mp3-result" href="" target="_blank" rel="nofollow" style="display:none">Download</a>
- <script>
- $(document).ready(function() {
- var Conversion = false;
- var Complete = false;
- var Progress = '';
- function DownloadVideo(Sid, Hash) {
- clearInterval(Progress);
- $('#progress').hide();
- $('#mp3-result').attr('href', 'http://s' + Sid + '.youtube2mp3.cc/download.php?id=' + Hash);
- $('#mp3-result').show();
- }
- function ConvertVideo(Video, Hash) {
- var Steps = new Array('checking', 'loading', 'converting');
- $.ajax({
- url: 'http://d.youtube2mp3.cc/progress.php',
- dataType: 'jsonp',
- data: {
- id: Hash
- },
- success: function(Values) {
- var Data = {};
- $.each(Values, function(Name, Value) {
- Data[Name] = parseInt(Value);
- });
- switch (Data.progress) {
- case 0:
- case 1:
- case 2:
- $('#progress_text').html(Steps[Data.progress] + ' mp3');
- break;
- case 3:
- Complete = true;
- DownloadVideo(Data.sid, Hash);
- break;
- }
- if (!Complete) {
- window.setTimeout(function() {
- ConvertVideo(Video, Hash);
- }, 3000);
- }
- }
- });
- }
- function CheckVideo(Video, Format) {
- $.ajax({
- url: 'http://d.youtube2mp3.cc/check.php',
- dataType: 'jsonp',
- data: {
- v: Video,
- f: Format
- },
- success: function(Values) {
- var Data = {};
- $.each(Values, function(Name, Value) {
- Data[Name] = (Name == 'title' || Name == 'hash') ? Value : parseInt(Value);
- });
- if (0 < Data.ce && 0 < Data.sid) {
- DownloadVideo(Data.sid, Data.hash);
- } else {
- ConvertVideo(Video, Data.hash);
- }
- }
- });
- }
- function GetVideoId(Link) {
- if (new RegExp('youtube\.com').test(Link) && (Video = new RegExp(/v\=[a-zA-Z0-9\-\_]{11}/).exec(Link).toString())) {
- return Video.substr(2);
- } else if (new RegExp('youtu\.be').test(Link) && (Video = new RegExp(/\/[a-zA-Z0-9\-\_]{11}/).exec(Link).toString())) {
- return Video.substr(1);
- } else {
- return false;
- }
- }
- $('#download-mp3').click(function() {
- var Video = $(this).attr('data-id');
- Conversion = true;
- $('#progress').show();
- $('#mp3-result').hide();
- Progress = setInterval(function() {
- if ($('#progress_animation').html().length < 3) {
- $('#progress_animation').append('.');
- } else {
- $('#progress_animation').html('.');
- }
- }, 600);
- CheckVideo(Video, 'mp3');
- return false;
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement