sync
This commit is contained in:
59
consul_backup/functions/torrent_tagger
Normal file
59
consul_backup/functions/torrent_tagger
Normal file
@@ -0,0 +1,59 @@
|
||||
import qbittorrentapi
|
||||
import logging
|
||||
import sys
|
||||
|
||||
#Creating and Configuring Logger
|
||||
Log_Format = "%(levelname)s %(asctime)s - %(message)s"
|
||||
logging.basicConfig(stream = sys.stdout,
|
||||
format = Log_Format,
|
||||
level = logging.INFO)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
#Testing our Logger
|
||||
|
||||
qbt_client = qbittorrentapi.Client(
|
||||
host='qbittorrent.service.dc1.consul',
|
||||
port=8080,
|
||||
username='admin',
|
||||
password='adminadmin',
|
||||
)
|
||||
try:
|
||||
qbt_client.auth_log_in()
|
||||
except qbittorrentapi.LoginFailed as e:
|
||||
print(e)
|
||||
sys.exit(1)
|
||||
|
||||
# display qBittorrent info
|
||||
|
||||
logger.info(f'qBittorrent: {qbt_client.app.version}')
|
||||
logger.info(f'qBittorrent Web API: {qbt_client.app.web_api_version}')
|
||||
# logger.info(f'Web API Supported: {qbittorrentapi.supported_app_versions}')
|
||||
|
||||
for k,v in qbt_client.app.build_info.items(): print(f'{k}: {v}')
|
||||
for torrent in qbt_client.torrents_info():
|
||||
tags = [word.strip() for word in torrent.tags.split(',')]
|
||||
|
||||
if "812415449bd161ba71e1a30fb5450e3d346a0594" == torrent.hash:
|
||||
logger.info(f'Deleting: {torrent.name}')
|
||||
qbt_client.torrents_delete(delete_files=True, torrent_hashes=torrent.hash)
|
||||
continue
|
||||
|
||||
|
||||
if "/downloads/" in torrent.save_path and "PR2100" not in tags:
|
||||
logger.info(f'Tagging as PR2100: {torrent.name}')
|
||||
qbt_client.torrents_add_tags(tags="PR2100",torrent_hashes=torrent.hash)
|
||||
qbt_client.torrents_remove_tags(tags="WDMYCLOUD",torrent_hashes=torrent.hash)
|
||||
|
||||
if "/archiveseeding/" in torrent.save_path and "WDMYCLOUD" not in tags:
|
||||
logger.info(f'Tagging as WDMYCLOUD: {torrent.name}')
|
||||
qbt_client.torrents_remove_tags(tags="PR2100",torrent_hashes=torrent.hash)
|
||||
qbt_client.torrents_add_tags(tags="WDMYCLOUD",torrent_hashes=torrent.hash)
|
||||
|
||||
if torrent.trackers[0]["msg"] != "This torrent is private" and len(torrent.trackers) == 4:
|
||||
if "rawkbawx" not in torrent.trackers[3]["url"]:
|
||||
logger.info(f'Tagging as Private: {torrent.name} {torrent.hash}')
|
||||
qbt_client.torrents_set_share_limits(ratio_limit=1,seeding_time_limit=1440,inactive_seeding_time_limit=-1,torrent_hashes=torrent.hash)
|
||||
qbt_client.torrents_add_tags(tags="PublicTracker",torrent_hashes=torrent.hash)
|
||||
|
||||
sys.exit(0)
|
||||
87
consul_backup/functions/torrent_tidy
Normal file
87
consul_backup/functions/torrent_tidy
Normal file
@@ -0,0 +1,87 @@
|
||||
import qbittorrentapi
|
||||
from pprint import pprint
|
||||
|
||||
# instantiate a Client using the appropriate WebUI configuration
|
||||
qbt_client = qbittorrentapi.Client(
|
||||
host='qbittorrent.service.dc1.consul',
|
||||
port=8080,
|
||||
username='admin',
|
||||
password='adminadmin',
|
||||
)
|
||||
|
||||
# the Client will automatically acquire/maintain a logged-in state
|
||||
# in line with any request. therefore, this is not strictly necessary;
|
||||
# however, you may want to test the provided login credentials.
|
||||
try:
|
||||
qbt_client.auth_log_in()
|
||||
except qbittorrentapi.LoginFailed as e:
|
||||
print(e)
|
||||
|
||||
# display qBittorrent info
|
||||
print(f'qBittorrent: {qbt_client.app.version}')
|
||||
print(f'qBittorrent Web API: {qbt_client.app.web_api_version}')
|
||||
for k,v in qbt_client.app.build_info.items(): print(f'{k}: {v}')
|
||||
|
||||
|
||||
# Creating an empty dictionary
|
||||
trackermap = {}
|
||||
|
||||
# Adding list as value
|
||||
trackermap["Docspedia"] = ["http://science.docspedia.world:2710/f200baf50d45595c269b7b2d8c475a56/announce"]
|
||||
trackermap["MMA"] = ["http://a.mma-tracker.org:2710/ed6d78535267e979de36ec2401999d3a/announce"]
|
||||
trackermap["IPT"] = ["http://127.0.0.1.stackoverflow.tech/cc7288bf91565af486c8e4bad2b63a37/announce"
|
||||
"http://routing.bgp.technology/cc7288bf91565af486c8e4bad2b63a37/announce",
|
||||
"http://async.empirehost.me/cc7288bf91565af486c8e4bad2b63a37/announce",
|
||||
]
|
||||
trackermap["Anthelion"] = ["https://tracker.anthelion.me:34001/LmD45Qf7p0MVgYkPm1Uogc8wNqDtvsjF/announce"]
|
||||
trackermap["Cathode"] = ["https://signal.cathode-ray.tube/yebawgmvnvojwjnfw2a1qr5wg3pqwe4o/announce"]
|
||||
trackermap["RedSeeding"] = ["https://flacsfor.me/f08a15129e4276f609c8b99abb746195/announce"]
|
||||
trackermap["cinemaz"] = ["https://tracker.cinemaz.to/50500ba3815e18c837cd753ceb0080e3/announce"]
|
||||
trackermap["iMetal"] = ["http://metal.iplay.ro/announce.php?passkey=2b4d98fe0f4b7325a15e5654961498ea"]
|
||||
trackermap["rawk"] = ["http://rawkbawx.rocks:2710/announce","http://rawkbawx.rocks:2710/f7903677d2c030b89b69799f4bd9edbd/announce"]
|
||||
trackermap["torrentleech"] = ["https://tracker.tleechreload.org/a/3d6cde5fd3bf1a375f3466d40f9ee9bb/announce"
|
||||
,"https://tracker.torrentleech.org/a/3d6cde5fd3bf1a375f3466d40f9ee9bb/announce"]
|
||||
trackermap["MyAnonamouse"] = ["https://t.myanonamouse.net/tracker.php/VPRYYAL-WpTwnr9G9aIN6044YVZ7x8Ao/announce"]
|
||||
trackermap["Nebulance"] = ["https://tracker.nebulance.io/edcd6847fb3c31fd9958dd7144f0ea15/announce"]
|
||||
trackermap["Orpheus_seeding"] = ["https://home.opsfet.ch/EAvBpDtmBtbziuydzwzhasgqAxrCqFwo/announce"]
|
||||
trackermap["tvchaos"] = ["https://tvchaosuk.com/announce/cbaade5ac5612edf854b295153a60e6b"]
|
||||
trackermap["filelist"] = ["http://reactor.filelist.io/98ece6e971fe7e89a0c86a00c20c1037/announce",
|
||||
"http://reactor.flro.org/98ece6e971fe7e89a0c86a00c20c1037/announce"]
|
||||
|
||||
|
||||
|
||||
categories_to_tidy = ["radarr","tv-sonarr","lidar","readarr","readarrAudio","Uncategorized"]
|
||||
|
||||
#ensutre cats exist
|
||||
torrents_cats = qbt_client.torrents_categories()
|
||||
|
||||
for tracker in trackermap:
|
||||
if tracker not in torrents_cats:
|
||||
|
||||
savepath = "/downloads/seeding/" + tracker
|
||||
qbt_client.torrents_create_category(name=tracker, save_path=savepath)
|
||||
if tracker in torrents_cats:
|
||||
savepath = "/downloads/seeding/" + tracker
|
||||
if torrents_cats[tracker]["savePath"] != savepath:
|
||||
# print(tracker)
|
||||
# print(torrents_cats[tracker]["savePath"])
|
||||
qbt_client.torrents_edit_category(name=tracker, save_path=savepath)
|
||||
|
||||
# retrieve and show all torrents
|
||||
for torrent in qbt_client.torrents_info():
|
||||
# pprint(torrent.category)
|
||||
for messycat in categories_to_tidy:
|
||||
if messycat == torrent.category:
|
||||
# pprint(torrent["name"])
|
||||
# pprint(torrent.trackers)
|
||||
for tracker in torrent.trackers:
|
||||
for knowntracker in trackermap:
|
||||
if tracker["url"] in trackermap[knowntracker]:
|
||||
name = torrent["name"]
|
||||
pprint(f"{knowntracker} detected: {name}")
|
||||
#seeding_time in seconds
|
||||
if int(torrent.seeding_time) > 86400:
|
||||
pprint(f"Moving {name} to {knowntracker}")
|
||||
qbt_client.torrents_set_category(category=knowntracker,torrent_hashes=torrent.hash)
|
||||
else:
|
||||
pprint(f"seedtime {name} to {knowntracker}")
|
||||
Reference in New Issue
Block a user