1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

y0u tub3 View Increaser FreePascal - Redo

Discussion in 'General Programming Chat' started by Redneck, Sep 22, 2008.

  1. Redneck

    Redneck Newbie

    Joined:
    May 24, 2008
    Messages:
    15
    Likes Received:
    2
    Location:
    South
    This is a simple y0u tub3 View Increaser. It was a quick little project
    I made to show everyone how to do it in FreePascal.
    I re-worked it and made sure that it ran on windows (XP Pro).

    This is a command line program. You will need
    FreePascal (FPC): h**p://www.freepascal.org/
    and cUrl: h**p://curl.haxx.se/

    I use Arch Linux, but this code should compile and run, with minimal modification, on
    any OS that you can install FPC and cUrl.

    Save the 2 code blocks into text files called:
    tubeincreasecl.pas
    and
    nusecurl.pas

    You will need to edit one line in the tubeincreasecl.pas file.
    Line #19 holds the path to your cUrl executable. You will need to
    set this to the path of cUrl on your system.
    On my windows box:
    cUrlLocation : string = 'C:\curl_718_2\curl.exe';
    On my Linux box:
    cUrlLocation : string = '/usr/bin/curl';

    NOTE: On Linux, in a terminal type "which curl" and it *should* tell you
    where it is.

    On Linux:
    Open a terminal, cd into the folder that has tubeincreasecl.pas & nusecurl.pas and type:
    "fpc tubeincreasecl.pas"
    and it will compile.

    On windows:
    Find out where your fpc.exe is. Mine is at
    C:\FPC\2.1.4\bin\i386-win32\fpc.exe

    The 2 sources file are in a folder at:
    C:\projects\tubeincreasercli\

    Click the Start button, click on Run, type "cmd" and hit Enter.
    In the cmd.exe window type:
    C:\FPC\2.1.4\bin\i386-win32\fpc.exe C:\projects\tubeincreasercli\tubeincreasecl.pas

    I am not sure how it is done on OSX. It should be the same as linux. I do have a couple
    OSX machines here, if anyone needs to know I will try it out.

    NOTE TO BOARD ADMINS:
    The following string:
    "http://www.you tube.com/watch?v=" (without the space)
    in the [ CODE ][ / CODE ] tags tries to load a youtube vid.

    Save this as "tubeincreasecl.pas"
    Code:
    {
    Tube Increase Command Line
    Made by: Redneck
    For: BlackHatWorld.com
    }
    program tubeincreasecl;
    
    {$mode objfpc}{$H+}
    
    uses
      {$IFDEF UNIX}{$IFDEF UseCThreads}
      cthreads,
      {$ENDIF}{$ENDIF}
      Classes, SysUtils, StrUtils, nusecurl;
      
    const
      appdirname: string = 'tubeincreasecl';
      version: string = '0.0.1';
      cUrlLocation : string = 'C:\curl_718_2\curl.exe';
      
    var
      cookkeefile, utubeurl, wrkfoldr, myvidid, mytstring: string;
      i, alladded, badget: integer;
      MycUrl: AbuseCurl;
      
    procedure WriteOutTmpLine(linetawriteout: string);
    begin
      write(#13'' + linetawriteout + DupeString(' ', 79 - Length(linetawriteout)));
    end;
    
    procedure WriteHelp;
    begin
      writeln('Basic usage: ',appdirname,' http://www.YoUtUbE.com/watch?v=YoUtUbE_uRl 100');
      writeln('Replace "http://www.YoUtUbE.com/watch?v=YoUtUbE_uRl" with your YouTube Url.');
      writeln('Replace "100" with the number of time you want the vid downloaded.');
    end;
    
    function GetTheVidCountstring(Linput: string): string;
    var
      turetrun: string;
    begin
       Linput := StringReplace(Linput, '"', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '''', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '<span id=watch-view-count>', 'DEJSUSER=', [rfReplaceAll]);
       turetrun := Copy(Linput, pos('DEJSUSER=', Linput) + 9, Length(Linput));
       turetrun := Copy(turetrun, 1, pos('<', turetrun) - 1);
       result := turetrun;
    end;
    
    function GetTheVidTextCommentCountstring(Linput: string): string;
    var
      turetrun: string;
    begin
       Linput := StringReplace(Linput, '"', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '''', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, 'Text Comments: <span class=number-of-comments>', 'DEJSUSER=', [rfReplaceAll]);
       turetrun := Copy(Linput, pos('DEJSUSER=', Linput) + 9, Length(Linput));
       turetrun := Copy(turetrun, 1, pos('<', turetrun) - 1);
       result := turetrun;
    end;
    
    function GetTheVidResponseCountstring(Linput: string): string;
    var
      turetrun: string;
    begin
       Linput := StringReplace(Linput, '"', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '''', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '<span id=watch-comments-numresponses>', 'DEJSUSER=', [rfReplaceAll]);
       turetrun := Copy(Linput, pos('DEJSUSER=', Linput) + 9, Length(Linput));
       turetrun := Copy(turetrun, 1, pos('<', turetrun) - 1);
       result := turetrun;
    end;
    
    procedure GetTheVidInfo;
    var
      durle, refferr, dgetetback, dlfile: string;
      tmploader: TStringList;
      i: integer;
    begin
      tmploader := TStringList.create;
      durle := utubeurl;
      refferr := 'http://www.google.com/search?hl=en&pwst=1&q=youtube+video&start=10&sa=N';
      dlfile := wrkfoldr + '/0fille.txt';
      if (FileExists(dlfile )) then DeleteFile(dlfile );
      dgetetback := MycUrl.DoTheCurl(durle, cUrlLocation, cookkeefile, refferr, '', '0', '', dlfile, 30, 30, 0);
      if (FileExists(dlfile)) then
      begin
        dgetetback := '';
        tmploader.LoadFromFile(dlfile);
        for i := 0 to tmploader.Count - 1 do
          dgetetback := dgetetback + tmploader[i] + #13+#10;
      end;
      if (FileExists(dlfile )) then DeleteFile(dlfile );
      if (pos('var swfArgs = {', dgetetback) <> 0) then
      begin
        WriteOutTmpLine('Views: ' + GetTheVidCountstring(dgetetback));
        writeln(' ');
        writeln('Comments: ', GetTheVidTextCommentCountstring(dgetetback));
        writeln('Responses: ', GetTheVidResponseCountstring(dgetetback));
      end
      else
      begin
        writeln('Cannot get info. Quitting!');
        halt;
      end;
    end;
    
    function GetTheVideoID(Linput: string): string;
    var
      turetrun: string;
    begin
       Linput := StringReplace(Linput, '"', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '''', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, 'video_id: ', 'DEJSUSER=', [rfReplaceAll]);
       turetrun := Copy(Linput, pos('DEJSUSER=', Linput) + 9, Length(Linput));
       turetrun := Copy(turetrun, 1, pos(',', turetrun) - 1);
       result := turetrun;
    end;
    
    function GetTheTstring(Linput: string): string;
    var
      turetrun: string;
    begin
       Linput := StringReplace(Linput, '"', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, '''', '', [rfReplaceAll, rfIgnoreCase]);
       Linput := StringReplace(Linput, ', t: ', 'DEJSUSER=', [rfReplaceAll]);
       turetrun := Copy(Linput, pos('DEJSUSER=', Linput) + 9, Length(Linput));
       turetrun := Copy(turetrun, 1, pos(',', turetrun) - 1);
       result := turetrun;
    end;
    
    procedure GetTheVidTandID;
    var
      durle, refferr, dgetetback, dlfile: string;
      tmploader: TStringList;
      i: integer;
    begin
      tmploader := TStringList.create;
      durle := utubeurl;
      refferr := 'http://www.google.com/search?hl=en&pwst=1&q=youtube+video&start=10&sa=N';
      dlfile := wrkfoldr + '/0fille.txt';
      if (FileExists(dlfile )) then DeleteFile(dlfile );
      dgetetback := MycUrl.DoTheCurl(durle, cUrlLocation, cookkeefile, refferr, '', '0', '', dlfile, 30, 30, 0);
      if (FileExists(dlfile)) then
      begin
        dgetetback := '';
        tmploader.LoadFromFile(dlfile);
        for i := 0 to tmploader.Count - 1 do
          dgetetback := dgetetback + tmploader[i] + #13+#10;
      end;
      if (FileExists(dlfile )) then DeleteFile(dlfile );
      if (pos('var swfArgs = {', dgetetback) <> 0) then
      begin
        myvidid := GetTheVideoID(dgetetback);
        mytstring := GetTheTstring(dgetetback);
      end
      else
      begin
        myvidid := '';
        mytstring := '';
      end;
    end;
    
    function GetTheVidFile: boolean;
    var
      durle, refferr, dgetetback, dlfile: string;
    begin
      durle := 'http://www.youtube.com/get_video?video_id=' + myvidid + '&t=' + mytstring + '&eurl=';
      refferr := utubeurl;
      dlfile := wrkfoldr + '/0fille.mp4';
      dgetetback := MycUrl.DoTheCurl(durle, cUrlLocation, cookkeefile, refferr, '', '0', '', dlfile, 30, 600, 0);
      if FileExists(dlfile) then
      begin
        DeleteFile(dlfile);
        result := True;
      end
      else
      begin
        result := False;
      end;
    end;
    
    begin
      if (Trim(ParamStr(1))='') or (pos(LowerCase('http://www.YoUtUbE.com/watch?v='), Trim(ParamStr(1))) = 0)  then
      begin
        WriteHelp;
        Halt;
      end;
      if (Trim(ParamStr(2))='') then
      begin
        i := 100;
      end
      else
      begin
        try
          i := strtoint(Trim(ParamStr(2)));
        except
          i := 100;
        end;
      end;
      wrkfoldr := Trim(GetEnvironmentVariable('HOME'));
      wrkfoldr := wrkfoldr + '/' + appdirname;
      if DirectoryExists(wrkfoldr) = False then CreateDir(wrkfoldr);
      cookkeefile := wrkfoldr + '/cookies.txt';
      if FileExists(cookkeefile) then DeleteFile(cookkeefile);
      utubeurl := Trim(ParamStr(1));
      writeln('Tube Increase CL Bot v', version);
      writeln('Url you gave: ', utubeurl);
      writeln('Times to download: ', i);
      WriteOutTmpLine('Getting info...');
      GetTheVidInfo;
      alladded := 1;
      badget := 0;
      Sleep(4000);
      repeat
        WriteOutTmpLine('Download #' + inttostr(alladded) + ' get Tstring and VidID');
        if FileExists(cookkeefile) then DeleteFile(cookkeefile);
        GetTheVidTandID;
        if (myvidid <> '') and (mytstring <> '') then
        begin
          WriteOutTmpLine('Download #' + inttostr(alladded) + ' getting video now');
          if (GetTheVidFile = True) then
            WriteOutTmpLine('Download #' + inttostr(alladded) + ' SUCCESS!')
          else
            WriteOutTmpLine('Download #' + inttostr(alladded) + ' FAILED!');
          Inc(alladded);
        end
        else
        begin
          WriteOutTmpLine('Download #' + inttostr(alladded) + ' Tstring and VidID: FAILED!');
          Inc(badget);
        end;
          if not (alladded > i) then Sleep(4000);
      until(alladded > i) or (badget > 10);
      if FileExists(cookkeefile) then DeleteFile(cookkeefile);
      writeln(' ');
      if (badget > 10) then
      begin
        writeln('Stopped. Too many failures.');
      end
      else
      begin
        writeln('Finished!');
      end;
      writeln('Failures: ' + inttostr(badget));
      writeln('Good Dls: ' + inttostr(alladded-1));
    end.
    
    Save this as "nusecurl.pas"
    Code:
    unit nusecurl;
    
    {$mode objfpc}{$H+}
    
    interface
    
    uses
      Classes, Process, SysUtils;
      
    type
      AbuseCurl = class
      private
        { private declarations }
      public
        function DoTheCurl(URL, curlpath, cookyfile, repherer, postvarstr, proxytype, proxieport, fillename: string; conntimeout, gettimeout, index: integer) : string;
        function NexecuteProgram(execstr: string) : string;
      end;
    
    implementation
    
    function AbuseCurl.DoTheCurl(URL, curlpath, cookyfile, repherer, postvarstr, proxytype, proxieport, fillename: string; conntimeout, gettimeout, index: integer) : string;
    var
      headers: string;
    begin
      headers := curlpath + ' ';
      
      headers := headers + '--header "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" ';
      headers := headers + '--header "Accept-Language: en-us,en;q=0.5" ';
      headers := headers + '--header "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" ';
      if (postvarstr <> '') and (pos('-F ', postvarstr) = 1) then
      begin
        headers := headers + '--header "Keep-Alive: 300" ';
        headers := headers + '--header "Connection: keep-alive" ';
        headers := headers + '--header "Expect:" ';
      end
      else
      begin
        headers := headers + '--header "Connection: Close" ';
      end;
      if (postvarstr <> '') and ((pos('--form-string ', postvarstr) = 1) or (pos('-F ', postvarstr) = 1)) then
        headers := headers + '--header "Content-Type: multipart/form-data" ';
        
      headers := headers + '--user-agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11" ';
      if (repherer <> '') then
        headers := headers + '--referer "' + repherer + '" ';
            
      if (proxytype = '4') then
        headers := headers + '--socks4 "' + proxieport + '" ';
      if (proxytype = '5') then
        headers := headers + '--socks5 "' + proxieport + '" ';
      if (proxytype = '2') then
        headers := headers + '--proxy "' + proxieport + '" ';
            
      headers := headers + '--connect-timeout "' + inttostr(conntimeout) + '" ';
      headers := headers + '--max-time "' + inttostr(gettimeout) + '" ';
      headers := headers + '--insecure ';
      headers := headers + '--location ';
      headers := headers + '--compressed ';
      headers := headers + '--cookie "' + cookyfile + '" ';
      headers := headers + '--cookie-jar "' + cookyfile + '" ';
          
      if not (postvarstr = '') then
      begin
        if (pos('--form-string ', postvarstr) = 1) or (pos('-F ', postvarstr) = 1) then
          headers := headers + postvarstr
        else
          headers := headers + '--data "' + postvarstr + '" ';
      end;
          
      if not (fillename = '') then
      begin
        headers := headers + '--output "' + fillename + '" ';
        headers := headers + '--write-out "' + fillename + '" ';
      end;
      
      headers := headers + '-silent --url "' + URL + '"';
    //  writeln(headers);
      result := NexecuteProgram(headers);
    end;
    
    function AbuseCurl.NexecuteProgram(execstr: string) : string;
    const
      READ_BYTES = 2048;
    var
      S: TStringList;
      M: TMemoryStream;
      P: TProcess;
      n: LongInt;
      BytesRead: LongInt;
      GiveBack: string;
    begin
      M := TMemoryStream.Create;
      BytesRead := 0;
      GiveBack := '';
      P := TProcess.Create(nil);
      P.CommandLine := execstr;
      P.Options := [poUsePipes];
      P.Execute;
      while P.Running do
      begin
        M.SetSize(BytesRead + READ_BYTES);
        n := P.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
        if n > 0 then
        begin
          Inc(BytesRead, n);
        end
        else
        begin
          Sleep(100);
        end;
      end;
      repeat
        M.SetSize(BytesRead + READ_BYTES);
        n := P.Output.Read((M.Memory + BytesRead)^, READ_BYTES);
        if n > 0 then
        begin
          Inc(BytesRead, n);
        end;
       until n <= 0;
       M.SetSize(BytesRead);
       S := TStringList.Create;
       S.LoadFromStream(M);
       for n := 0 to S.Count - 1 do
       begin
         GiveBack := GiveBack +S[n];
       end;
       S.Free;
       P.Free;
       M.Free;
       result := GiveBack;
    end;
    
    end.
    
     
  2. ooomph

    ooomph BANNED BANNED

    Joined:
    Feb 12, 2009
    Messages:
    98
    Likes Received:
    187
    would this still work? finally something i might be able to run on my mac :)