def dissect_comment(comment): """ :param comment: comment string :raises exceptions.MovieNotFound :raises exceptions.EpisodeNotFound :raises exceptions.OffensiveWord """ split_command = comment.split(" ") requests_command = split_command[0] if not any(commands in requests_command.lower() for commands in COMMANDS): return split_command.pop(0) final_comment = " ".join(split_command) try: title = final_comment.split("[")[0].rstrip() if is_episode(title): search_episode(EPISODE_LIST, title, raise_resting=False) else: search_movie(MOVIE_LIST, title, raise_resting=False) except IndexError: return content = REQUEST_RE.findall(final_comment) if content: [check_offensive_content(text) for text in content] return { "command": requests_command, "title": title, "comment": final_comment, "content": content, }
def dissect_comment(comment): """ :param comment: comment string :raises exceptions.MovieNotFound :raises exceptions.EpisodeNotFound :raises exceptions.OffensiveWord :raises exceptions.IvalidRequest """ split_command = comment.split(" ") requests_command = split_command[0] if requests_command.lower() not in COMMANDS: return split_command.pop(0) final_comment = " ".join(split_command) if requests_command == "!parallel": parallels = is_parallel(final_comment) try: contents = [REQUEST_RE.findall(parallel) for parallel in parallels] if any(len(content) > 1 for content in contents) or len(parallels) > 3: raise InvalidRequest(final_comment) except TypeError: return title, content = "Parallel", ["Parallel"] else: try: title = final_comment.split("[")[0].rstrip() if is_episode(title): search_episode(EPISODE_LIST, title, raise_resting=False) else: search_movie(MOVIE_LIST, title, raise_resting=False) except IndexError: return content = REQUEST_RE.findall(final_comment) if content: [check_offensive_content(text) for text in content] return { "command": requests_command, "title": title, "comment": final_comment, "content": content, }
async def search(ctx, *args): query = " ".join(args) try: if is_episode(query): result = search_episode(EPISODE_LIST, query, raise_resting=False) message = f"{BASE}/episode/{result['id']}" else: result = search_movie(MOVIE_LIST, query, raise_resting=False) message = f"{BASE}/movie/{result['tmdb']}" except (MovieNotFound, EpisodeNotFound): message = "apoco si pa" await ctx.send(message)
def search_item(query, return_dict=False): if is_episode(query): EPISODE_LIST = db.get_list_of_episode_dicts() result = search_episode(EPISODE_LIST, query, raise_resting=False) if not return_dict: return f"{BASE}/episode/{result['id']}" else: MOVIE_LIST = db.get_list_of_movie_dicts() result = search_movie(MOVIE_LIST, query, raise_resting=False) if not return_dict: return f"{BASE}/movie/{result['tmdb']}" return result