Example #1
0
    def gotFeed(self, feed):
        if self.wrapper is not None:
            wrapper = self.wrapper(feed, self.ns)
        else:
            if feed.tag == "rss":
                self.wrapper = RSS2Wrapper
            elif feed.tag.startswith(NS_RDF):
                self.ns = NS_RDF
                self.wrapper = RSS1Wrapper
            elif feed.tag.startswith(NS_RSS_09):
                self.ns = NS_RSS_09
                self.wrapper = RSS1Wrapper
            elif feed.tag.startswith(NS_RSS_10):
                self.ns = NS_RSS_10
                self.wrapper = RSS1Wrapper
            elif feed.tag.endswith("feed"):
                self.wrapper = PEAWrapper
            else:
                raise NotImplementedError('Unsupported Feed: %s' % feed.tag)

            wrapper = self.wrapper(feed, self.ns)

            self.title = strip(wrapper.title).encode("UTF-8")
            self.description = strip_readable(wrapper.description
                                              or "").encode("UTF-8")
            self.logoUrl = wrapper.logo

        return self.gotWrapper(wrapper)
Example #2
0
	def gotFeed(self, feed):
		if self.wrapper is not None:
			wrapper = self.wrapper(feed, self.ns)
		else:
			if feed.tag == "rss":
				self.wrapper = RSS2Wrapper
			elif feed.tag.startswith(NS_RDF):
				self.ns = NS_RDF
				self.wrapper = RSS1Wrapper
			elif feed.tag.startswith(NS_RSS_09):
				self.ns = NS_RSS_09
				self.wrapper = RSS1Wrapper
			elif feed.tag.startswith(NS_RSS_10):
				self.ns = NS_RSS_10
				self.wrapper = RSS1Wrapper
			elif feed.tag.endswith("feed"):
				self.wrapper = PEAWrapper
			else:
				raise NotImplementedError, 'Unsupported Feed: %s' % feed.tag

			wrapper = self.wrapper(feed, self.ns)

			self.title = strip(wrapper.title).encode("UTF-8")
			self.description = strip_readable(wrapper.description or "").encode("UTF-8")
			self.logoUrl = wrapper.logo

		return self.gotWrapper(wrapper)
Example #3
0
	def gotWrapper(self, wrapper):
		updated = wrapper.updated
		if updated and self.last_update == updated:
			return []

		idx = 0
		ids = self.last_ids
		for item in wrapper:
			# Try to read title, continue if none found
			title = strip(item.title)
			if not title:
				continue

			# Try to read id, continue if none found (invalid feed or internal error) or to be excluded
			id = item.id
			if not id or id in ids:
				continue

			# Link
			link = item.link

			# Try to read summary, empty if none
			summary = strip_readable(item.summary or "")

			# Update Lists
			self.history.insert(idx, (
					title.encode("UTF-8"),
					link.encode("UTF-8"),
					summary.encode("UTF-8"),
					item.enclosures
			))
			ids.add(id)

			idx += 1

		# Eventually cut history
		del self.history[self.MAX_HISTORY_ELEMENTS:]

		return self.history[:idx]
Example #4
0
	def gotWrapper(self, wrapper):
		updated = wrapper.updated
		if updated and self.last_update == updated:
			return []

		idx = 0
		ids = self.last_ids
		for item in wrapper:
			# Try to read title, continue if none found
			title = strip(item.title)
			if not title:
				continue

			# Try to read id, continue if none found (invalid feed or internal error) or to be excluded
			id = item.id
			if not id or id in ids:
				continue

			# Link
			link = item.link

			# Try to read summary, empty if none
			summary = strip_readable(item.summary or "")

			# Update Lists
			self.history.insert(idx, (
					title.encode("UTF-8"),
					link.encode("UTF-8"),
					summary.encode("UTF-8"),
					item.enclosures
			))
			ids.add(id)

			idx += 1

		# Eventually cut history
		del self.history[self.MAX_HISTORY_ELEMENTS:]

		return self.history[:idx]