Files
gallery-dl/gallery_dl/downloader/text.py
Mike Fährmann 963670d73b add options to control usage of .part files (#29)
- '--no-part' command line option to disable them
- 'downloader.http.part' and 'downloader.text.part' config options

Disabling .part files restores the behaviour of the old downloader
implementation.
2017-10-24 23:33:44 +02:00

36 lines
865 B
Python

# -*- coding: utf-8 -*-
# Copyright 2014-2017 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
"""Downloader module for text: URLs"""
from .common import DownloaderBase
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 = ""
def connect(self, url, offset):
self.text = url[offset + 5:]
return offset, len(url) - 5
def receive(self, file):
file.write(self.text)
def reset(self):
self.text = ""
@staticmethod
def get_extension():
return "txt"