Пример #1
0
	def getLatest(self):
		client = gdata.youtube.service.YouTubeService(client_id='Parklife', developer_key=Defaults.YOUTUBE_API_KEY)		
		gdata.alt.appengine.run_on_appengine(client)		
		
		# retrieve the favorites
		favorites = client.GetYouTubeVideoFeed( self.getFeedUri( user=Config.getKey('youtube_user'), feed='favorites', count=str(self.FETCH_ALL_MAX_ITEMS)))
		# and the uploaded
		uploaded = client.GetYouTubeVideoFeed( self.getFeedUri( user=Config.getKey('youtube_user'), feed='uploads', count=str(self.FETCH_ALL_MAX_ITEMS)))

		# merge the arrays after we've verified that all videos are valid and should be returned
		videos = filter(self.isValid, favorites.entry) + filter(self.isValid, uploaded.entry)
		
		return videos
Пример #2
0
	def getLatest(self):

		# get latest entries only
		# retrieve the twitter user
		c = Config()
		twitter_user = c.getKey('twitter_user')
		
		# quit right away if no twitter user has been provided
		if twitter_user == None:
			raise Exception( 'Twitter username missing' )		

		twitter = Twitter()
		
		# retrieve the newest tweet, if any
		newest_tweet = self.getMostRecentEntry()
		if newest_tweet == None:
			# get everything
			logging.debug('no newest tweet found - requesting all')
			statuses = twitter.statuses.user_timeline(user=twitter_user,count=self.FETCH_ALL_MAX_ENTRIES)			
		else:
			# get only tweets with an id higher than the newest one
			logging.debug('requesting tweets with id greater than ' + str(newest_tweet.external_id))			
			statuses = twitter.statuses.user_timeline(user=twitter_user,since_id=newest_tweet.external_id,count=40)
			
		return(statuses)
Пример #3
0
	def getLatest(self):
		feed_link = Config.getKey( 'google_reader_feed' )
		if feed_link == None:
			raise Exception( 'Please configure your Google Reader shared items feed first!' )
			
		response = feedparser.parse( feed_link )
		return response.entries
Пример #4
0
	def toEntry(self, pictures):
		# and now create the entry
		c = Config()
		e = Entry(source = self.source_id,
			url = "http://picasaweb.google.com/" + c.getKey('picasa_user'))
		
		# define whether we show a matrix with pictures (in case we've got more than one) or just a bigger thumbnail)
		if(len(pictures) > 1):
			html = "<div class=\"picasa-entry\">"
			html += "<ul class=\"picasa-entry-ul\">"
			#for pic in pictures:
			#	html += self.pictureHTML(pic, True)
			html += "".join(map(lambda e: self.pictureHTML(e, True), pictures))				
			html += "</ul></div>"

			e.text = html			
			e.title = "%s new photos (%s)" % (str(len(pictures)), self._getTodayDate())
		else:
			pic = pictures.pop()
			# only one picture, we can show a bigger version of the picture
			# the markup uses different CSS classes so that we can control the styling separately
			e.title = "New photo upload (%s)" % (self._getTodayDate())
			e.text = "<div class=\"picasa-single-entry\">" + self.pictureHTML(pic, False) + "</div>"
					
		return e
Пример #5
0
 def getLatest(self):        
     most_recent = self.getMostRecentEntry()
     try:
         p = pinboard.open(Config.getKey("pinboard_user"), Config.getKey("pinboard_password"))            
         if most_recent == None:                
             posts = p.posts(count=self.FETCH_ALL_MAX_LINKS)
         else:
             posts = p.posts(date=most_recent.created.strftime("%Y-%m-%dT%H:%M:%SZ"))
     except:
         logging.error( 'Could not retrieve Pinboard posts for user: '******'pinboard_user')))
         raise
     
     # filter posts whose title is "instagram"
     if Defaults.PINBOARD_IGNORE_INSTAGRAM_LINKS == True:
         logging.debug("Filtering Instagram posts")
         posts = filter(lambda p: p['description'].lower() != 'instagram', posts)
     
     return posts
Пример #6
0
	def getLatest(self):
		# retrieve the user
		c = Config()
		picasa_user = c.getKey('picasa_user')		
		# quit right away if no user has been provided
		if picasa_user == None:
			raise Exception( 'Picasa username missing, unable to proceed' )
			
		# get the most recent picasa entry from the db
		latest_entry = self.getMostRecentEntry()
		if latest_entry == None:
			latest_entry_created_date = parse("2000-01-01T00:00:00")
		else:
			latest_entry_created_date = latest_entry.created
			
		# to hold the pictures to be added	
		to_add = []
			
		# get the latest pictures via the API
		client = gdata.photos.service.PhotosService()
		latest_pics = client.GetUserFeed(user=picasa_user, kind='photo', limit=self.MAX_PHOTOS) # let's see if we can process so many of them
		for pic in latest_pics.entry:
			# we don't need the time zone, and if we keep it then we'll run into trouble when comparing the dates
			picture_date = pic.published.text[0:len(pic.published.text)-5]
			logging.debug("Picasa source: latest_entry_created_date: %s - pic.published.text: %s - picture_date: %s" % (str(latest_entry_created_date), str(pic.published.text), str(picture_date)))			

			# is it newer than the newest picasa entry in the db?			
			if(parse(picture_date)) > latest_entry_created_date:
				to_add.append(pic)
			else:
				# we can probably get out of this loop
				break
				
		# create an entry only if there's something to add
		num_new_pics = len(to_add)
		
		# this should will ever only add one entry, regardless of how many pictures are found		
		logging.debug("Picasa source: new pictures to be added: " + str(num_new_pics))
		data = []
		if(num_new_pics > 0):
			data.insert(0, to_add)
								
		return(data)
Пример #7
0
 def getAPI(self):
     access_token = Config.getKey( 'instagram_token' )
     if access_token == None:
         raise Exception( 'Please provide a valid Instagram access token before executing this source' )
         
     return InstagramAPI(access_token=access_token)