elementprocessor.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:RedditDownloader 作者: shadowmoose 项目源码 文件源码
def process_url(self, url, info):
        """ Accepts a URL and the array of file info generated for it by this class, and then attempts to download it using any possible handler.
            Returns whatever the handlers do, which should be a path to the file itself or the contianing directory for an album.
                +Also returns False or None if no appropriate handler was found, or if the handler told us not to download anything.
        """
        ret_val = False # Default to 'False', meaning no file was located by a handler.
        for h in self.handlers:
            print("\tChecking handler: %s" % h.tag)
            ret = h.handle(url, info)
            if ret is None:
                # None is returned when the handler specifically wants this URL to be "finished", but not added to the files list.
                stringutil.print_color(Fore.GREEN, "\t+Handler '%s' completed correctly, but returned no files!" % h.tag )
                ret_val = None
                break
            if ret:
                # The handler will return a file/directory name if it worked properly.
                ret_val = stringutil.normalize_file(ret)
                stringutil.out("%s\t+Handler '%s' completed correctly! %s%s" % (Fore.GREEN, h.tag, stringutil.fit(ret_val, 75), Style.RESET_ALL) )
                break
            #
        #
        if ret_val is False:
            stringutil.error("\t!No handlers were able to accept this URL." )
        return ret_val
    #
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号