Skip to content

Commit 1386f1f

Browse files
committed
Added "grabbed" column to subscription results
1 parent aeaf1ad commit 1386f1f

15 files changed

+204
-24
lines changed

core/src/com/biglybt/core/content/RelatedContentSearcher.java

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@
709709

710710
return( new Long( 0 ));
711711
}
712+
case SearchResult.PR_COMPLETED_COUNT:{
713+
714+
return( new Long( -1 ));
715+
}
712716
case SearchResult.PR_PUB_DATE:{
713717

714718
long date = c.getPublishDate();

core/src/com/biglybt/core/metasearch/Result.java

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public abstract class
5656
public abstract int getNbPeers();
5757
public abstract int getNbSeeds();
5858
public abstract int getNbSuperSeeds();
59+
public abstract int getNbCompleted();
5960
public abstract int getComments();
6061
public abstract int getVotes();
6162
public abstract int getVotesDown();
@@ -283,6 +284,13 @@ public Map toJSONMap() {
283284
object.put("p","-1");
284285
}
285286

287+
int completed = getNbCompleted();
288+
289+
if ( completed >= 0 ) {
290+
291+
object.put( "gr", "" + completed); // grabbed
292+
}
293+
286294
int comments = getComments();
287295

288296
if ( comments >= 0 ){

core/src/com/biglybt/core/metasearch/impl/MetaSearchManagerImpl.java

+4
Original file line numberDiff line numberDiff line change
@@ -1921,6 +1921,10 @@ public void parameterChanged(String parameterName)
19211921

19221922
return( new Long( result.getNbSuperSeeds()));
19231923
}
1924+
case PR_COMPLETED_COUNT:{
1925+
1926+
return( new Long( result.getNbCompleted()));
1927+
}
19241928
case PR_CATEGORY:{
19251929

19261930
return( result.getCategory());

core/src/com/biglybt/core/metasearch/impl/plugin/PluginResult.java

+7
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@
143143
{
144144
return(getIntProperty( SearchResult.PR_SUPER_SEED_COUNT ));
145145
}
146+
147+
@Override
148+
public int
149+
getNbCompleted()
150+
{
151+
return(getIntProperty( SearchResult.PR_COMPLETED_COUNT ));
152+
}
146153

147154
@Override
148155
public int

core/src/com/biglybt/core/metasearch/impl/web/WebResult.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ public class WebResult extends Result {
5555
Date assetDate;
5656

5757
long size = -1;
58-
int nbPeers = -1;
59-
int nbSeeds = -1;
60-
int nbSuperSeeds = -1;
58+
59+
int nbPeers = -1;
60+
int nbSeeds = -1;
61+
int nbSuperSeeds = -1;
62+
int nbCompleted = -1;
63+
6164
int comments = -1;
62-
int votes = -1;
63-
int votesDown = -1;
64-
float rank = -1;
65+
int votes = -1;
66+
int votesDown = -1;
67+
float rank = -1;
6568

6669
boolean privateTorrent;
6770

@@ -205,6 +208,9 @@ public void setNbSuperSeedsFromHTML(String nbSuperSeeds) {
205208
}
206209
}
207210

211+
public void setNbCompleted( int num ){
212+
nbCompleted = num;
213+
}
208214
public void setRankFromHTML( String rank_str, float divisor ){
209215
if (rank_str == null) {
210216
return;
@@ -558,6 +564,11 @@ public int getNbSuperSeeds() {
558564
return nbSuperSeeds;
559565
}
560566

567+
@Override
568+
public int getNbCompleted(){
569+
return( nbCompleted );
570+
}
571+
561572
@Override
562573
public Date getPublishedDate() {
563574
return publishedDate;

core/src/com/biglybt/core/metasearch/impl/web/rss/RSSEngine.java

+31-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
{
5252
private Pattern seed_leecher_pat1 = Pattern.compile("([0-9]+)" + RegExUtil.PAT_WHITE_SPACE + "(seed|seeder|leech|leecher)s", Pattern.CASE_INSENSITIVE );
5353
private Pattern seed_leecher_pat2 = Pattern.compile("(seed|seeder|leech|leecher)s" + RegExUtil.PAT_WHITE_SPACE + "([0-9]+)", Pattern.CASE_INSENSITIVE );
54+
private Pattern completed_pat = Pattern.compile("(?:complete|completed)" + RegExUtil.PAT_WHITE_SPACE + "([0-9]+)", Pattern.CASE_INSENSITIVE );
5455

5556
private Pattern size_pat = Pattern.compile("([0-9\\.]+)" + RegExUtil.PAT_WHITE_SPACE + "(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)", Pattern.CASE_INSENSITIVE );
5657

@@ -353,11 +354,14 @@
353354

354355
int item_seeds = -1;
355356
int item_peers = -1;
357+
int item_completed = -1;
358+
356359
String item_hash = null;
357360
String item_magnet = null;
358361

359-
String desc_size = null;
360-
362+
String desc_size = null;
363+
int desc_completed = -1;
364+
361365
String potential_cdp_link = null;
362366

363367
SimpleXMLParserDocumentNode node = item.getNode();
@@ -615,6 +619,15 @@
615619
}catch( Throwable e ){
616620

617621
}
622+
}else if( lc_child_name.equals( "grabs" ) || lc_child_name.equals( "completed" )){
623+
624+
try{
625+
item_completed = Integer.parseInt( value );
626+
627+
}catch( Throwable e ){
628+
629+
}
630+
618631
}else if( lc_child_name.equals( "infohash" ) || lc_child_name.equals( "info_hash" )){
619632

620633
item_hash = value;
@@ -693,6 +706,17 @@
693706
}
694707
}
695708

709+
m = completed_pat.matcher( desc );
710+
711+
if ( m.find()){
712+
713+
try{
714+
desc_completed = Integer.parseInt(m.group(1));
715+
716+
}catch( Throwable e ){
717+
}
718+
}
719+
696720
m = size_pat.matcher( desc );
697721

698722
if ( m.find()){
@@ -895,6 +919,11 @@
895919
result.setTorrentLink( item_magnet );
896920
}
897921
}
922+
923+
if ( item_completed >= 0 || desc_completed >= 0) {
924+
925+
result.setNbCompleted( Math.max( item_completed, desc_completed ));
926+
}
898927

899928
// if we still have no download link see if the magnet is in the title
900929

core/src/com/biglybt/core/subs/impl/SubscriptionResultImpl.java

+3
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,9 @@
716716

717717
result.put( SearchResult.PR_LEECHER_COUNT, peers==null?-1:Long.parseLong(peers) );
718718

719+
String completed = (String)map.get( "gr" );
720+
721+
result.put( SearchResult.PR_COMPLETED_COUNT, completed==null?-1:Long.parseLong(completed) );
719722

720723
String votes = (String)map.get( "v" );
721724

core/src/com/biglybt/core/subs/util/SearchSubsResultBase.java

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
public long
5454
getSeedsPeersSortValue();
5555

56+
public int
57+
getNbCompleted();
58+
5659
public String
5760
getVotesComments();
5861

core/src/com/biglybt/core/subs/util/SubscriptionResultFilterable.java

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
private String seeds_peers;
5252
private int seed_count;
5353
private int peer_count;
54+
private int completed_count;
5455
private long votes_comments_sort;
5556
private String votes_comments;
5657
private int rank;
@@ -148,6 +149,8 @@
148149
long seeds = (Long)properties.get( SearchResult.PR_SEED_COUNT );
149150
long leechers = (Long)properties.get( SearchResult.PR_LEECHER_COUNT );
150151

152+
completed_count = ((Long)properties.get( SearchResult.PR_COMPLETED_COUNT )).intValue();
153+
151154
seed_count = (int)(seeds<0?0:seeds);
152155
peer_count = (int)(leechers<0?0:leechers);
153156

@@ -271,6 +274,13 @@
271274
return( seeds_peers_sort );
272275
}
273276

277+
@Override
278+
public int
279+
getNbCompleted()
280+
{
281+
return( completed_count );
282+
}
283+
274284
@Override
275285
public String
276286
getVotesComments()

core/src/com/biglybt/internat/MessagesBundle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -5553,6 +5553,7 @@ value.invalid.title=Invalid Value
55535553
value.invalid.text=Invalid value entered
55545554
enter.number=Enter Number
55555555
number.of.pieces=Number of Pieces
5556+
TableColumn.header.grabbed=Grabbed
55565557

55575558
#
55585559
#

core/src/com/biglybt/pif/utils/search/SearchResult.java

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
public static final int PR_ASSET_DATE = 24;
5353
public static final int PR_TAGS = 25; // String[]
5454

55+
public static final int PR_COMPLETED_COUNT = 26; // Long (-1 unknown)
56+
5557
// if you add more properties make sure you amend the mapping in PluginEngine appropriately
5658
// AND the reverse mapping in MetaSearchManagerImpl
5759
// AND generic XML attributes in xml-http plugin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) Azureus Software, Inc, All Rights Reserved.
3+
*
4+
* This program is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation; either version 2
7+
* of the License, or (at your option) any later version.
8+
* This program is distributed in the hope that it will be useful,
9+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
* GNU General Public License for more details.
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program; if not, write to the Free Software
14+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15+
*
16+
*/
17+
18+
package com.biglybt.ui.swt.columns.searchsubs;
19+
20+
21+
import com.biglybt.core.subs.util.SearchSubsResultBase;
22+
import com.biglybt.pif.ui.tables.*;
23+
24+
25+
public class ColumnSearchSubResultGrabbed
26+
implements TableCellRefreshListener, TableColumnExtraInfoListener
27+
{
28+
public static String COLUMN_ID = "grabbed";
29+
30+
31+
@Override
32+
public void fillTableColumnInfo(TableColumnInfo info) {
33+
info.addCategories(new String[] {
34+
TableColumn.CAT_CONTENT,
35+
});
36+
info.setProficiency(TableColumnInfo.PROFICIENCY_INTERMEDIATE);
37+
}
38+
39+
/** Default Constructor */
40+
public ColumnSearchSubResultGrabbed(TableColumn column) {
41+
column.initialize(TableColumn.ALIGN_CENTER, TableColumn.POSITION_INVISIBLE, 60 );
42+
column.setRefreshInterval(TableColumn.INTERVAL_INVALID_ONLY);
43+
column.addListeners(this);
44+
}
45+
46+
@Override
47+
public void refresh(TableCell cell) {
48+
SearchSubsResultBase result = (SearchSubsResultBase) cell.getDataSource();
49+
50+
long num = result.getNbCompleted();
51+
52+
if ( !cell.setSortValue(num) && cell.isValid()){
53+
54+
return;
55+
}
56+
57+
if (!cell.isShown()) {
58+
return;
59+
}
60+
61+
cell.setText( String.valueOf( num ));
62+
63+
return;
64+
65+
}
66+
}

uis/src/com/biglybt/ui/swt/search/SBC_SearchResult.java

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
private final long seeds_peers_sort;
4848
private final int seed_count;
4949
private final int peer_count;
50+
private final int completed_count;
5051
private final long votes_comments_sort;
5152
private final String votes_comments;
5253

@@ -107,6 +108,8 @@
107108

108109
seeds_peers_sort = ((seeds&0x7fffffff)<<32) | ( leechers & 0xffffffff );
109110

111+
completed_count = result.getNbCompleted();
112+
110113
long votes = result.getVotes();
111114
long comments = result.getComments();
112115

@@ -210,6 +213,13 @@
210213
return( seeds_peers_sort );
211214
}
212215

