elementprocessor.py 文件源码

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

项目:RedditDownloader 作者: shadowmoose 项目源码 文件源码
def process_ele(self, reddit_element):
        """ Accepts a RedditElement of Post/Comment details, then runs through the Handlers loaded from the other directory, attempting to download the url.  """
        print('%i/%i: ' % (self.loader.count_completed()+1, self.loader.count_total() ), end='')
        stringutil.print_color(Fore.LIGHTYELLOW_EX, stringutil.out("[%s](%s): %s" % (reddit_element.type, reddit_element.subreddit, reddit_element.title), False))

        for url in reddit_element.get_urls():
            print('\tURL: %s' % url)
            file = self.loader.url_exists(url)
            if file:
                stringutil.print_color(Fore.GREEN, "\t\t+URL already taken care of.")
                reddit_element.add_file(url, file)
                continue
            if self.manifest:
                skip, file = self.manifest.url_completed(url)
                if skip and (file is None or os.path.exists(file)):
                    stringutil.print_color(Fore.GREEN, "\t\t+URL already handled in previous run.")
                    reddit_element.add_file(url, file)
                    if file is not None:
                        hashjar.add_hash(file) # Add the existing file hash so we can deduplicate against it.
                    continue
            base_file, file_info = self.build_file_info(reddit_element)# Build the file information array using this RedditElement's information
            file_path = self.process_url(url, file_info)
            reddit_element.add_file(url, self.check_duplicates(file_path))
    #
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号