Skip to content

Commit 3de1c9d

Browse files
[Issue GerryFerdinandus#12] Add trackers to multiple .torrent files without changing existing unique, individual trackers
Add two extra menu items under update torrent. User can select to add the new torrent list before or after the existing one.
1 parent 35855d0 commit 3de1c9d

File tree

3 files changed

+125
-11
lines changed

3 files changed

+125
-11
lines changed

enduser/readme.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,11 @@ Console parameter: -U3
8787
Console parameter: -U4
8888
Sort the trackers list by name.
8989

90+
Console parameter: -U5
91+
Append new trackers list BEFORE, the original trackers list inside the torrent file.
92+
Keep original tracker list unchanged and remove nothing.
93+
94+
Console parameter: -U6
95+
Append new trackers list AFTER, the original trackers list inside the torrent file.
96+
Keep original tracker list unchanged and remove nothing.
9097

source/code/main.lfm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object FormTrackerModify: TFormTrackerModify
2-
Left = 743
2+
Left = 1386
33
Height = 607
4-
Top = 103
4+
Top = 210
55
Width = 1179
66
AllowDropFiles = True
77
Caption = 'Bittorrent Tracker Editor'
@@ -16,7 +16,7 @@ object FormTrackerModify: TFormTrackerModify
1616
OnDropFiles = FormDropFiles
1717
OnShow = FormShow
1818
Position = poScreenCenter
19-
LCLVersion = '1.4.2.0'
19+
LCLVersion = '1.4.4.0'
2020
object PageControl: TPageControl
2121
Left = 0
2222
Height = 587
@@ -311,6 +311,10 @@ object FormTrackerModify: TFormTrackerModify
311311
Caption = 'And remove possible duplicated trackers from the NEW trackers list.'
312312
OnClick = MenuUpdateTorrentAddBeforeRemoveNewClick
313313
end
314+
object MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothing: TMenuItem
315+
Caption = 'Keep original tracker list unchanged and remove nothing.'
316+
OnClick = MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothingClick
317+
end
314318
end
315319
object MenuUpdateTorrentAddBefore: TMenuItem
316320
Caption = 'Append new trackers list &AFTER, the original trackers list inside the torrent file.'
@@ -322,6 +326,10 @@ object FormTrackerModify: TFormTrackerModify
322326
Caption = 'And remove possible duplicated trackers from the NEW trackers list.'
323327
OnClick = MenuUpdateTorrentAddAfterRemoveNewClick
324328
end
329+
object MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothing: TMenuItem
330+
Caption = 'Keep original tracker list unchanged and remove nothing.'
331+
OnClick = MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothingClick
332+
end
325333
end
326334
object MenuUpdateTorrentSort: TMenuItem
327335
Caption = '&Sort the trackers list by name.'

source/code/main.pas

Lines changed: 107 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,18 @@ interface
6666

6767
// Console parameter: -U4
6868
// Sort the trackers list by name.
69-
tloSort
69+
tloSort,
70+
71+
// Console parameter: -U5
72+
// Append new trackers list BEFORE, the original trackers list inside the torrent file.
73+
// Keep original tracker list unchanged and remove nothing.
74+
tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing,
75+
76+
// Console parameter: -U6
77+
// Append new trackers list AFTER, the original trackers list inside the torrent file.
78+
// Keep original tracker list unchanged and remove nothing.
79+
tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing
80+
7081
);
7182

7283

@@ -86,6 +97,8 @@ TFormTrackerModify = class(TForm)
8697
MenuFileTorrentFolder: TMenuItem;
8798
MenuFileOpenTrackerList: TMenuItem;
8899
MenuHelpReportingIssue: TMenuItem;
100+
MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothing: TMenuItem;
101+
MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothing: TMenuItem;
89102
MenuUpdateTorrentAddBeforeRemoveOriginal: TMenuItem;
90103
MenuUpdateTorrentAddAfterRemoveOriginal: TMenuItem;
91104
MenuUpdateTorrentAddBeforeRemoveNew: TMenuItem;
@@ -144,10 +157,14 @@ TFormTrackerModify = class(TForm)
144157
//Menu trackers
145158
procedure MenuTrackersAllTorrentArePublicPrivateClick(Sender: TObject);
146159
procedure MenuTrackersKeepOrDeleteAllTrackersClick(Sender: TObject);
160+
procedure MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothingClick(Sender: TObject
161+
);
147162

