Advertisement
Guest User

convert-mp3.html

a guest
May 24th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <!DOCtype html>
  2. <html lang="vi">
  3. <head>
  4. <title>Download mp3</title>
  5. <meta charset="utf-8">
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  7. </head>
  8. <body>
  9. <a id="download-mp3" href="javascript:;" data-id="VEqnueVkl-8">TαΊ£i</a>
  10. <div id="progress" style="display:none;">
  11. <span id="progress_text">Checking video syntax</span>
  12. <span id="progress_animation">...</span>
  13. </div>
  14. <a id="mp3-result" href="" target="_blank" rel="nofollow" style="display:none">Download</a>
  15. <script>
  16. $(document).ready(function() {
  17. var Conversion = false;
  18. var Complete = false;
  19. var Progress = '';
  20. function DownloadVideo(Sid, Hash) {
  21. clearInterval(Progress);
  22. $('#progress').hide();
  23. $('#mp3-result').attr('href', 'http://s' + Sid + '.youtube2mp3.cc/download.php?id=' + Hash);
  24. $('#mp3-result').show();
  25. }
  26. function ConvertVideo(Video, Hash) {
  27. var Steps = new Array('checking', 'loading', 'converting');
  28. $.ajax({
  29. url: 'http://d.youtube2mp3.cc/progress.php',
  30. dataType: 'jsonp',
  31. data: {
  32. id: Hash
  33. },
  34. success: function(Values) {
  35. var Data = {};
  36. $.each(Values, function(Name, Value) {
  37. Data[Name] = parseInt(Value);
  38. });
  39. switch (Data.progress) {
  40. case 0:
  41. case 1:
  42. case 2:
  43. $('#progress_text').html(Steps[Data.progress] + ' mp3');
  44. break;
  45. case 3:
  46. Complete = true;
  47. DownloadVideo(Data.sid, Hash);
  48. break;
  49. }
  50. if (!Complete) {
  51. window.setTimeout(function() {
  52. ConvertVideo(Video, Hash);
  53. }, 3000);
  54. }
  55. }
  56. });
  57. }
  58. function CheckVideo(Video, Format) {
  59. $.ajax({
  60. url: 'http://d.youtube2mp3.cc/check.php',
  61. dataType: 'jsonp',
  62. data: {
  63. v: Video,
  64. f: Format
  65. },
  66. success: function(Values) {
  67. var Data = {};
  68. $.each(Values, function(Name, Value) {
  69. Data[Name] = (Name == 'title' || Name == 'hash') ? Value : parseInt(Value);
  70. });
  71. if (0 < Data.ce && 0 < Data.sid) {
  72. DownloadVideo(Data.sid, Data.hash);
  73. } else {
  74. ConvertVideo(Video, Data.hash);
  75. }
  76. }
  77. });
  78. }
  79. function GetVideoId(Link) {
  80. if (new RegExp('youtube\.com').test(Link) && (Video = new RegExp(/v\=[a-zA-Z0-9\-\_]{11}/).exec(Link).toString())) {
  81. return Video.substr(2);
  82. } else if (new RegExp('youtu\.be').test(Link) && (Video = new RegExp(/\/[a-zA-Z0-9\-\_]{11}/).exec(Link).toString())) {
  83. return Video.substr(1);
  84. } else {
  85. return false;
  86. }
  87. }
  88. $('#download-mp3').click(function() {
  89. var Video = $(this).attr('data-id');
  90. Conversion = true;
  91. $('#progress').show();
  92. $('#mp3-result').hide();
  93. Progress = setInterval(function() {
  94. if ($('#progress_animation').html().length < 3) {
  95. $('#progress_animation').append('.');
  96. } else {
  97. $('#progress_animation').html('.');
  98. }
  99. }, 600);
  100. CheckVideo(Video, 'mp3');
  101. return false;
  102. });
  103. });
  104. </script>
  105. </body>
  106. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement