aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/downloader/text.py
blob: a668d62a34434a52f5c8740e55efb814ffc4fb10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# -*- coding: utf-8 -*-

# Copyright 2014-2019 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


class TextDownloader(DownloaderBase):
    scheme = "text"

    def download(self, url, pathfmt):
        if self.part:
            pathfmt.part_enable(self.partdir)
        self.out.start(pathfmt.path)
        with pathfmt.open("wb") as fp:
            fp.write(url.encode()[5:])
        return True


__downloader__ = TextDownloader