Author Topic: [Delphi] PirateBay Manager 0.8  (Read 2138 times)

0 Members and 1 Guest are viewing this topic.

Offline Doddy

  • Serf
  • *
  • Posts: 30
  • Cookies: 20
    • View Profile
[Delphi] PirateBay Manager 0.8
« on: February 14, 2014, 07:11:24 pm »
A simple Delphi program to search for torrents on PirateBay.

An image :



The source :

Code: [Select]
// PirateBay Manager 0.8
// (C) Doddy Hackman 2014

unit pirate;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, PerlRegEx, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient, IdHTTP, ComCtrls, sListView, sGroupBox, sListBox, ShellApi,
  sSkinManager, acPNG, ExtCtrls, sStatusBar, sEdit, sButton;

type
  TForm1 = class(TForm)
    IdHTTP1: TIdHTTP;
    PerlRegEx1: TPerlRegEx;
    sGroupBox1: TsGroupBox;
    sListView1: TsListView;
    sListBox1: TsListBox;
    sListBox2: TsListBox;
    sListBox3: TsListBox;
    PerlRegEx2: TPerlRegEx;
    sSkinManager1: TsSkinManager;
    Image1: TImage;
    sGroupBox2: TsGroupBox;
    sEdit1: TsEdit;
    sStatusBar1: TsStatusBar;
    sButton1: TsButton;
    procedure sListView1DblClick(Sender: TObject);
    procedure sButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  sSkinManager1.SkinDirectory := ExtractFilePath(Application.ExeName) + 'Data';
  sSkinManager1.SkinName := 'tv-b';
  sSkinManager1.Active := True;
end;

procedure TForm1.sButton1Click(Sender: TObject);
var
  busqueda: string;
  code: string;
  nombre: string;
  link_torrent: string;
  limpiando_data: string;
  data: string;
  seeders: string;
  leechers: string;
  i: integer;

begin

  sListBox1.Clear;
  sListBox2.Clear;
  sListBox3.Clear;
  sListView1.Clear;

  busqueda := sEdit1.Text;
  busqueda := StringReplace(busqueda, ' ', '%20', [rfReplaceAll, rfIgnoreCase]);

  sStatusBar1.Panels[0].Text := '[+] Searching ...';
  sStatusBar1.Update;

  code := IdHTTP1.Get('http://thepiratebay.se/search/' + busqueda + '/0/99/0');

  sStatusBar1.Panels[0].Text := '[+] Finished';
  sStatusBar1.Update;

  PerlRegEx1.Regex :=
    '(.*?)class="detLink" title="Details for (.*?)">(.*?)<a href="magnet(.*?)" title="Download this torrent using magnet"(.*?)<font class="detDesc">(.*?)<\/font>(.*?)<td align="right">(.*?)<\/td>(.*?)<td align="right">(.*?)<\/td>(.*?)';
  PerlRegEx1.Subject := code;

  while PerlRegEx1.MatchAgain do
  // if PerlRegEx1.Match then
  begin
    nombre := PerlRegEx1.SubExpressions[2];
    link_torrent := 'magnet' + PerlRegEx1.SubExpressions[4];
    limpiando_data := PerlRegEx1.SubExpressions[6];
    seeders := PerlRegEx1.SubExpressions[8];
    leechers := PerlRegEx1.SubExpressions[10];

    PerlRegEx2.Regex := '(.*), ULed by <';
    PerlRegEx2.Subject := limpiando_data;

    if PerlRegEx2.Match then
    begin
      limpiando_data := PerlRegEx2.SubExpressions[1];
      data := StringReplace(limpiando_data, '&nbsp;', '', [rfReplaceAll,
        rfIgnoreCase]);
      data := data + ', Seeders ' + seeders + ', Leechers ' + leechers;

    end;

    sListBox1.Items.Add(nombre);
    sListBox2.Items.Add(data);
    sListBox3.Items.Add(link_torrent);

  end;

  for i := 0 to sListBox1.Count - 1 do
  begin
    // ShowMessage(IntToStr(i));
    with sListView1.Items.Add do
    begin
      Caption := sListBox1.Items[i];
      SubItems.Add(sListBox2.Items[i]);
    end;
  end;
end;

procedure TForm1.sListView1DblClick(Sender: TObject);
begin
  // ShowMessage(sListBox3.Items[sListView1.Selected.Index]);
  ShellExecute(0, nil, PChar(sListBox3.Items[sListView1.Selected.Index]), nil,
    nil, SW_SHOWNORMAL);
end;

end.

// The End ?

Available for download here.

Offline iTpHo3NiX

  • EZ's Pirate Captain
  • Administrator
  • Titan
  • *
  • Posts: 2920
  • Cookies: 328
    • View Profile
    • EvilZone
Re: [Delphi] PirateBay Manager 0.8
« Reply #1 on: February 14, 2014, 08:04:36 pm »
Great share Doddy! +1

If you don't mind I have a couple of suggestions to help improve your app!

1. Add ability to add a socks proxy for those who have tpb blocked in their country
2. Add other public trackers such as kickasstorrents
3. Maybe an input to allow private trackers
4. Maybe an ssh tunnel option as well as a VPN/OpenVPN option
5. Ability to interface with seedbox server (something like a transdroid desktop app)

If I'd be able to use this to connect to my private trackers and add torrents to my seedbox it would be a very useful application to a lot of torrenters. We could search all of our sites. It would be awesome!
[09:27] (+lenoch) iTpHo3NiX can even manipulate me to suck dick
[09:27] (+lenoch) oh no that's voluntary
[09:27] (+lenoch) sorry

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: [Delphi] PirateBay Manager 0.8
« Reply #2 on: February 14, 2014, 08:21:46 pm »
Great effort, +1. However it's not exactly useful unless you make it search multiple sites to save time :)
It's so nice to see Delphi code, it has been some time since I last opened a delphi project :D
Btw why still Delphi? I have left it behind many years ago...
« Last Edit: February 14, 2014, 08:28:27 pm by Kulverstukas »

Offline Doddy

  • Serf
  • *
  • Posts: 30
  • Cookies: 20
    • View Profile
Re: [Delphi] PirateBay Manager 0.8
« Reply #3 on: February 14, 2014, 08:49:35 pm »
thanks for the suggestions.

Kulverstukas, that language would have to use? , I have planned to start in C#

Offline Matriplex

  • Knight
  • **
  • Posts: 323
  • Cookies: 66
  • Java
    • View Profile
Re: [Delphi] PirateBay Manager 0.8
« Reply #4 on: February 14, 2014, 08:50:12 pm »
Interesting, thanks for the share :)
+1
\x64\x6F\x75\x65\x76\x65\x6E\x00