y0u tub3 View Increaser FreePascal

Redneck

Newbie
Joined
May 24, 2008
Messages
15
Reaction score
2
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.

My next code offering will be the same thing but with a GUI front end ;)

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 on any OS that you can install FPC and cUrl.

Save the code into a text file called "tubeincreasecl.pas"
On Linux, in a terminal, type:
"fpc tubeincreasecl.pas"
and it will compile.
I am not sure how it is done on windows or OSX. Google should help you.

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, libcurl, unixtype;
  
const
  appdirname: string = 'tubeincreasecl';
  version: string = '0.0.1';
  
var
  cookkeefile, utubeurl, wrkfoldr, myvidid, mytstring: string;
  i, alladded, badget: integer;
  
procedure WriteOutTmpLine(linetawriteout: string);
begin
  write(#13'' + linetawriteout + DupeString(' ', 79 - Length(linetawriteout)));
end;

function DoWrite(Ptr : Pointer; Size : size_t; nmemb: size_t; Data : Pointer) : size_t;cdecl;
begin
  Result:=TStream(Data).Write(Ptr^,Size*nmemb);
end;

function DoTheCurl(URL, workfldr, cookyfile, repherer, postvarstr, proxytype, proxieport, fillename: string; autoreph: boolean; timmeout: integer) : string;
var
  F : TFileStream;
  hCurl : pCurl;
  tmplist: TStringList;
  i: integer;
  allfile, savedfilename: string;
  K: Text;
  header : Pcurl_slist = Nil;
begin
  if (fillename = '') then
    savedfilename := workfldr + '/usecurl.html.tmp'
  else
    savedfilename := fillename;

  F := TFileStream.Create(savedfilename, fmCreate);
  try
    hCurl:= curl_easy_init;
    if Assigned(hCurl) then
      begin
      header := curl_slist_append(header, 'Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5');
      header := curl_slist_append(header, 'Accept-Language: en-us,en;q=0.5');
      header := curl_slist_append(header, 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7');
      header := curl_slist_append(header, 'Keep-Alive: 300');
      header := curl_slist_append(header, 'Connection: Close');

      if (repherer <> '') then
        curl_easy_setopt(hCurl, CURLOPT_REFERER, [PChar(repherer)]);

//      curl_easy_setopt(hCurl, CURLOPT_VERBOSE, [True]);
      curl_easy_setopt(hCurl, CURLOPT_URL,[PChar(URL)]);
  if not (proxytype = '0') then
  begin
      curl_easy_setopt(hCurl, CURLOPT_PROXY,[PChar(proxieport)]);
  if (proxytype = '4') then
      curl_easy_setopt(hCurl, CURLOPT_PROXYTYPE, [CURLPROXY_SOCKS4]);
  if (proxytype = '5') then
      curl_easy_setopt(hCurl, CURLOPT_PROXYTYPE, [CURLPROXY_SOCKS5]);
  if (proxytype = '2') then
      curl_easy_setopt(hCurl, CURLOPT_PROXYTYPE,[CURLPROXY_HTTP]);
  end;
      curl_easy_setopt(hCurl, CURLOPT_CONNECTTIMEOUT,[timmeout]);
      curl_easy_setopt(hCurl, CURLOPT_TIMEOUT,[timmeout]);
      curl_easy_setopt(hCurl, CURLOPT_SSL_VERIFYPEER, [FALSE]);
      curl_easy_setopt(hCurl, CURLOPT_NOSIGNAL,[1]);
      curl_easy_setopt(hCurl, CURLOPT_HTTPHEADER, [header]);
      if (autoreph = True) then
      curl_easy_setopt(hCurl, CURLOPT_AUTOREFERER,[1]);
      curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION,[1]);
      curl_easy_setopt(hCurl, CURLOPT_ENCODING, [PChar('')]);
      curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION,[@DoWrite]);
      curl_easy_setopt(hCurl, CURLOPT_WRITEDATA,[Pointer(F)]);
      curl_easy_setopt(hCurl, CURLOPT_USERAGENT, [PChar('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')]);
      curl_easy_setopt(hCurl, CURLOPT_COOKIEFILE, [PChar(cookyfile)]);
      curl_easy_setopt(hCurl, CURLOPT_COOKIEJAR, [PChar(cookyfile)]);
      if not (postvarstr = '') then
      begin
        curl_easy_setopt(hCurl, CURLOPT_POST, [1]);
        curl_easy_setopt(hCurl, CURLOPT_POSTFIELDS,[PChar(postvarstr)]);
      end;
      curl_easy_perform(hCurl);
      curl_easy_cleanup(hCurl);
      end;
  finally
    F.Free;
    if (fillename = '') then
    begin
      tmplist := TStringList.Create;
      allfile := '';
      tmplist.LoadFromFile(savedfilename);
      for i := 0 to tmplist.Count - 1 do
        allfile := allfile + tmplist[i];

      Assign (K, savedfilename);
      Erase(K);
      FreeAndNil(tmplist);
      result := allfile;
    end
    else
    begin
      result := fillename;
    end;
  end;
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>', '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: string;
begin
  durle := utubeurl;
  refferr := 'http://www.google.com/search?hl=en&pwst=1&q=youtube+video&start=10&sa=N';
  dgetetback := DoTheCurl(durle, wrkfoldr, cookkeefile, refferr, '', '0', '', '', True, 30);
  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: string;
begin
  durle := utubeurl;
  refferr := 'http://www.google.com/search?hl=en&pwst=1&q=youtube+video&start=10&sa=N';
  dgetetback := DoTheCurl(durle, wrkfoldr, cookkeefile, refferr, '', '0', '', '', True, 30);
  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 := DoTheCurl(durle, wrkfoldr, cookkeefile, refferr, '', '0', '', dlfile, True, 30);
  if FileExists(dlfile) then
  begin
    DeleteFile(dlfile);
    result := True;
  end
  else
  begin
    result := False;
  end;
end;

begin
  if (Trim(ParamStr(1))='') or (pos('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.
 
Back
Top