def __init__( self, content, movie_list, episode_list, req_dictionary, multiple=False, ): search_func = search_episode if req_dictionary[ "is_episode"] else search_movie self.movie = search_func( episode_list if req_dictionary["is_episode"] else movie_list, req_dictionary["movie"], req_dictionary["parallel"] is None, ) self.discriminator, self.chain, self.quote = None, None, None self.pill = [] self.content = convert_request_content(content) self.req_dictionary = req_dictionary self.is_minute = self.content != content self.multiple = multiple self.dar = self.movie.get("dar") self.path = self.movie["path"] self.verified = req_dictionary["verified"] self.legacy_palette = "!palette" == self.req_dictionary["type"] if self.legacy_palette and len(req_dictionary["content"]) > 1: raise exceptions.InvalidRequest(req_dictionary["comment"])
def guess_subtitle_chain(subtitle_list, req_dictionary): """ :param subtitle_list: list of srt.Subtitle objects :param req_dictionary: request comment dictionary """ content = req_dictionary["content"] req_dictionary_length = len(content) if (any( isinstance(convert_request_content(req_), int) for req_ in content) or req_dictionary_length == 1): return perfect_chain = check_perfect_chain(content, subtitle_list) if len(perfect_chain) == len(content): logger.info("Found perfect chain: %s" % [per.content for per in perfect_chain]) return [to_dict(chain) for chain in perfect_chain] first_quote = find_quote(subtitle_list, content[0]) first_index = first_quote["index"] chain_list = [] for i in range(first_index - 1, (first_index + req_dictionary_length) - 1): chain_list.append(to_dict(subtitle_list[i])) try: check_chain_integrity(content, [i["message"] for i in chain_list]) logger.info(f"Chain request found: {req_dictionary_length} quotes") return chain_list except exceptions.InconsistentSubtitleChain: return
def __init__( self, content, movie_list, episode_list, req_dictionary, multiple=False, ): self.on_demand = req_dictionary.get("on_demand", False) search_func = search_episode if req_dictionary[ "is_episode"] else search_movie raise_resting = ((req_dictionary["parallel"] is None) if not self.on_demand else not self.on_demand) self.movie = search_func( episode_list if req_dictionary["is_episode"] else movie_list, req_dictionary["movie"], raise_resting, ) self.discriminator, self.chain, self.quote = None, None, None self.pill = [] self.content = convert_request_content(content) self.req_dictionary = req_dictionary self.is_minute = self.content != content self.dar = self.movie.get("dar") self.path = self.movie["path"] self.verified = req_dictionary["verified"] self.legacy_palette = "!palette" == self.req_dictionary["type"] self.multiple = multiple or self.legacy_palette if self.legacy_palette and len(req_dictionary["content"]) > 1: raise exceptions.InvalidRequest( "Palette requests only support one bracket.")
def get_range(content): """ :param content: string from request square bracket """ seconds = [convert_request_content(second.strip()) for second in content.split("-")] if any(isinstance(second, str) for second in seconds): logger.info("String found. Quote request") return content if len(seconds) != 2: raise InvalidRequest(f"Expected 2 timestamps, found {len(seconds)}.") logger.info("Good gif timestamp request") return tuple(seconds)
def __init__( self, query, content, movie_list, episode_list, req_dictionary, multiple=False, is_episode=False, ): if is_episode: self.movie = search_episode(episode_list, query) else: self.movie = search_movie(movie_list, query) self.discriminator, self.chain = None, None self.content = convert_request_content(content) self.req_dictionary = req_dictionary self.is_minute = self.content != content self.query = query self.multiple = multiple self.dar = self.movie.get("dar") self.path = self.movie.get("path") self.pill = []