Merge pull request #529 from Csineneo/patch-6

删去 tracker 服务器多余的「announce」
This commit is contained in:
栽培者 2021-05-09 08:05:46 +08:00 committed by GitHub
commit f28505e817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,7 @@ a.arguments.removed,transmission.torrents.splitid(),b&&b(a.arguments.torrents)):
this.removed[c],f.push(a);for(c in this.datas){a=this.datas[c];if(!a)return;if(-1!=$.inArray(a.id,f)&&0<f.length)this.all[a.id]&&(this.all[a.id]=null,delete this.all[a.id]),this.datas[c]=null,delete this.datas[c];else{this.isRecentlyActive&&!this.all[a.id]&&this.newIds.push(a.id);a=$.extend(this.all[a.id],a);0==a.uploadedEver&&0==a.downloadedEver&&(a.uploadRatio=-1);a.uploadRatio=parseFloat(a.uploadRatio);a.infoIsLoading=!1;var e=this.status[a.status];this.addTracker(a);e||(this.status[a.status]=
[],e=this.status[a.status]);this.totalSize+=a.totalSize;a.remainingTime=0<a.rateDownload&&0<a.leftUntilDone?Math.floor(a.leftUntilDone/a.rateDownload*1E3):0==a.rateDownload&&0==a.leftUntilDone&&0!=a.totalSize?0:31536E8;e.push(a);0!=a.error&&this.error.push(a);(0<a.rateUpload||0<a.rateDownload)&&this.actively.push(a);switch(a.status){case b.stopped:this.puased.push(a);break;case b.download:this.downloading.push(a)}this.all[a.id]=a;-1==$.inArray(a.downloadDir,transmission.downloadDirs)&&transmission.downloadDirs.push(a.downloadDir);
if(transmission.options.getFolders&&a.downloadDir){e=a.downloadDir.replace(/\\/g,"/").split("/");var l="folders-",h;for(h in e){var g=e[h];""!=g&&(g=d.encode(g),l+=g.replace(/[+|\/|=]/g,"0"),(g=this.folders[l])||(g={count:0,torrents:[],size:0,nodeid:l}),g.torrents.push(a),g.count++,g.size+=a.totalSize,this.folders[l]=g)}}this.count++}}transmission.downloadDirs=transmission.downloadDirs.sort();0<this.newIds.length&&this.getallids(null,this.newIds)},addTracker:function(b){var d=b.trackerStats,c=[];
b.leecherCount=0;b.seederCount=0;if(0<d.length){var a=[],f;for(f in d){var e=d[f],l=e.lastAnnounceResult.toLowerCase(),h=e.host.getHostName().split(".");-1!=$.inArray(h[0],["www","tracker"])&&h.shift();h=h.join(".");var g="tracker-"+h.replace(/\./g,"-"),k=transmission.trackers[g];k||(transmission.trackers[g]={count:0,torrents:[],size:0,connected:!0,isBT:5<d.length},k=transmission.trackers[g]);k.name=h;k.nodeid=g;k.host=e.host;e.lastAnnounceSucceeded||e.announceState==transmission._trackerStatus.inactive||
b.leecherCount=0;b.seederCount=0;if(0<d.length){var a=[],f;for(f in d){var e=d[f],l=e.lastAnnounceResult.toLowerCase(),h=e.host.getHostName().split(".");-1!=$.inArray(h[0],["www","tracker","announce"])&&h.shift();h=h.join(".");var g="tracker-"+h.replace(/\./g,"-"),k=transmission.trackers[g];k||(transmission.trackers[g]={count:0,torrents:[],size:0,connected:!0,isBT:5<d.length},k=transmission.trackers[g]);k.name=h;k.nodeid=g;k.host=e.host;e.lastAnnounceSucceeded||e.announceState==transmission._trackerStatus.inactive||
(a.push(e.lastAnnounceResult),"could not connect to tracker"==l&&(k.connected=!1));-1==k.torrents.indexOf(b)&&(k.torrents.push(b),k.count++,k.size+=b.totalSize);b.leecherCount+=e.leecherCount;b.seederCount+=e.seederCount;-1==c.indexOf(h)&&c.push(h)}5<d.length&&this.btItems.push(b);a.length==d.length&&(""==a.join(";").replace(/;/g,"")?b.warning="":b.warning=a.join(";"),b.nextAnnounceTime?b.nextAnnounceTime>e.nextAnnounceTime&&(b.nextAnnounceTime=e.nextAnnounceTime):b.nextAnnounceTime=e.nextAnnounceTime,
this.warning.push(b));0>b.leecherCount&&(b.leecherCount=0);0>b.seederCount&&(b.seederCount=0);b.leecher=b.leecherCount+" ("+b.peersGettingFromUs+")";b.seeder=b.seederCount+" ("+b.peersSendingToUs+")";b.trackers=c.join(";")}},getPeers:function(b){transmission.exec({method:"torrent-get",arguments:{fields:["peers","peersFrom"],ids:b}},function(b){console.log("data:",b)})},getMoreInfos:function(b,d,c){transmission.exec({method:"torrent-get",arguments:{fields:b.split(","),ids:d}},function(a){"success"==
a.result?c&&c(a.arguments.torrents):c&&c(null)})},search:function(b,d){if(!b)return null;d||(d=this.all);var c=[];$.each(d,function(a,f){-1!=d[a].name.toLowerCase().indexOf(b.toLowerCase())&&c.push(d[a])});return this.searchResult=c},getFiles:function(b,d){transmission.exec({method:"torrent-get",arguments:{fields:["files","fileStats"],ids:b}},function(b){"success"==b.result?d&&d(b.arguments.torrents):d&&d(null)})},getConfig:function(b,d){this.getMoreInfos(this.fields.config,b,d)},getErrorIds:function(b,