def parseItem(self, item): entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text entry.link = item.find("link").text entry.details_link = item.find("comments").text entry.indexerguid = item.find("guid").text entry.size = int(item.find("size").text) entry.attributes = [] entry.has_nfo = NzbSearchResult.HAS_NFO_NO categories = item.find("category") if categories is not None: categories = categories.text entry.category = getByNewznabCats(categories) for i in item.findall("./newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"}): attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] entry.attributes.append({"name": attribute_name, "value": attribute_value}) entry.pubDate = item.find("pubDate").text pubDate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') entry.epoch = pubDate.timestamp entry.pubdate_utc = str(pubDate) entry.age_days = (arrow.utcnow() - pubDate).days entry.precise_date = True entry.downloadType = "torrent" return entry
def parseItem(self, item): usenetdate = None entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text entry.link = item.find("link").text entry.attributes = [] entry.pubDate = item.find("pubDate").text entry.indexerguid = item.find("guid").text if entry.indexerguid: m = self.guidpattern.search(entry.indexerguid) if m: entry.indexerguid = m.group(2) entry.has_nfo = NzbSearchResult.HAS_NFO_MAYBE description = item.find("description") if description is not None: description = description.text if description is not None and "Group:" in description: # DogNZB has the group in its description m = self.grouppattern.search(description) if m and m.group(1) != "not available": entry.group = m.group(1) categories = [] for i in item.findall("./newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"}): attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] if attribute_name == "size": entry.size = int(attribute_value) elif attribute_name == "guid": entry.indexerguid = attribute_value elif attribute_name == "category" and attribute_value != "": try: categories.append(int(attribute_value)) except ValueError: self.error("Unable to parse category %s" % attribute_value) elif attribute_name == "poster": entry.poster = attribute_value elif attribute_name == "password" and attribute_value != "0": entry.passworded = True elif attribute_name == "group" and attribute_value != "not available": entry.group = attribute_value elif attribute_name == "usenetdate": try: usenetdate = arrow.get(attribute_value, 'ddd, DD MMM YYYY HH:mm:ss Z') except ParserError: logger.debug("Unable to parse usenet date format: %s" % attribute_value) usenetdate = None # Store all the extra attributes, we will return them later for external apis entry.attributes.append({"name": attribute_name, "value": attribute_value}) entry.details_link = self.get_details_link(entry.indexerguid) if usenetdate is None: # Not provided by attributes, use pubDate instead usenetdate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') entry.epoch = usenetdate.timestamp entry.pubdate_utc = str(usenetdate) entry.age_days = (arrow.utcnow() - usenetdate).days entry.precise_date = True entry.category = getByNewznabCats(categories) return entry
def parseItem(self, item): entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text entry.title = self.cleanUpTitle(entry.title) entry.link = item.find("link").text entry.details_link = item.find("comments").text entry.indexerguid = item.find("guid").text entry.comments = 0 size = item.find("size") if size is not None: entry.size = int(size.text) entry.attributes = [] entry.has_nfo = NzbSearchResult.HAS_NFO_NO categories = item.find("category") if categories is not None: categories = categories.text entry.category = getByNewznabCats(categories) attributes = item.findall( "torznab:attr", {"torznab": "http://torznab.com/schemas/2015/feed"}) attributes.extend( item.findall("newznab:attr", { "newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/" })) for i in attributes: attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] entry.attributes.append({ "name": attribute_name, "value": attribute_value }) if attribute_name == "size": entry.size = int(attribute_value) if attribute_name == "grabs": entry.grabs = int(attribute_value) entry.pubDate = item.find("pubDate").text pubDate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') self.getDates(entry, pubDate) entry.downloadType = "torrent" # For some trackers several results with the same ID are returned (e.g. PTP so we need to make sure the ID is unique) entry.indexerguid += str(entry.size) return entry
def parseItem(self, item): entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text entry.title = self.cleanUpTitle(entry.title) entry.link = item.find("link").text entry.details_link = item.find("comments").text entry.indexerguid = item.find("guid").text entry.comments = 0 size = item.find("size") if size is not None: entry.size = int(size.text) entry.attributes = [] entry.has_nfo = NzbSearchResult.HAS_NFO_NO categories = item.find("category") if categories is not None: categories = categories.text entry.category = getByNewznabCats(categories) attributes = item.findall("torznab:attr", {"torznab": "http://torznab.com/schemas/2015/feed"}) attributes.extend(item.findall("newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"})) for i in attributes: attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] entry.attributes.append({"name": attribute_name, "value": attribute_value}) if attribute_name == "size": entry.size = int(attribute_value) if attribute_name == "grabs": entry.grabs = int(attribute_value) entry.pubDate = item.find("pubDate").text pubDate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') self.getDates(entry, pubDate) entry.downloadType = "torrent" # For some trackers several results with the same ID are returned (e.g. PTP so we need to make sure the ID is unique) entry.indexerguid += str(entry.size) return entry
def parseItem(self, item): usenetdate = None entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text entry.title = self.cleanUpTitle(entry.title) entry.link = item.find("link").text entry.pubDate = item.find("pubDate").text guid = item.find("guid") entry.indexerguid = guid.text if "isPermaLink" in guid.attrib.keys( ) and guid.attrib["isPermaLink"] == "true": entry.details_link = entry.indexerguid m = self.guidpattern.search(entry.indexerguid) if m: # Extract GUID from link entry.indexerguid = m.group(2) if not entry.details_link: comments = item.find("comments") # Example: https://nzbfinder.ws/details/1234567jagkshsg72hs8whgs6#comments if comments is not None: entry.details_link = comments.text.replace("#comments", "") entry.has_nfo = NzbSearchResult.HAS_NFO_MAYBE description = item.find("description") if description is not None: description = description.text if description is not None and "Group:" in description: # DogNZB has the group in its description m = self.grouppattern.search(description) if m and m.group(1) != "not available": entry.group = m.group(1) categories = [] for i in item.findall( "./newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"}): attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] if attribute_name == "guid": entry.indexerguid = attribute_value elif attribute_name == "category" and attribute_value != "": try: categories.append(int(attribute_value)) except ValueError: self.error("Unable to parse category %s" % attribute_value) elif attribute_name == "password" and attribute_value != "0": entry.passworded = True elif attribute_name == "nfo": entry.has_nfo = NzbSearchResult.HAS_NFO_YES if int( attribute_value) == 1 else NzbSearchResult.HAS_NFO_NO elif attribute_name == "info" and self.settings.backend.lower( ) in ["nzedb", "nntmux"]: entry.has_nfo = NzbSearchResult.HAS_NFO_YES elif attribute_name == "group" and attribute_value != "not available": entry.group = attribute_value elif attribute_name == "usenetdate": try: usenetdate = arrow.get(attribute_value, [ 'ddd, DD MMM YYYY HH:mm:ss Z', 'ddd, DD MMM YYYY HH:mm:ss ZZZ', 'ddd, DD MMM YYYY HH:mm Z', 'ddd, DD MMM YYYY HH:mm A Z' ]) except ParserError: self.debug("Unable to parse usenet date format: %s" % attribute_value) usenetdate = None else: for x in ["size", "files", "comments", "grabs"]: if attribute_name == x: setattr(entry, x, int(attribute_value)) else: for x in ["guid", "poster"]: if attribute_name == x: setattr(entry, x, attribute_value) # Store all the attributes, we will return them later for external apis entry.attributes.append({ "name": attribute_name, "value": attribute_value }) if self.settings.backend is None or ( self.settings.backend.lower() in ["nzedb", "nntmux"] and entry.has_nfo == NzbSearchResult.HAS_NFO_MAYBE): # If the "info" attribute wasn't found this entry doesn't have an NFO entry.has_nfo = NzbSearchResult.HAS_NFO_NO if not entry.details_link: entry.details_link = self.get_details_link(entry.indexerguid) if usenetdate is None: # Not provided by attributes, use pubDate instead usenetdate = arrow.get(entry.pubDate, [ 'ddd, DD MMM YYYY HH:mm:ss Z', 'ddd, DD MMM YYYY HH:mm:ss ZZZ', 'ddd, DD MMM YYYY HH:mm Z', 'ddd, DD MMM YYYY HH:mm A Z' ]) self.getDates(entry, usenetdate) entry.category = getByNewznabCats(categories) return entry
def parseItem(self, item): usenetdate = None entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text if entry.title and "nzbgeek" in self.settings.host: entry.title = entry.title.replace("-Obfuscated", "") if config.settings.searching.removeLanguage: for word in [ " English", " Korean", " Spanish", " French", " German", " Italian", " Danish", " Dutch", " Japanese", " Cantonese", " Mandarin", " Russian", " Polish", " Vietnamese", " Swedish", " Norwegian", " Finnish", " Turkish", " Portuguese", " Flemish", " Greek", " Hungarian" ]: if entry.title.endswith(word): self.debug("Removing trailing%s from title %s" % (word, entry.title)) entry.title = entry.title[:-len(word)] break entry.link = item.find("link").text entry.attributes = [] entry.pubDate = item.find("pubDate").text entry.indexerguid = item.find("guid").text if entry.indexerguid: m = self.guidpattern.search(entry.indexerguid) if m: entry.indexerguid = m.group(2) entry.has_nfo = NzbSearchResult.HAS_NFO_MAYBE description = item.find("description") if description is not None: description = description.text if description is not None and "Group:" in description: # DogNZB has the group in its description m = self.grouppattern.search(description) if m and m.group(1) != "not available": entry.group = m.group(1) categories = [] for i in item.findall( "./newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"}): attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] if attribute_name == "size": entry.size = int(attribute_value) elif attribute_name == "guid": entry.indexerguid = attribute_value elif attribute_name == "category" and attribute_value != "": try: categories.append(int(attribute_value)) except ValueError: self.error("Unable to parse category %s" % attribute_value) elif attribute_name == "poster": entry.poster = attribute_value elif attribute_name == "password" and attribute_value != "0": entry.passworded = True elif attribute_name == "group" and attribute_value != "not available": entry.group = attribute_value elif attribute_name == "usenetdate": try: usenetdate = arrow.get(attribute_value, 'ddd, DD MMM YYYY HH:mm:ss Z') except ParserError: self.debug("Unable to parse usenet date format: %s" % attribute_value) usenetdate = None # Store all the extra attributes, we will return them later for external apis entry.attributes.append({ "name": attribute_name, "value": attribute_value }) entry.details_link = self.get_details_link(entry.indexerguid) if usenetdate is None: # Not provided by attributes, use pubDate instead usenetdate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') entry.epoch = usenetdate.timestamp entry.pubdate_utc = str(usenetdate) entry.age_days = (arrow.utcnow() - usenetdate).days entry.precise_date = True entry.category = getByNewznabCats(categories) return entry
def parseItem(self, item): usenetdate = None entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text if entry.title and "nzbgeek" in self.settings.host: entry.title = entry.title.replace("-Obfuscated", "") if config.settings.searching.removeLanguage: for word in [" English", " Korean", " Spanish", " French", " German", " Italian", " Danish", " Dutch", " Japanese", " Cantonese", " Mandarin", " Russian", " Polish", " Vietnamese", " Swedish", " Norwegian", " Finnish", " Turkish", " Portuguese", " Flemish", " Greek", " Hungarian"]: if entry.title.endswith(word): self.debug("Removing trailing%s from title %s" % (word, entry.title)) entry.title = entry.title[:-len(word)] break entry.link = item.find("link").text entry.pubDate = item.find("pubDate").text guid = item.find("guid") entry.indexerguid = guid.text if "isPermaLink" in guid.attrib.keys() and guid.attrib["isPermaLink"] == "true": entry.details_link = entry.indexerguid m = self.guidpattern.search(entry.indexerguid) if m: # Extract GUID from link entry.indexerguid = m.group(2) if not entry.details_link: comments = item.find("comments") # Example: https://nzbfinder.ws/details/1234567jagkshsg72hs8whgs6#comments if comments is not None: entry.details_link = comments.text.replace("#comments", "") entry.has_nfo = NzbSearchResult.HAS_NFO_MAYBE description = item.find("description") if description is not None: description = description.text if description is not None and "Group:" in description: # DogNZB has the group in its description m = self.grouppattern.search(description) if m and m.group(1) != "not available": entry.group = m.group(1) categories = [] for i in item.findall("./newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"}): attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] if attribute_name == "guid": entry.indexerguid = attribute_value elif attribute_name == "category" and attribute_value != "": try: categories.append(int(attribute_value)) except ValueError: self.error("Unable to parse category %s" % attribute_value) elif attribute_name == "password" and attribute_value != "0": entry.passworded = True elif attribute_name == "nfo": entry.has_nfo = NzbSearchResult.HAS_NFO_YES if int(attribute_value) == 1 else NzbSearchResult.HAS_NFO_NO elif attribute_name == "info" and self.settings.backend.lower() in["nzedb", "nntmux"]: entry.has_nfo = NzbSearchResult.HAS_NFO_YES elif attribute_name == "group" and attribute_value != "not available": entry.group = attribute_value elif attribute_name == "usenetdate": try: usenetdate = arrow.get(attribute_value, 'ddd, DD MMM YYYY HH:mm:ss Z') except ParserError: self.debug("Unable to parse usenet date format: %s" % attribute_value) usenetdate = None else: for x in ["size", "files", "comments", "grabs"]: if attribute_name == x: setattr(entry, x, int(attribute_value)) else: for x in ["guid", "poster"]: if attribute_name == x: setattr(entry, x, attribute_value) # Store all the attributes, we will return them later for external apis entry.attributes.append({"name": attribute_name, "value": attribute_value}) if self.settings.backend.lower() in ["nzedb", "nntmux"] and entry.has_nfo == NzbSearchResult.HAS_NFO_MAYBE: # If the "info" attribute wasn't found this entry doesn't have an NFO entry.has_nfo = NzbSearchResult.HAS_NFO_NO if not entry.details_link: entry.details_link = self.get_details_link(entry.indexerguid) if usenetdate is None: # Not provided by attributes, use pubDate instead usenetdate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') self.getDates(entry, usenetdate) entry.category = getByNewznabCats(categories) return entry
def testGetByNewznabCats(self): config.settings = Bunch.fromDict(config.initialConfig) cats = "2000" result = categories.getByNewznabCats(cats) self.assertEqual("movies", result.name) cats = 2000 result = categories.getByNewznabCats(cats) self.assertEqual("movies", result.name) cats = "2040" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) cats = u"2040" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) cats = "2040,2050" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) cats = "2050,2040" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) cats = u"2050,2040" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) cats = [2050, 2040] result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) #Test fallback to more general category cats = "2090" result = categories.getByNewznabCats(cats) self.assertEqual("movies", result.name) cats = "2080, 2090" result = categories.getByNewznabCats(cats) self.assertEqual("movies", result.name) #Don't fall back if one category matches a more specific one cats = "2040, 2090" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) cats = "2090, 2040" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name) #Use the most specific category cats = "2000, 2040" result = categories.getByNewznabCats(cats) self.assertEqual("movieshd", result.name)
def parseItem(self, item): usenetdate = None entry = self.create_nzb_search_result() # These are the values that absolutely must be contained in the response entry.title = item.find("title").text if entry.title and "nzbgeek" in self.settings.host: entry.title = entry.title.replace("-Obfuscated", "") if config.settings.searching.removeLanguage: for word in [ " English", " Korean", " Spanish", " French", " German", " Italian", " Danish", " Dutch", " Japanese", " Cantonese", " Mandarin", " Russian", " Polish", " Vietnamese", " Swedish", " Norwegian", " Finnish", " Turkish", " Portuguese", " Flemish", " Greek", " Hungarian" ]: if entry.title.endswith(word): self.debug("Removing trailing%s from title %s" % (word, entry.title)) entry.title = entry.title[:-len(word)] break entry.link = item.find("link").text entry.attributes = [] entry.pubDate = item.find("pubDate").text guid = item.find("guid") entry.indexerguid = guid.text if "isPermaLink" in guid.attrib.keys( ) and guid.attrib["isPermaLink"] == "true": entry.details_link = entry.indexerguid m = self.guidpattern.search(entry.indexerguid) if m: # Extract GUID from link entry.indexerguid = m.group(2) if not entry.details_link: comments = item.find("comments") # Example: https://nzbfinder.ws/details/1234567jagkshsg72hs8whgs6#comments if comments: entry.details_link = comments.text.replace("#comments", "") entry.has_nfo = NzbSearchResult.HAS_NFO_MAYBE description = item.find("description") if description is not None: description = description.text if description is not None and "Group:" in description: # DogNZB has the group in its description m = self.grouppattern.search(description) if m and m.group(1) != "not available": entry.group = m.group(1) categories = [] for i in item.findall( "./newznab:attr", {"newznab": "http://www.newznab.com/DTD/2010/feeds/attributes/"}): attribute_name = i.attrib["name"] attribute_value = i.attrib["value"] if attribute_name == "guid": entry.indexerguid = attribute_value elif attribute_name == "category" and attribute_value != "": try: categories.append(int(attribute_value)) except ValueError: self.error("Unable to parse category %s" % attribute_value) elif attribute_name == "password" and attribute_value != "0": entry.passworded = True elif attribute_name == "nfo": entry.has_nfo = NzbSearchResult.HAS_NFO_YES if int( attribute_value) == 1 else NzbSearchResult.HAS_NFO_NO elif attribute_name == "info" and self.settings.backend.lower( ) in ["nzedb", "nntmux"]: entry.has_nfo = NzbSearchResult.HAS_NFO_YES elif attribute_name == "group" and attribute_value != "not available": entry.group = attribute_value elif attribute_name == "usenetdate": try: usenetdate = arrow.get(attribute_value, 'ddd, DD MMM YYYY HH:mm:ss Z') except ParserError: self.debug("Unable to parse usenet date format: %s" % attribute_value) usenetdate = None else: for x in ["size", "files", "comments", "grabs"]: if attribute_name == x: setattr(entry, x, int(attribute_value)) else: for x in ["guid", "poster"]: if attribute_name == x: setattr(entry, x, attribute_value) # Store all the attributes, we will return them later for external apis entry.attributes.append({ "name": attribute_name, "value": attribute_value }) if self.settings.backend.lower() in [ "nzedb", "nntmux" ] and entry.has_nfo == NzbSearchResult.HAS_NFO_MAYBE: # If the "info" attribute wasn't found this entry doesn't have an NFO entry.has_nfo = NzbSearchResult.HAS_NFO_NO if not entry.details_link: entry.details_link = self.get_details_link(entry.indexerguid) if usenetdate is None: # Not provided by attributes, use pubDate instead usenetdate = arrow.get(entry.pubDate, 'ddd, DD MMM YYYY HH:mm:ss Z') entry.epoch = usenetdate.timestamp entry.pubdate_utc = str(usenetdate) entry.age_days = (arrow.utcnow() - usenetdate).days entry.precise_date = True entry.category = getByNewznabCats(categories) return entry