148163
//Menu update torrent
149164
procedure MenuUpdateTorrentAddAfterRemoveNewClick(Sender: TObject);
150165
procedure MenuUpdateTorrentAddAfterRemoveOriginalClick(Sender: TObject);
166+
procedure MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothingClick(Sender: TObject
167+
);
151168
procedure MenuUpdateTorrentAddBeforeRemoveNewClick(Sender: TObject);
152169
procedure MenuUpdateTorrentAddBeforeRemoveOriginalClick(Sender: TObject);
153170
procedure MenuUpdateTorrentSortClick(Sender: TObject);
@@ -239,8 +256,8 @@ implementation
239256
'udp://tracker.istole.it:80/announce'
240257
// 'udp://open.demonii.com:1337/announce'
241258
);
242-
//program name and version
243-
FORM_CAPTION = 'Bittorrent tracker editor (1.32 BETA)';
259+
//program name and version (http://semver.org/)
260+
FORM_CAPTION = 'Bittorrent tracker editor (1.32.0-RC.2)';
244261
TORRENT_FILES_CONTENTS_FORM_CAPTION =
245262
'Show all the files inside the torrents. (Use right mouse for popup menu.)';
246263

@@ -540,7 +557,7 @@ procedure TFormTrackerModify.UpdateTorrent;
540557
Continue;
541558

542559

543-
//tloSort it is already process. But it not tloSort then process it.
560+
//tloSort it is already process. But if not tloSort then process it.
544561
if FTrackerListOrderForUpdatedTorrent <> tloSort then
545562
begin
546563
//Add the new tracker before of after the original trackers inside the torrent.
@@ -612,12 +629,36 @@ procedure TFormTrackerModify.UpdateTorrent;
612629
end
613630
else
614631
begin
615-
//Via popup show user how many trackers are inside the torrent after update.
616-
PopUpMenuStr := 'All torrent file(s) have now ' + IntToStr(CountTrackers) +
617-
' trackers.';
632+
633+
case FTrackerListOrderForUpdatedTorrent of
634+
tloInsertNewBeforeAndKeepNewIntact,
635+
tloInsertNewBeforeAndKeepOriginalIntact,
636+
tloAppendNewAfterAndKeepNewIntact,
637+
tloAppendNewAfterAndKeepOriginalIntact,
638+
tloSort:
639+
begin
640+
//Via popup show user how many trackers are inside the torrent after update.
641+
PopUpMenuStr := 'All torrent file(s) have now ' + IntToStr(CountTrackers) +
642+
' trackers.';
643+
end;
644+
645+
tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing,
646+
tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing:
647+
begin
648+
//Via popup show user that all the torrent files are updated.
649+
PopUpMenuStr := 'All torrent file(s) are updated.';
650+
end;
651+
else
652+
begin
653+
Assert(True, 'case else: Should never been called. UpdateTorrent');
654+
end;
655+
end;
656+
657+
//Show the MessageBox
618658
Application.MessageBox(
619659
PChar(@PopUpMenuStr[1]),
620660
'', MB_ICONINFORMATION + MB_OK);
661+
621662
end;
622663

