mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-03-09 22:35:07 +08:00
Added some stuff
This commit is contained in:
parent
fe42fc2bb0
commit
b07d955124
2 changed files with 33 additions and 8 deletions
|
@ -15,6 +15,3 @@ tags:
|
|||
avistaz: Avistaz
|
||||
landof.tv: BroadcasTheNet
|
||||
passthepopcorn: PassThePopcorn
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -8,12 +8,15 @@ parser = argparse.ArgumentParser("qBittorrent Manager.",
|
|||
description='A mix of scripts combined for managing qBittorrent.')
|
||||
parser.add_argument('-c', '--config-file', dest='config', action='store', default='config.yml',
|
||||
help='This is used if you want to use different names for your config.yml. Example: tv.yml')
|
||||
parser.add_argument('--manage', dest='command', action='store_const', const='manage',
|
||||
help='Use this if you would like to update your tags AND categories.')
|
||||
parser.add_argument('-m', '--manage', dest='command', action='store_const', const='manage',
|
||||
help='Use this if you would like to update your tags AND categories and remove unregistered '
|
||||
'torrents.')
|
||||
parser.add_argument('--cat-update', dest='command', action='store_const', const='cat-update',
|
||||
help='Use this if you would like to update your categories.')
|
||||
parser.add_argument('--tag-update', dest='command', action='store_const', const='tag-update',
|
||||
help='Use this if you would like to update your tags.')
|
||||
parser.add_argument('--rem-unregistered', dest='command', action='store_const', const='rem-unregistered',
|
||||
help='Use this if you would like to remove unregistered torrents.')
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.config, "r") as cfg_file:
|
||||
|
@ -21,7 +24,7 @@ with open(args.config, "r") as cfg_file:
|
|||
|
||||
# Actual API call to connect to qbt.
|
||||
client = Client(host=cfg["qbt"]["host"], username=cfg["qbt"]["user"], password=cfg["qbt"]["pass"])
|
||||
torrent_list = client.torrents.info()
|
||||
# torrent_list = client.torrents.info()
|
||||
|
||||
|
||||
def get_category(path):
|
||||
|
@ -36,6 +39,7 @@ def get_category(path):
|
|||
|
||||
|
||||
def update_category():
|
||||
torrent_list = client.torrents.info()
|
||||
num_cat = 0
|
||||
for torrent in torrent_list:
|
||||
if torrent.category == '':
|
||||
|
@ -62,6 +66,7 @@ def get_tags(url):
|
|||
|
||||
|
||||
def update_tags():
|
||||
torrent_list = client.torrents.info()
|
||||
num_tags = 0
|
||||
for torrent in torrent_list:
|
||||
if torrent.tags == '':
|
||||
|
@ -73,19 +78,42 @@ def update_tags():
|
|||
torrent.add_tags(tags=new_tag)
|
||||
num_tags += 1
|
||||
if num_tags >= 1:
|
||||
print('Updated ', num_tags, ' new tags')
|
||||
print('Updated ', num_tags, ' new tags.')
|
||||
else:
|
||||
print('No new torrents to tag.')
|
||||
|
||||
|
||||
def rem_unregistered():
|
||||
torrent_list = client.torrents.info()
|
||||
rem_unr = 0
|
||||
for torrent in torrent_list:
|
||||
for status in torrent.trackers:
|
||||
if 'Unregistered torrent' in status.msg:
|
||||
print(torrent.name, '->', status.msg)
|
||||
print(' - Deleted')
|
||||
torrent.delete(hash=torrent.hash, delete_files=True)
|
||||
rem_unr += 1
|
||||
if rem_unr >= 1:
|
||||
print('Deleted ', rem_unr, 'torrents.')
|
||||
else:
|
||||
print('No unregistered torrents found.')
|
||||
|
||||
|
||||
def main():
|
||||
if args.command == 'manage':
|
||||
update_category()
|
||||
update_tags()
|
||||
rem_unregistered()
|
||||
elif args.command == 'tag-update':
|
||||
update_tags()
|
||||
elif args.command == 'cat-update':
|
||||
update_category()
|
||||
elif args.command == 'rem-unregistered':
|
||||
rem_unregistered()
|
||||
else:
|
||||
print("The script requires an argument. See below:")
|
||||
print("")
|
||||
parser.print_help()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue