You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gallery-dl/gallery_dl/downloader/text.py

33 lines
909 B

# -*- 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 BasicDownloader
class Downloader(BasicDownloader):
def __init__(self, session, output):
BasicDownloader.__init__(self)
self.out = output
def download_impl(self, url, pathfmt):
if not pathfmt.has_extension:
pathfmt.set_extension("txt")
if pathfmt.exists():
self.out.skip(pathfmt.path)
return
self.out.start(pathfmt.path)
self.downloading = True
with pathfmt.open("w") as file:
file.write(url[5:])
self.downloading = False
self.out.success(pathfmt.path, 0)