623664
end;
@@ -849,6 +890,8 @@ function TFormTrackerModify.DecodeConsoleUpdateParameter(
849890
2: FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepNewIntact;
850891
3: FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepOriginalIntact;
851892
4: FTrackerListOrderForUpdatedTorrent := tloSort;
893+
5: FTrackerListOrderForUpdatedTorrent := tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing;
894+
6: FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing;
852895
else
853896
begin
854897
//the number is out of range.
@@ -1034,7 +1077,7 @@ procedure TFormTrackerModify.CombineFiveTrackerListToOne(
10341077
TrackerDeselectTempList, TrackerFromInsideOneTorrentFile: TStringList;
10351078

10361079
begin
1037-
//The new trackers can be added at the begin of end of the list.
1080+
//The new trackers can be added at the begin or at the end of the list.
10381081

10391082
// FTrackerFinalList =
10401083
// (TrackerFromInsideOneTorrentFile
@@ -1152,6 +1195,46 @@ procedure TFormTrackerModify.CombineFiveTrackerListToOne(
11521195
FTrackerFinalList.Sort;
11531196
end;
11541197

1198+
tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing:
1199+
begin
1200+
//Before
1201+
1202+
//remove duplicate from the list that need to be added.
1203+
RemoveTrackersFromList(TrackerFromInsideOneTorrentFile, FTrackerAddedByUserList);
1204+
1205+
//Must be place as first FTrackerAddedByUserList.
1206+
for TrackerStr in FTrackerAddedByUserList do
1207+
AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1208+
1209+
//original tracker list is second place (Keep original intact)
1210+
for TrackerStr in TrackerFromInsideOneTorrentFile do
1211+
AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1212+
1213+
//Nothing should be removed
1214+
FTrackerManualyDeselectedByUserList.Clear;
1215+
end;
1216+
1217+
1218+
tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing:
1219+
begin
1220+
//After
1221+
1222+
//remove duplicate from the list that need to be added.
1223+
RemoveTrackersFromList(TrackerFromInsideOneTorrentFile, FTrackerAddedByUserList);
1224+
1225+
//original tracker list is first place (Keep original intact)
1226+
for TrackerStr in TrackerFromInsideOneTorrentFile do
1227+
AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1228+
1229+
//Must be place as second FTrackerAddedByUserList.
1230+
for TrackerStr in FTrackerAddedByUserList do
1231+
AddButIngnoreDuplicates(FTrackerFinalList, TrackerStr);
1232+
1233+
//Nothing should be removed
1234+
FTrackerManualyDeselectedByUserList.Clear;
1235+
end;
1236+
1237+
11551238
else
11561239
begin
11571240
Assert(True, 'case else: Should never been called. CombineFiveTrackerListToOne');
@@ -1349,6 +1432,14 @@ procedure TFormTrackerModify.MenuTrackersKeepOrDeleteAllTrackersClick(Sender: TO
13491432
CheckedOnOffAllTrackers(TMenuItem(Sender).Tag = 1);
13501433
end;
13511434

1435+
procedure TFormTrackerModify.MenuUpdateTorrentAddAfterKeepOriginalInstactAndRemoveNothingClick(
1436+
Sender: TObject);
1437+
begin
1438+
//User have selected to add new tracker.
1439+
FTrackerListOrderForUpdatedTorrent := tloAppendNewAfterAndKeepOriginalIntactAndRemoveNothing;
1440+
UpdateTorrent;
1441+
end;
1442+
13521443
procedure TFormTrackerModify.MenuUpdateTorrentAddAfterRemoveNewClick(Sender: TObject);
13531444
begin
13541445
//User have selected to add new tracker.
@@ -1364,6 +1455,14 @@ procedure TFormTrackerModify.MenuUpdateTorrentAddAfterRemoveOriginalClick(
13641455
UpdateTorrent;
13651456
end;
13661457

1458+
procedure TFormTrackerModify.MenuUpdateTorrentAddBeforeKeepOriginalInstactAndRemoveNothingClick(
1459+
Sender: TObject);
1460+
begin
1461+
//User have selected to add new tracker.
1462+
FTrackerListOrderForUpdatedTorrent := tloInsertNewBeforeAndKeepOriginalIntactAndRemoveNothing;
1463+
UpdateTorrent;
1464+
end;
1465+
13671466
procedure TFormTrackerModify.MenuUpdateTorrentAddBeforeRemoveNewClick(Sender: TObject);
13681467

13691468
begin

0 commit comments

Comments
 (0)