def get_tag_by_link(link): url = helpers.get_url_from_link(link).strip('/').split('/')[0] if not Retriever.TAGS_MAPPING: dm = WaitingDM() print 'downloading main page of LibRu for retrieving tags...' html = dm.download( helpers.get_site_root_link(link) ) soup = get_soup(html) dirs = Retriever.get_dirs(soup) for link, tag in dirs: Retriever.TAGS_MAPPING[link.strip('/')] = tag if not Retriever.TAGS_MAPPING.has_key(url): #TODO make other way for retrieving of tags for this case logger.write_fail("LibRu parser: can't find tag in main page",link=link, url=url) return None return Retriever.TAGS_MAPPING[url]
def get_filename(self): site_link = helpers.get_site_root_link(self.opds_link) site_link = site_link.replace("http://", "") site_link = site_link.replace("www.", "") site_link = site_link.replace(".", "_") return site_link