示例#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) if PY3 else strip(wrapper.title).encode('utf-8')
			self.description = strip_readable(wrapper.description or "") if PY3 else strip_readable(wrapper.description or "").encode('utf-8')
			self.logoUrl = wrapper.logo

		return self.gotWrapper(wrapper)
示例#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)
示例#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 PY3 else item.title.encode('utf-8'))
			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 if PY3 else item.link.encode('utf-8')

			# Try to read summary, empty if none
			summary = strip_readable(item.summary or "") if PY3 else strip_readable(item.summary or "").encode('utf-8')

			# Update Lists
			self.history.insert(idx, (title, link, summary, item.enclosures))
			ids.add(id)

			idx += 1

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

		return self.history[:idx]
示例#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]