def check_conditions(_filter, list_item, item, list_language, list_quality, quality_count=0, language_count=0): is_language_valid = True if _filter.language: # logger.debug("title es %s" % item.title) #2nd lang from platformcode import unify _filter.language = unify.set_lang(_filter.language).upper() # viene de episodios if isinstance(item.language, list): #2nd lang for n, lang in enumerate(item.language): item.language[n] = unify.set_lang(lang).upper() if _filter.language in item.language: language_count += 1 else: is_language_valid = False # viene de findvideos else: #2nd lang item.language = unify.set_lang(item.language).upper() if item.language.lower() == _filter.language.lower(): language_count += 1 else: is_language_valid = False is_quality_valid = True quality = "" if _filter.quality_allowed and item.quality != "": # if hasattr(item, 'quality'): # esta validación no hace falta por que SIEMPRE se devuelve el atributo vacío if item.quality.lower() in _filter.quality_allowed: quality = item.quality.lower() quality_count += 1 else: is_quality_valid = False if is_language_valid and is_quality_valid: #TODO 2nd lang: habría que ver si conviene unificar el idioma aqui o no item.list_language = list_language if list_quality: item.list_quality = list_quality item.context = context(item, exist=True) list_item.append(item) # logger.debug("{0} | context: {1}".format(item.title, item.context)) # logger.debug(" -Enlace añadido") logger.debug(" idioma valido?: %s, item.language: %s, filter.language: %s" % (is_language_valid, item.language, _filter.language)) logger.debug(" calidad valida?: %s, item.quality: %s, filter.quality_allowed: %s" % (is_quality_valid, quality, _filter.quality_allowed)) return list_item, quality_count, language_count, _filter.language
def check_conditions(_filter, list_item, item, list_language, list_quality, quality_count=0, language_count=0): is_language_valid = True if _filter.language: # logger.debug("title es %s" % item.title) # 2nd lang from platformcode import unify _filter.language = unify.set_lang(_filter.language).upper() # comes from episodes if isinstance(item.language, list): # 2nd lang for n, lang in enumerate(item.language): item.language[n] = unify.set_lang(lang).upper() if _filter.language in item.language: language_count += 1 else: is_language_valid = False # comes from findvideos else: # 2nd lang item.language = unify.set_lang(item.language).upper() if item.language.lower() == _filter.language.lower(): language_count += 1 else: is_language_valid = False is_quality_valid = True quality = "" if _filter.quality_allowed and item.quality != "": # if hasattr (item, 'quality'): # this validation is not necessary because the empty attribute is ALWAYS returned if item.quality.lower() in _filter.quality_allowed: quality = item.quality.lower() quality_count += 1 else: is_quality_valid = False if is_language_valid and is_quality_valid: #TODO 2nd lang: we should see if it is convenient to unify the language here or not item.list_language = list_language if list_quality: item.list_quality = list_quality item.context = context(item, exist=True) list_item.append(item) # logger.debug("{0} | context: {1}".format(item.title, item.context)) # logger.debug(" -Enlace añadido") elif not item.language: list_item.append(item) logger.debug(" idioma valido?: %s, item.language: %s, filter.language: %s" % (is_language_valid, item.language, _filter.language)) logger.debug(" calidad valida?: %s, item.quality: %s, filter.quality_allowed: %s" % (is_quality_valid, quality, _filter.quality_allowed)) return list_item, quality_count, language_count, _filter.language