def __init__(self, bot): self.bot = bot self.loop = bot.loop self.conf = Config('configs/nsfw.json') if 'update' not in self.conf: self.conf['update'] = { 'safebooru': { 'url': 'https://safebooru.donmai.us' }, 'lolibooru': { 'url': 'https://lolibooru.moe' } } self.conf.save() pybooru.resources.SITE_LIST.update(self.conf['update']) if 'yandere-conf' not in self.conf: self.conf['yandere-conf'] = {} if 'danbooru-conf' not in self.conf: self.conf['danbooru-conf'] = {} if 'safebooru-conf' not in self.conf: self.conf['safebooru-conf'] = {} if 'lolibooru-conf' not in self.conf: self.conf['lolibooru-conf'] = {} self.yandere = pybooru.Moebooru('yandere', **self.conf['yandere-conf']) self.danbooru = pybooru.Danbooru('danbooru', **self.conf['danbooru-conf']) self.lolibooru = pybooru.Moebooru('lolibooru', **self.conf['lolibooru-conf']) self.safebooru = pybooru.Danbooru('safebooru', **self.conf['safebooru-conf'])
def pull_booru(argv, delay=5): client = pybooru.Moebooru(random.choice(tuple(booruSites))) try: posts = client.post_list(tags=argv, random=True, limit=16) if not posts: raise EOFError choice = xrand(len(posts)) url = posts[0]["file_url"] return [url, 1, choice + 1] except: return None
def pull_booru(argv, data, thr, delay=5): client = pybooru.Moebooru(random.choice(booruSites)) try: posts = client.post_list(tags=argv, random=True, limit=10) except: print(traceback.format_exc()) return 0 if (len(posts) <= 0): return 0 choice = xrand(len(posts)) url = posts[0]['file_url'] data[thr] = [url, 1, choice + 1]
def pull_booru(argv, delay=5): client = pybooru.Moebooru(choice(tuple(booruSites))) try: posts = client.post_list(tags=argv, random=True, limit=16) if not posts: raise EOFError i = xrand(len(posts)) url = posts[i]["file_url"] return [url, 1, i + 1] except: if LOG: print_exc()