def treat(self, photo): """ Process each page. 1. Check for existing duplicates on the wiki specified in self.site. 2. If duplicates are found, then skip uploading. 3. Download the file from photo.URL and upload the file to self.site. """ duplicates = photo.findDuplicateImages() if duplicates: pywikibot.output('Skipping duplicate of {!r}'.format(duplicates)) return duplicates[0] title = photo.getTitle(self.titlefmt) description = photo.getDescription(self.pagefmt) bot = UploadRobot(url=photo.URL, description=description, use_filename=title, keep_filename=True, verify_description=False, target_site=self.site) bot._contents = photo.downloadPhoto().getvalue() bot._retrieved = True bot.run() return title
def treat(self, photo): """Process each page.""" duplicates = photo.findDuplicateImages() if duplicates: pywikibot.output(u"Skipping duplicate of %r" % duplicates) return duplicates[0] title = photo.getTitle(self.titlefmt) description = photo.getDescription(self.pagefmt) bot = UploadRobot(url=photo.URL, description=description, useFilename=title, keepFilename=True, verifyDescription=False, targetSite=self.site) bot._contents = photo.downloadPhoto().getvalue() bot._retrieved = True bot.run() return title