Пример #1
0
	def transformEnclosure(self, url, enclosure, host):
		# TODO: don't transform the enclosure if we won't prefetch it (if record.sent)
		# TODO: refactor this with the other transformEnclosure()
		# TODO: Catch value errors on other fields as well
		try:
			length = int(enclosure.getAttribute('length').encode('utf8'))
		except ValueError:
			# Set length to zero and hope that we can use HTTP Content-Length header later.
			length = 0
		channel = getChannel(enclosure)
		title = getTitle(enclosure)
		record = self.feedStore.get(url)
		if not record:
			record = Record(url, length, channel, title)
			self.feedStore[url] = record
		else:
			# Don't reset length based on enclosure value. It may be wrong. (The
			# Content-Length received while prefetching is usually more accurate.)
			if record.length == 0:
				record.length = length
			record.channel = channel
			record.title = title
		record.published = getPubDate(enclosure)
		record.partialPath = utils.getPartialPathName(url)
		record.lastSeen = time.time()
		enclosure.setAttribute('url', utils.getEnclosureURL(url, host))
Пример #2
0
	def updateFeed(self, url, enclosure, length, torrentFile):
		channel = getChannel(enclosure)
		title = getTitle(enclosure)
		record = self.feedStore.get(url)
		if not record:
			record = Record(url, length, channel, title)
			self.feedStore[url] = record
		else:
			if length > 0:
				record.length = length
			record.channel = channel
			record.title = title
		record.torrentFile = torrentFile
		record.published = getPubDate(enclosure)
		record.lastSeen = time.time()
		return record