improved url grabbing and filename
This commit is contained in:
parent
52113f6ad0
commit
14f7356957
|
@ -37,6 +37,7 @@ class OppaiBot(irc.IRCClient):
|
|||
res.raise_for_status()
|
||||
fname = re.search(r'filename="(.+)"',res.headers['content-disposition'])
|
||||
fname = fname.group(1)
|
||||
fname = fname.replace(u"â\x80\x93", "–")
|
||||
print("Saving torrent:", fname)
|
||||
with open(os.path.join(directory, fname), "wb") as file:
|
||||
for chunk in res.iter_content(100000):
|
||||
|
@ -51,7 +52,7 @@ class OppaiBot(irc.IRCClient):
|
|||
# More advanced logic is left as an exercise to the reader.
|
||||
tags_in_msg = [tag in message for tag in self.tags]
|
||||
if any(tags_in_msg):
|
||||
url = message.split(" - ")[1].split(" / ")[1]
|
||||
url = re.findall(r"(http.+?) ", message)[1]
|
||||
self.save_torrent(url, self.watch_dir)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user