moved dragnet to config file #17
326
.gitignore
vendored
326
.gitignore
vendored
@ -1,164 +1,164 @@
|
|||||||
*.log
|
*.log
|
||||||
*.json
|
*.json
|
||||||
*.csv
|
*.csv
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
|
||||||
# C extensions
|
# C extensions
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
.Python
|
.Python
|
||||||
build/
|
build/
|
||||||
develop-eggs/
|
develop-eggs/
|
||||||
dist/
|
dist/
|
||||||
downloads/
|
downloads/
|
||||||
eggs/
|
eggs/
|
||||||
.eggs/
|
.eggs/
|
||||||
lib/
|
lib/
|
||||||
lib64/
|
lib64/
|
||||||
parts/
|
parts/
|
||||||
sdist/
|
sdist/
|
||||||
var/
|
var/
|
||||||
wheels/
|
wheels/
|
||||||
share/python-wheels/
|
share/python-wheels/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
.installed.cfg
|
.installed.cfg
|
||||||
*.egg
|
*.egg
|
||||||
MANIFEST
|
MANIFEST
|
||||||
|
|
||||||
# PyInstaller
|
# PyInstaller
|
||||||
# Usually these files are written by a python script from a template
|
# Usually these files are written by a python script from a template
|
||||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
*.manifest
|
*.manifest
|
||||||
*.spec
|
*.spec
|
||||||
|
|
||||||
# Installer logs
|
# Installer logs
|
||||||
pip-log.txt
|
pip-log.txt
|
||||||
pip-delete-this-directory.txt
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
# Unit test / coverage reports
|
# Unit test / coverage reports
|
||||||
htmlcov/
|
htmlcov/
|
||||||
.tox/
|
.tox/
|
||||||
.nox/
|
.nox/
|
||||||
.coverage
|
.coverage
|
||||||
.coverage.*
|
.coverage.*
|
||||||
.cache
|
.cache
|
||||||
nosetests.xml
|
nosetests.xml
|
||||||
coverage.xml
|
coverage.xml
|
||||||
*.cover
|
*.cover
|
||||||
*.py,cover
|
*.py,cover
|
||||||
.hypothesis/
|
.hypothesis/
|
||||||
.pytest_cache/
|
.pytest_cache/
|
||||||
cover/
|
cover/
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
*.mo
|
*.mo
|
||||||
*.pot
|
*.pot
|
||||||
|
|
||||||
# Django stuff:
|
# Django stuff:
|
||||||
*.log
|
*.log
|
||||||
local_settings.py
|
local_settings.py
|
||||||
db.sqlite3
|
db.sqlite3
|
||||||
db.sqlite3-journal
|
db.sqlite3-journal
|
||||||
|
|
||||||
# Flask stuff:
|
# Flask stuff:
|
||||||
instance/
|
instance/
|
||||||
.webassets-cache
|
.webassets-cache
|
||||||
|
|
||||||
# Scrapy stuff:
|
# Scrapy stuff:
|
||||||
.scrapy
|
.scrapy
|
||||||
|
|
||||||
# Sphinx documentation
|
# Sphinx documentation
|
||||||
docs/_build/
|
docs/_build/
|
||||||
|
|
||||||
# PyBuilder
|
# PyBuilder
|
||||||
.pybuilder/
|
.pybuilder/
|
||||||
target/
|
target/
|
||||||
|
|
||||||
# Jupyter Notebook
|
# Jupyter Notebook
|
||||||
.ipynb_checkpoints
|
.ipynb_checkpoints
|
||||||
|
|
||||||
# IPython
|
# IPython
|
||||||
profile_default/
|
profile_default/
|
||||||
ipython_config.py
|
ipython_config.py
|
||||||
|
|
||||||
# pyenv
|
# pyenv
|
||||||
# For a library or package, you might want to ignore these files since the code is
|
# For a library or package, you might want to ignore these files since the code is
|
||||||
# intended to run in multiple environments; otherwise, check them in:
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
# .python-version
|
# .python-version
|
||||||
|
|
||||||
# pipenv
|
# pipenv
|
||||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
# install all needed dependencies.
|
# install all needed dependencies.
|
||||||
#Pipfile.lock
|
#Pipfile.lock
|
||||||
|
|
||||||
# poetry
|
# poetry
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||||
# commonly ignored for libraries.
|
# commonly ignored for libraries.
|
||||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||||
#poetry.lock
|
#poetry.lock
|
||||||
|
|
||||||
# pdm
|
# pdm
|
||||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||||
#pdm.lock
|
#pdm.lock
|
||||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||||
# in version control.
|
# in version control.
|
||||||
# https://pdm.fming.dev/#use-with-ide
|
# https://pdm.fming.dev/#use-with-ide
|
||||||
.pdm.toml
|
.pdm.toml
|
||||||
|
|
||||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||||
__pypackages__/
|
__pypackages__/
|
||||||
|
|
||||||
# Celery stuff
|
# Celery stuff
|
||||||
celerybeat-schedule
|
celerybeat-schedule
|
||||||
celerybeat.pid
|
celerybeat.pid
|
||||||
|
|
||||||
# SageMath parsed files
|
# SageMath parsed files
|
||||||
*.sage.py
|
*.sage.py
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
ENV/
|
ENV/
|
||||||
env.bak/
|
env.bak/
|
||||||
venv.bak/
|
venv.bak/
|
||||||
|
|
||||||
# Spyder project settings
|
# Spyder project settings
|
||||||
.spyderproject
|
.spyderproject
|
||||||
.spyproject
|
.spyproject
|
||||||
|
|
||||||
# Rope project settings
|
# Rope project settings
|
||||||
.ropeproject
|
.ropeproject
|
||||||
|
|
||||||
# mkdocs documentation
|
# mkdocs documentation
|
||||||
/site
|
/site
|
||||||
|
|
||||||
# mypy
|
# mypy
|
||||||
.mypy_cache/
|
.mypy_cache/
|
||||||
.dmypy.json
|
.dmypy.json
|
||||||
dmypy.json
|
dmypy.json
|
||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
# pytype static type analyzer
|
# pytype static type analyzer
|
||||||
.pytype/
|
.pytype/
|
||||||
|
|
||||||
# Cython debug symbols
|
# Cython debug symbols
|
||||||
cython_debug/
|
cython_debug/
|
||||||
|
|
||||||
# PyCharm
|
# PyCharm
|
||||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
@ -46,6 +46,8 @@ Config.json
|
|||||||
"po_key": "",
|
"po_key": "",
|
||||||
"po_token": "",
|
"po_token": "",
|
||||||
"delete_torrents": false
|
"delete_torrents": false
|
||||||
|
"enable_dragnet": false,
|
||||||
|
"dragnet_outfile": "./orphaned.csv"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -74,4 +76,5 @@ You will need a category-whitelist.json in the root directory. This will ignore
|
|||||||
| use_log | true or false to enable or disable writing to alog file |
|
| use_log | true or false to enable or disable writing to alog file |
|
||||||
| po_key | pushover key |
|
| po_key | pushover key |
|
||||||
| po_token | pushover api token |
|
| po_token | pushover api token |
|
||||||
| delete_torrents | true or false to enable or disable deletion. Useful for dry-runs |
|
| delete_torrents | true or false to enable or disable deletion. Useful for dry-runs |
|
||||||
|
| enable_dragnet | true or false to enable dragnet functionality. Useful for debugging |
|
@ -13,5 +13,7 @@
|
|||||||
"use_log": true,
|
"use_log": true,
|
||||||
"po_key": "",
|
"po_key": "",
|
||||||
"po_token": "",
|
"po_token": "",
|
||||||
"delete_torrents": false
|
"delete_torrents": false,
|
||||||
|
"enable_dragnet": true,
|
||||||
|
"dragnet_outfile": "./orphaned.csv"
|
||||||
}
|
}
|
@ -43,6 +43,8 @@ class Qbt:
|
|||||||
self.tracker_non_protected_tag = self.config["non_protected_tag"]
|
self.tracker_non_protected_tag = self.config["non_protected_tag"]
|
||||||
self.minimum_age = self.config["minimum_age"]
|
self.minimum_age = self.config["minimum_age"]
|
||||||
self.age = self.config["age"]
|
self.age = self.config["age"]
|
||||||
|
self.enable_dragnet = self.config["enable_dragnet"]
|
||||||
|
self.dragnet_outfile = self.config["dragnet_outfile"]
|
||||||
# Calling log and notify functions
|
# Calling log and notify functions
|
||||||
torlog(self)
|
torlog(self)
|
||||||
tornotify(self)
|
tornotify(self)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from cgitb import enable
|
||||||
|
|
||||||
|
|
||||||
def torprocessor(self):
|
def torprocessor(self):
|
||||||
"""Main logic to sort through both self.tracker_nonprotected_list and self.tracker_protected_list
|
"""Main logic to sort through both self.tracker_nonprotected_list and self.tracker_protected_list
|
||||||
If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list
|
If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list
|
||||||
@ -32,7 +35,8 @@ def torprocessor(self):
|
|||||||
if self.use_log:
|
if self.use_log:
|
||||||
self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
|
self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
|
||||||
else:
|
else:
|
||||||
dragnet(self,canidate['state'],canidate['ratio'],canidate["tags"],canidate['added_on'],self.age,self.t.time(),canidate['infohash_v1'],canidate["name"][0:20])
|
if self.enable_dragnet:
|
||||||
|
dragnet(self,canidate['state'],canidate['ratio'],canidate["tags"],canidate['added_on'],self.age,self.t.time(),canidate['infohash_v1'],canidate["name"][0:20])
|
||||||
self.tl.info(f'["{canidate["name"][0:20]}..."] is orphaned.')
|
self.tl.info(f'["{canidate["name"][0:20]}..."] is orphaned.')
|
||||||
self.up_tor_counter += 1
|
self.up_tor_counter += 1
|
||||||
continue
|
continue
|
||||||
@ -72,7 +76,7 @@ def isnonprotectedtor(setnonprotectedtag, tortags):
|
|||||||
def dragnet(self,state,ratio,tags,added,age,time,thash,tname):
|
def dragnet(self,state,ratio,tags,added,age,time,thash,tname):
|
||||||
header = ['state','ratio','tags','added','age','time','thash','tname']
|
header = ['state','ratio','tags','added','age','time','thash','tname']
|
||||||
row = [state,ratio,tags,added,age,time,thash,tname]
|
row = [state,ratio,tags,added,age,time,thash,tname]
|
||||||
with open('./orphanedtorrents.csv', 'w', encoding='UTF8', newline='') as f:
|
with open(self.dragnet_outfile, 'w', encoding='UTF8', newline='') as f:
|
||||||
writer = self.cv.writer(f)
|
writer = self.cv.writer(f)
|
||||||
if f.tell() == 0:
|
if f.tell() == 0:
|
||||||
writer.writerow(header)
|
writer.writerow(header)
|
||||||
|
192
test_qbitmaid.py
192
test_qbitmaid.py
@ -1,97 +1,97 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from qlist import ispreme,iscatignored,istrackerblank,isprotectedtracker,isnotprotectedtracker,istagblank
|
from qlist import ispreme,iscatignored,istrackerblank,isprotectedtracker,isnotprotectedtracker,istagblank
|
||||||
from qprocess import isdownloading,isprotectedunderratio,isoldtor,isprotectedoverratio,isnonprotectedtor
|
from qprocess import isdownloading,isprotectedunderratio,isoldtor,isprotectedoverratio,isnonprotectedtor
|
||||||
|
|
||||||
class TestQbitmaid(unittest.TestCase):
|
class TestQbitmaid(unittest.TestCase):
|
||||||
def test_ispreme_sanity(self):
|
def test_ispreme_sanity(self):
|
||||||
self.assertTrue(ispreme(1,1,1))
|
self.assertTrue(ispreme(1,1,1))
|
||||||
self.assertFalse(ispreme(1,1,3))
|
self.assertFalse(ispreme(1,1,3))
|
||||||
|
|
||||||
def test_ispreme(self):
|
def test_ispreme(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_iscatignored_sanity(self):
|
def test_iscatignored_sanity(self):
|
||||||
self.assertTrue(iscatignored('a', ['a','b','c']))
|
self.assertTrue(iscatignored('a', ['a','b','c']))
|
||||||
self.assertTrue(iscatignored('b', ['a','b','c']))
|
self.assertTrue(iscatignored('b', ['a','b','c']))
|
||||||
self.assertTrue(iscatignored('c', ['a','b','c']))
|
self.assertTrue(iscatignored('c', ['a','b','c']))
|
||||||
self.assertFalse(iscatignored('d', ['a','b','c']))
|
self.assertFalse(iscatignored('d', ['a','b','c']))
|
||||||
self.assertFalse(iscatignored(1, ['a','b','c']))
|
self.assertFalse(iscatignored(1, ['a','b','c']))
|
||||||
self.assertFalse(iscatignored(1.0000000, ['a','b','c']))
|
self.assertFalse(iscatignored(1.0000000, ['a','b','c']))
|
||||||
|
|
||||||
def test_iscatignored(self):
|
def test_iscatignored(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_istrackerblank_sanity(self):
|
def test_istrackerblank_sanity(self):
|
||||||
self.assertTrue(istrackerblank(''))
|
self.assertTrue(istrackerblank(''))
|
||||||
self.assertFalse(istrackerblank('a'))
|
self.assertFalse(istrackerblank('a'))
|
||||||
self.assertFalse(istrackerblank(1))
|
self.assertFalse(istrackerblank(1))
|
||||||
self.assertFalse(istrackerblank(1.00000000))
|
self.assertFalse(istrackerblank(1.00000000))
|
||||||
|
|
||||||
def test_istrackerblank(self):
|
def test_istrackerblank(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_isprotectedtracker_sanity(self):
|
def test_isprotectedtracker_sanity(self):
|
||||||
self.assertTrue(isprotectedtracker('https://a.com/',['a.com','b.me','c.io']))
|
self.assertTrue(isprotectedtracker('https://a.com/',['a.com','b.me','c.io']))
|
||||||
self.assertFalse(isprotectedtracker('https://google.com/',['a.com','b.me','c.io']))
|
self.assertFalse(isprotectedtracker('https://google.com/',['a.com','b.me','c.io']))
|
||||||
self.assertFalse(isprotectedtracker('https://d.com',['a.com','b.me','c.io']))
|
self.assertFalse(isprotectedtracker('https://d.com',['a.com','b.me','c.io']))
|
||||||
|
|
||||||
def test_isprotectedtracker(self):
|
def test_isprotectedtracker(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_isnotprotectedtracker_sanity(self):
|
def test_isnotprotectedtracker_sanity(self):
|
||||||
self.assertFalse(isnotprotectedtracker('https://a.com/',['a.com','b.me','c.io']))
|
self.assertFalse(isnotprotectedtracker('https://a.com/',['a.com','b.me','c.io']))
|
||||||
self.assertTrue(isnotprotectedtracker('https://google.com/',['a.com','b.me','c.io']))
|
self.assertTrue(isnotprotectedtracker('https://google.com/',['a.com','b.me','c.io']))
|
||||||
self.assertTrue(isnotprotectedtracker('https://d.com',['a.com','b.me','c.io']))
|
self.assertTrue(isnotprotectedtracker('https://d.com',['a.com','b.me','c.io']))
|
||||||
|
|
||||||
def test_isnotprotectedtracker(self):
|
def test_isnotprotectedtracker(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_istagblank(self):
|
def test_istagblank(self):
|
||||||
self.assertTrue(istagblank(''))
|
self.assertTrue(istagblank(''))
|
||||||
self.assertFalse(istagblank('a'))
|
self.assertFalse(istagblank('a'))
|
||||||
self.assertFalse(istagblank(1))
|
self.assertFalse(istagblank(1))
|
||||||
self.assertFalse(istagblank(1.0001))
|
self.assertFalse(istagblank(1.0001))
|
||||||
self.assertFalse(istagblank(False))
|
self.assertFalse(istagblank(False))
|
||||||
self.assertFalse(istagblank(True))
|
self.assertFalse(istagblank(True))
|
||||||
|
|
||||||
def test_isdownloading_sanity(self):
|
def test_isdownloading_sanity(self):
|
||||||
self.assertTrue(isdownloading('downloading'))
|
self.assertTrue(isdownloading('downloading'))
|
||||||
|
|
||||||
def test_isdownloading(self):
|
def test_isdownloading(self):
|
||||||
self.assertFalse(isdownloading('DOWNLOADING'))
|
self.assertFalse(isdownloading('DOWNLOADING'))
|
||||||
self.assertFalse(isdownloading('dOwNlOaDiNg'))
|
self.assertFalse(isdownloading('dOwNlOaDiNg'))
|
||||||
|
|
||||||
def test_isprotectedunderratio_sanity(self):
|
def test_isprotectedunderratio_sanity(self):
|
||||||
self.assertTrue(isprotectedunderratio(0.5,1,'a','a,b,c'))
|
self.assertTrue(isprotectedunderratio(0.5,1,'a','a,b,c'))
|
||||||
|
|
||||||
def test_isprotectedunderratio(self):
|
def test_isprotectedunderratio(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_isoldtor_sanity(self):
|
def test_isoldtor_sanity(self):
|
||||||
self.assertTrue(isoldtor(1,2,4))
|
self.assertTrue(isoldtor(1,2,4))
|
||||||
|
|
||||||
def test_isoldtor(self):
|
def test_isoldtor(self):
|
||||||
self.assertFalse(isoldtor(1661150664,2419200,1662049004.2101078))
|
self.assertFalse(isoldtor(1661150664,2419200,1662049004.2101078))
|
||||||
self.assertFalse(isoldtor(1661150664,2419200,1662049004))
|
self.assertFalse(isoldtor(1661150664,2419200,1662049004))
|
||||||
self.assertFalse(isoldtor(1661150664.000000,2419200.0000000,1662049004.2101078))
|
self.assertFalse(isoldtor(1661150664.000000,2419200.0000000,1662049004.2101078))
|
||||||
|
|
||||||
def test_isprotectedoverratio_sanity(self):
|
def test_isprotectedoverratio_sanity(self):
|
||||||
self.assertTrue(isprotectedoverratio(2,1,'a','a,b,c'))
|
self.assertTrue(isprotectedoverratio(2,1,'a','a,b,c'))
|
||||||
|
|
||||||
def test_isprotectedoverratio(self):
|
def test_isprotectedoverratio(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_isnonprotectedtor_sanity(self):
|
def test_isnonprotectedtor_sanity(self):
|
||||||
self.assertTrue(isnonprotectedtor('a','a,b,c'))
|
self.assertTrue(isnonprotectedtor('a','a,b,c'))
|
||||||
|
|
||||||
def test_isnonprotectedtor(self):
|
def test_isnonprotectedtor(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# def test__sanity(self):
|
# def test__sanity(self):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
# def test_(self):
|
# def test_(self):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user