Added in tag capabilities
This commit is contained in:
parent
33812eac65
commit
a7def171e6
20
bot.py
20
bot.py
|
@ -122,13 +122,13 @@ class QBittorrentAPICaller():
|
||||||
to_ret += "```"
|
to_ret += "```"
|
||||||
return to_ret
|
return to_ret
|
||||||
|
|
||||||
def add(self, url, username):
|
def add(self, url, username, tag="unknown"):
|
||||||
if not url.startswith("magnet:"):
|
if not url.startswith("magnet:"):
|
||||||
return "Please supply a magnet link (begins with \"magnet:\")"
|
return "Please supply a magnet link (begins with \"magnet:\")"
|
||||||
|
|
||||||
the_url = self.url + "/" + "api/v2/torrents/add"
|
the_url = self.url + "/" + "api/v2/torrents/add"
|
||||||
|
|
||||||
resp = self.session.post(the_url, data={"urls":url,"category":username})
|
resp = self.session.post(the_url, data={"urls":url,"category":username,"tags":tag})
|
||||||
if (resp.status_code == 415):
|
if (resp.status_code == 415):
|
||||||
return "Torrent file not valid"
|
return "Torrent file not valid"
|
||||||
|
|
||||||
|
@ -300,7 +300,13 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
message += self.api_caller.torrentList("full")
|
message += self.api_caller.torrentList("full")
|
||||||
|
|
||||||
case "add":
|
case "add":
|
||||||
message += self.api_caller.add(tokens[2], msg['mucnick'])
|
tag = "unknown"
|
||||||
|
string_start = 2
|
||||||
|
if tokens[2].startswith("t="):
|
||||||
|
tag = tokens[2].removeprefix("t=")
|
||||||
|
string_start = 3
|
||||||
|
|
||||||
|
message += self.api_caller.add(tokens[string_start], msg['mucnick'], tag)
|
||||||
|
|
||||||
case "searchplugins":
|
case "searchplugins":
|
||||||
resp = self.api_caller.get_search_plugins()
|
resp = self.api_caller.get_search_plugins()
|
||||||
|
@ -356,18 +362,18 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
message += "\n```"
|
message += "\n```"
|
||||||
# Register the users's latest search in the searchselects structure
|
# Register the users's latest search in the searchselects structure
|
||||||
user = msg['mucnick']
|
user = msg['mucnick']
|
||||||
self.searchselects[user] = the_list
|
self.searchselects[user] = [category if category != "all" else "unknown", the_list]
|
||||||
|
|
||||||
case "searchselect":
|
case "searchselect":
|
||||||
user = msg['mucnick']
|
user = msg['mucnick']
|
||||||
if self.searchselects[user] is None:
|
if self.searchselects[user] is None:
|
||||||
message += "Please initiate a search first."
|
message += "Please initiate a search first."
|
||||||
else:
|
else:
|
||||||
selection = self.searchselects[user]
|
selection = self.searchselects[user][1]
|
||||||
index = int(tokens[2])
|
index = int(tokens[2])
|
||||||
if index < len(selection):
|
if index < len(selection):
|
||||||
link = selection[index][1]
|
link = selection[index][1]
|
||||||
self.api_caller.add(link, user)
|
self.api_caller.add(link, user, self.searchselects[user][0])
|
||||||
message += "Successfully added " + selection[index][0]
|
message += "Successfully added " + selection[index][0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -398,7 +404,7 @@ class QBBot(slixmpp.ClientXMPP):
|
||||||
message += "help: Displays this help" + "\n"
|
message += "help: Displays this help" + "\n"
|
||||||
message += "list: Lists torrents, names truncated to 25 characters\n"
|
message += "list: Lists torrents, names truncated to 25 characters\n"
|
||||||
message += "fulllist: Lists torrents, no name truncation\n"
|
message += "fulllist: Lists torrents, no name truncation\n"
|
||||||
message += "add MAGNET_URL: Adds torrent corresponding to MAGNET_URL to the download list. Note that this will take about 5 seconds, as there's a check for 0 seeds after 5 seconds as a warning\n"
|
message += "add [t=TAG] MAGNET_URL: Adds torrent corresponding to MAGNET_URL to the download list.\n\tNote that this will take about 5 seconds, as there's a check for 0 seeds after 5 seconds as a warning.\n\tOptionally include TAG to assist in automated copy.\n\tValid TAG values can be found with the categories in searchplugins\n"
|
||||||
message += "searchplugins: List the installed search plugins\n"
|
message += "searchplugins: List the installed search plugins\n"
|
||||||
message += "search [c=CATEGORY] search_string: Search from all enabled plugins for search_string, with optional category CATEGORY. Valid categories can be found from the searchplugins command.\n"
|
message += "search [c=CATEGORY] search_string: Search from all enabled plugins for search_string, with optional category CATEGORY. Valid categories can be found from the searchplugins command.\n"
|
||||||
message += "searchselect: Selects a torrent from a previous search to download\n"
|
message += "searchselect: Selects a torrent from a previous search to download\n"
|
||||||
|
|
Loading…
Reference in New Issue