Beispiel #1
0
        def textOldStyle(self,link, prepend_text=''):
                lu=LinkUtils()
                short_link = lu.shortenLink(link.url)
		if short_link is None:
			self.text=None
			return
                self.text = "check out this story: %s " %short_link
                if link.facebook_like is not None and link.facebook_like > 5:
                                self.text+=" #facebooklikes %s" %link.facebook_like
                if link.redditups is not None and link.redditups > 5:#reddit ups %s #delicious save %s #instapaper %s #twitter %s
                                self.text+=" #reddit ups %s" % link.redditups
                if link.delicious_count is not None and link.delicious_count > 5:
                                self.text+=" #delicious saves %s" % link.delicious_count
                if link.instapaper_count is not None and link.instapaper_count > 5:
                                self.text+=" #instaright %s" %link.instapaper_count
                if link.tweets is not None and link.tweets > 5:
                                self.text+=" #twitter %s #RTs" %link.tweets
                top_category=None
                if link.categories is not None and len(link.categories) > 0:
                                logging.info('init cat : %s' % str(link.categories))
                                #dicti = ast.literal_eval(link.categories)
                                dicti = eval(link.categories)
                                if len(dicti) > 0:
                                        import operator
                                        logging.info('categories:'+str(dicti))
                                        sorteddict = sorted(dicti.iteritems(), key=operator.itemgetter(1))
                                        top_category = sorteddict[len(sorteddict)-1]
                if len(self.text) <= 140 - 1 - len(prepend_text):
                                if top_category is not None and top_category[0] not in self.text and len(top_category[0]) + len(self.text) +2 <= 140:
                                        self.text +=" #%s" % unicode(top_category[0])
                                if link.diggs is not None and link.diggs > 4 and 8 + len(self.text) +2 <= 140:
                                        self.text +=" #digg %s" % link.diggs
                self.text += " " + prepend_text
                logging.info('self.text: %s' % self.text)
Beispiel #2
0
 def generate_post_message(cls, session):
         if session is None or session.title is None or session.url is None:
                 return None
         lu = LinkUtils()
         short_link = lu.shortenLink(session.url)
         if short_link is None:
                 return None
         return "%s %s via http://www.bit.ly/instarightapp"  % (session.title[0:59], short_link)
Beispiel #3
0
        def textNewStyle(self,link, title_from_url, prepend_text=None):
                lu=LinkUtils()
                short_link = lu.shortenLink(link.url)
                if short_link is None:
                        logging.info('something is wrong with bitly link from %s ... ' % link.url)
                        self.text=None
                        return
                logging.info('new style title %s' %title_from_url)

                if (link.title is None and title_from_url is None) or (title_from_url is not None and len(title_from_url) < 15):
                        logging.info('title not known going back to old style')
                        return self.textOldStyle(link,prepend_text)
                categories = CategoryUtil.getTwitCategories(link.categories)
                self.text =  Twit.generateTwitText(categories, title_from_url, short_link, prepend_text)