216+
@Override
217+
public int
218+
getNbCompleted()
219+
{
220+
return( completed_count );
221+
}
222+
213223
@Override
214224
public String
215225
getVotesComments()

uis/src/com/biglybt/ui/swt/search/SBC_SearchResultsView.java

+27-16
Original file line numberDiff line numberDiff line change
@@ -1010,27 +1010,38 @@ public void tableColumnCreated(TableColumn column) {
10101010
});
10111011

10121012
tableManager.registerColumn(
1013-
SBC_SearchResult.class,
1014-
ColumnSearchSubResultSeeds.COLUMN_ID,
1015-
new TableColumnCreationListener() {
1013+
SBC_SearchResult.class,
1014+
ColumnSearchSubResultSeeds.COLUMN_ID,
1015+
new TableColumnCreationListener() {
10161016

1017-
@Override
1018-
public void tableColumnCreated(TableColumn column) {
1019-
new ColumnSearchSubResultSeeds(column);
1020-
}
1021-
});
1017+
@Override
1018+
public void tableColumnCreated(TableColumn column) {
1019+
new ColumnSearchSubResultSeeds(column);
1020+
}
1021+
});
10221022

10231023
tableManager.registerColumn(
1024-
SBC_SearchResult.class,
1025-
ColumnSearchSubResultPeers.COLUMN_ID,
1026-
new TableColumnCreationListener() {
1024+
SBC_SearchResult.class,
1025+
ColumnSearchSubResultPeers.COLUMN_ID,
1026+
new TableColumnCreationListener() {
10271027

1028-
@Override
1029-
public void tableColumnCreated(TableColumn column) {
1030-
new ColumnSearchSubResultPeers(column);
1031-
}
1032-
});
1028+
@Override
1029+
public void tableColumnCreated(TableColumn column) {
1030+
new ColumnSearchSubResultPeers(column);
1031+
}
1032+
});
1033+
1034+
tableManager.registerColumn(
1035+
SBC_SearchResult.class,
1036+
ColumnSearchSubResultGrabbed.COLUMN_ID,
1037+
new TableColumnCreationListener() {
10331038

1039+
@Override
1040+
public void tableColumnCreated(TableColumn column) {
1041+
new ColumnSearchSubResultGrabbed(column);
1042+
}
1043+
});
1044+
10341045
tableManager.registerColumn(
10351046
SBC_SearchResult.class,
10361047
ColumnSearchSubResultRatings.COLUMN_ID,

0 commit comments

Comments
 (0)