Advertisement
suprianto

tembah regex download youtube

Oct 17th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. use LWP::Simple;
  2. use CGI qw/unescape/;
  3. $|=1;
  4. while (<>) {
  5. @X = split;
  6.  
  7. if ( $X[0] =~ m/^http\:\/\/.*/) {
  8. $x = $X[0];
  9. $_ = $X[0];
  10. $u = $X[0];
  11. } else {
  12. $x = $X[1];
  13. $_ = $X[1];
  14. $u = $X[1];
  15. @slices = m/[^\/\&]?(slices[^\/]*)/;
  16. }
  17.  
  18. if (m/(videoplayback|liveplay|videogoodput).*[&?](title=[^\&\s]*)/) {
  19. @itag = m/[&?](itag=[0-9]*)/;
  20. @title = m/[&?]title=([^\&\s]*)/;
  21. my $title = unescape(@title);
  22. $title =~ s/(WWW.DOWNVIDS.NET-|\s\[www.videograbber.net\])//g;
  23. $title =~ s/(\s\+)/\_/g;
  24. my ($type, $size) = head($x);
  25.  
  26. $out="OK store-id=http://video-down.youtube.squid.internal/title=" . $title . "&@itag&size=" . $size . "-byte";
  27.  
  28. } elsif ($x =~ m/^https?\:\/\/[^\/]*(youtube|gstatic|google).*(ptracking|stream_204|playback|player_204|gen_204|watchtime|set_awesome|get_video|get_video_info|s\?|ads|qoe|csi).*(video_id|docid|\&v|content_v)\=([^\&\s]*).*/){
  29. $vid = $4 ;
  30. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  31. if (defined($vid )) {
  32. $fn = "/tmp/@cpn";
  33. unless (-e $fn) {
  34. open FH,">".$fn ;
  35. print FH "$vid\n";
  36. close FH;
  37. }
  38. }
  39. $out=$x . "\n";
  40.  
  41. } elsif ($x =~ m/^https?\:\/\/.*(youtube|google|gstatic).*(videoplayback|liveplay|videogoodput).*/) {
  42. @itag = m/[&?](itag=[0-9]*)/;
  43. @ids = m/[&?]id\=([^\&\s]*)/;
  44. @mime = m/[&?](mime\=[^\&\s]*)/;
  45. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  46. @range = m/[&?](range=[^\&\s]*)/;
  47. if (defined($cpn[0])) {
  48. $fn = "/tmp/@cpn";
  49. if (-e $fn) {
  50. open FH,"<".$fn ;
  51. $id = <FH>;
  52. chomp $id ;
  53. close FH ;
  54. } else {
  55. $id = $ids[0] ;
  56. }
  57. } else {
  58. $id = $ids[0] ;
  59. }
  60. @range = m/[&?](range=[^\&\s]*)/;
  61. $out="http://video-srv.youtube.com.squid.internal/id=" . $id . "&@itag@range@mime\n";
  62.  
  63.  
  64. } else {
  65. $out=$x;
  66.  
  67. }
  68. if ( $X[0] =~ m/^http\:\/\/.*/) {
  69. print "OK store-id=$out\n" ;
  70. } else {
  71. print $X[0] . " OK store-id=$out\n" ;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement