Advertisement
Guest User

Trollvids Sauce Finder (Source Code)

a guest
Sep 5th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********************************
  2.     Trollvids Sauce Finder
  3.     v1.0 (Initial Release)
  4.     9/5/2014
  5.    
  6.     Gets download links from
  7.     trollvids.com videos
  8. ********************************/
  9.  
  10. // Search page for video source
  11. function main(){
  12.     var player_container = $('.watch_left .player_container');
  13.     if (player_container.find('iframe').length){
  14.         // Video Sources:
  15.         //      -Google videos
  16.         var vid_id = player_container.find('iframe').attr('src').match(/file\/d\/(.*)\/preview/)[1];
  17.         if (!vid_id){
  18.             modal.open("Video Not Found", "Couldn't find the video source. Sorry!");
  19.             return false;
  20.         }
  21.         var vid_path = "https://docs.google.com/uc?id="+vid_id+"&export=download";
  22.         modal.open("Video Found", "<a href='"+vid_path+"' target='_blank'>Google Video</a>");
  23.     } else if (player_container.find('#nuevoplayer_top').length){
  24.         // Video Sources:
  25.         //      -YouTube
  26.         //      -Hosted on site
  27.         var vid_id = document.URL.match(/video\/(.*)\//)[1];
  28.         var nuevo_url = "/nuevo/player/config.php";
  29.         $.ajax({
  30.             url: nuevo_url,
  31.             data: {v: vid_id},
  32.             success: function(data){
  33.                 data = $(data);
  34.                
  35.                 // Check for SD video (usually a .flv)
  36.                 var file_sd_path = data.find('config file').text();
  37.                 var header = "Video Found";
  38.                 var content = "";
  39.                 if (file_sd_path){
  40.                     if (file_sd_path.indexOf('.flv') > -1){
  41.                         // FLV source
  42.                         content += "<a href='"+file_sd_path+"' target='_blank'>Download (SD FLV)</a>";
  43.                     } else if (file_sd_path.indexOf('.mp4') > -1) {
  44.                         // MP4 source
  45.                         content += "<a href='"+file_sd_path+"' target='_blank'>Download (SD MP4)</a>";
  46.                     } else if (file_sd_path.indexOf('youtube') > -1){
  47.                         // YouTube Video source
  48.                         content += "<a href='"+file_sd_path+"' target='_blank'>YouTube Video</a>";
  49.                     } else {
  50.                         content += "<a href='"+file_sd_path+"' target='_blank'>Download (SD)</a>";
  51.                     }
  52.                 }
  53.                
  54.                 // Check for HD video (.mp4)
  55.                 var file_hd_path = data.find('config filehd').text();
  56.                 if (file_hd_path){
  57.                     content += "<a href='"+file_hd_path+"' target='_blank'>Download (HD MP4)</a>";
  58.                 }
  59.                
  60.                 // Display failure message
  61.                 if (content == ""){
  62.                     header = "Video Not Found";
  63.                     content += "<p>Couldn't find the video source. Sorry!</p>";
  64.                 }
  65.                
  66.                 // Extra info
  67.                 content += "<br><a href='"+nuevo_url+"?v="+vid_id+"' target='_blank'>View video config data</a>";
  68.                 content += "<i class='muted'>Note: Some video sources may be missing due to site issues.</i>";
  69.                
  70.                 modal.open(header, content);
  71.             }
  72.         });
  73.     } else {
  74.         // Failsafe in case there's a new video embed format
  75.         // that this script doesn't include
  76.         modal.open("Video Not Found", "This embedded video format hasn't been coded into this script!");
  77.     }
  78. }
  79.  
  80. // Instantiate modal code and stuff
  81. if (typeof modal === 'undefined'){
  82.     var modal = {};
  83.         modal.object;
  84.    
  85.     // Close modal object
  86.     modal.close = function(){
  87.         if (modal.object){
  88.             modal.object.fadeOut(200, function(){
  89.                 $(this).remove();
  90.             });
  91.             modal.object = null;
  92.         }
  93.     }
  94.    
  95.     // Some extra modal styling
  96.     $("<style>.muted{color:#777;font-size:13px;}.modal_container a{color:#aaa; display: block; margin-bottom: 5px;}.modal_container a:hover{color:#ccc;}.modal_close{color:#aaa;}.modal_close:hover{color:#ccc;}</style>").appendTo('body');
  97.    
  98.     // Create modal with header text and main content
  99.     modal.open = function(header, content){
  100.         // Close existing modal
  101.         modal.close();
  102.        
  103.         // Contains all subsequent modal elements and darkens screen
  104.         var modal_container = $("<div class='modal_container'>").css({
  105.             'position': 'fixed',
  106.             'top': 0,
  107.             'right': 0,
  108.             'bottom': 0,
  109.             'left': 0,
  110.             'z-index': 1050,
  111.             'outline': 0,
  112.             'display': 'block',
  113.             'background-color': 'rgba(0, 0, 0, .5)'
  114.         });
  115.        
  116.         // Centered box
  117.         var modal_dialogue = $("<div class='modal_dialogue'>").css({
  118.             'background-color': '#222',
  119.             'color': '#eee',
  120.             'width': '600px',
  121.             'height': '200px',
  122.             'margin': '30px auto',
  123.             'font-size': '14px',
  124.             'position': 'relative',
  125.             'box-shadow': '0 2px 6px rgba(0, 0, 0, .7)'
  126.         });
  127.        
  128.         // Header text
  129.         var modal_header = $("<div class='modal_header'>").css({
  130.             'border-bottom': '1px solid #444',
  131.             'padding': '8px',
  132.             'font-size': '20px'
  133.         });
  134.        
  135.         // Main content
  136.         var modal_content = $("<div class='modal_content'>").css({
  137.             'padding': '8px',
  138.             'font-size': '14px'
  139.         });
  140.        
  141.         // Close button
  142.         var modal_close = $("<div class='modal_close'>&times;</div>").css({
  143.             'position': 'absolute',
  144.             'top': 0,
  145.             'right': 0,
  146.             'margin': '2px 8px',
  147.             'font-size': '30px',
  148.             'cursor': 'pointer'
  149.         });
  150.         modal_close.click(modal.close);
  151.        
  152.         // Put it all together
  153.         modal_header.html(header);
  154.         modal_content.html(content);
  155.        
  156.         modal_dialogue.append(modal_close);
  157.         modal_dialogue.append(modal_header);
  158.         modal_dialogue.append(modal_content);
  159.        
  160.         modal_container.append(modal_dialogue);
  161.        
  162.         // Show it
  163.         $('body').append(modal_container);
  164.         modal.object = modal_container;
  165.         modal.object.hide();
  166.         modal.object.fadeIn(200);
  167.     }
  168.  
  169.     $(document).mouseup(function(e){
  170.         if ($(e.target).hasClass('modal_container')) modal.close();
  171.     });
  172. }
  173.  
  174. // Run main function
  175. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement