Skip to content

Commit

Permalink
add START_SEED_PERCENT
Browse files Browse the repository at this point in the history
  • Loading branch information
Vance-ng-vn committed Feb 2, 2024
1 parent 8ce22b2 commit b63c2ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ This extension will auto update files from the Stremio Cache to the qBittorrent
4. Save! Restart Stremio.

**CONFIG**
`START_SEED_PERCENT` Accept seed files that have been downloaded X%, 0 < X <= 100. Default is 90%
`INTERVAL_CHECK` sec/min/hour/day leave empty to disable
`CACHE_DIR` your Stremio's cache dir (path/to/stremio-cache) leave empty to use dedault cache dir
`CUSTOM_CACHE_SIZE` kb/mb/gb/tb Overide Stremio Cache-Size Settings
Expand Down
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ if(INTERVAL_CHECK?.match(/min/i)) INTERVAL_CHECK = parseFloat(INTERVAL_CHECK) *
if(INTERVAL_CHECK?.match(/hour/i)) INTERVAL_CHECK = parseFloat(INTERVAL_CHECK) * 60 * 60 * 1000; else
if(INTERVAL_CHECK?.match(/day/i)) INTERVAL_CHECK = parseFloat(INTERVAL_CHECK) * 24 * 60 * 60 * 1000;

const START_SEED_PERCENT = process.env.START_SEED_PERCENT ? 0 < parseInt(process.env.START_SEED_PERCENT) <= 100 ? parseInt(process.env.START_SEED_PERCENT) : 90 : 90;
const RATIO_LIMIT = parseFloat(process.env.RATIO_LIMIT);
const BLOCK_DOWNLOAD = process.env.BLOCK_DOWNLOAD?.match(/true/i) ? true : false;
const SKIP_CHECKING = process.env.SKIP_CHECKING?.match(/true/i) ? true : false;
const INCLUDE_TRACKER = process.env.INCLUDE_STREMIO_TRACKER?.match(/true/i) ? true : false;
const KEEP_TORRENT_LOW_SEEDER = process.env.KEEP_TORRENT_LOW_SEEDER?.match(/true/i) ? true : false;
const CLEAN_CACHE_PERCENT = parseInt(process.env.CLEAN_CACHE_PERCENT) || 95;

const qbittorrent = new qt(BASE_URL, USERNAME, PASSWORD, { UPLOAD_LIMIT, RATIO_LIMIT, INCLUDE_TRACKER, BLOCK_DOWNLOAD, SKIP_CHECKING });

Expand Down Expand Up @@ -119,7 +121,7 @@ async function Update() {
try {
if(KEEP_TORRENT_LOW_SEEDER && _CUSTOM_CACHE_SIZE) {
const currentCacheSize = getFolderSize(CacheDir);
if((currentCacheSize/_CUSTOM_CACHE_SIZE)*100 >= 90){
if((currentCacheSize/_CUSTOM_CACHE_SIZE)*100 >= CLEAN_CACHE_PERCENT){
await cleanTorrentsCache(currentCacheSize);
}
}
Expand Down Expand Up @@ -188,7 +190,7 @@ async function cleanTorrentsCache(currentSize) {

let _removed_size = 0;

const _remove_size = currentSize - _CUSTOM_CACHE_SIZE*90/100;
const _remove_size = currentSize - _CUSTOM_CACHE_SIZE*CLEAN_CACHE_PERCENT/100;
//console.log('will remove', _remove_size)

//clean Uncompleted Torrents;
Expand Down Expand Up @@ -312,6 +314,6 @@ function checkBitField(bitFieldPath, totalPieces) {
}
const percent = (pieces/totalPieces) * 100;
console.log(' => Pieces:', pieces, 'Percent:', Math.floor(percent * 100)/100 + '%');
if(percent >= 90) return true;
if(percent >= START_SEED_PERCENT) return true;
return false;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stremio-qbittoreent-be-seeder",
"version": "1.0.1",
"version": "1.0.2",
"description": "Auto add Cache to Seed",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions stremio-seeds.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ BLOCK_DOWNLOAD=true
SKIP_CHECKING=true
UPLOAD_LIMIT=1mb
RATIO_LIMIT=5.0
START_SEED_PERCENT=

INCLUDE_STREMIO_TRACKER=false

0 comments on commit b63c2ca

Please sign in to comment.