better handling of unicode
This commit is contained in:
parent
e8baf1848b
commit
23eb0543c8
|
@ -39,9 +39,9 @@ class OppaiBot(irc.IRCClient):
|
|||
"""
|
||||
res = requests.get(url, cookies=self.cj, headers=HEADERS, verify=True)
|
||||
res.raise_for_status()
|
||||
fname = re.search(r'filename="(.+)"',res.headers['content-disposition'])
|
||||
fname =re.search(r'filename="(.+)"',res.headers['content-disposition'])
|
||||
fname = fname.group(1)
|
||||
fname = fname.replace(u"â\x80\x93", "–")
|
||||
fname = fname.encode("latin-1").decode("utf-8")
|
||||
print(self.tracker + ": Saving torrent:", fname)
|
||||
with open(os.path.join(directory, fname), "wb") as file:
|
||||
for chunk in res.iter_content(100000):
|
||||
|
|
Loading…
Reference in New Issue
Block a user