diff --git a/gallery_dl/downloader/common.py b/gallery_dl/downloader/common.py index bb6ad653..3d042fe6 100644 --- a/gallery_dl/downloader/common.py +++ b/gallery_dl/downloader/common.py @@ -16,7 +16,6 @@ import logging class DownloaderBase(): """Base class for downloaders""" retries = 1 - mode = "b" part = True def __init__(self, session, output): @@ -66,13 +65,13 @@ class DownloaderBase(): # check response if not offset: - mode = "w" + self.mode + mode = "wb" if filesize: self.log.info("Unable to resume partial download") elif offset == -1: break # early finish else: - mode = "a" + self.mode + mode = "ab" self.log.info("Resuming download at byte %d", offset) # set missing filename extension diff --git a/gallery_dl/downloader/text.py b/gallery_dl/downloader/text.py index 3f332c11..de0543f9 100644 --- a/gallery_dl/downloader/text.py +++ b/gallery_dl/downloader/text.py @@ -14,21 +14,21 @@ from .. import config class Downloader(DownloaderBase): part = config.interpolate(("downloader", "text", "part"), True) - mode = "t" def __init__(self, session, output): DownloaderBase.__init__(self, session, output) - self.text = "" + self.content = b"" def connect(self, url, offset): - self.text = url[offset + 5:] - return offset, len(url) - 5 + data = url.encode() + self.content = data[offset + 5:] + return offset, len(data) - 5 def receive(self, file): - file.write(self.text) + file.write(self.content) def reset(self): - self.text = "" + self.content = b"" @staticmethod def get_extension():