def getTitleSet(self): dbs = Movie.query.all() from blist import blist result = blist([]) for db in dbs: striped_string = getTitle(db.titles) result.append(striped_string) return result
def _report(self, info): assert (isinstance(info, dict)) title = info['titles'] try: title_en_l = getTitle(title) except TypeError: # May be title is 'None' return title_en = title_en_l[1] strip_title = title_en_l[0] movier = MovieInfo(strip_title) movier.get() movie_cover = movier.cover() movie_rating = movier['rating'] movie_outline = movier['outline'] try: movie_genres = movier['genres'][ 0] # has form [u'Comedy', u'Crime'] except IndexError: movie_genres = movier['genres'] if not self._require_rating(movie_rating): return subject = "(" + str(movie_rating) + ", " + info['votes'] + ", " + info[ 'hits'] + ", " + movie_genres + ") " + title #print subject mailer = Mailer() mailer.sender = self.sender mailer.receiver = var.receiver mailer.url = info['urls'] mailer.subject = subject mailer.attachText("====================") mailer.attachText(title) mailer.attachText("====================") mailer.attachText(movier['title']) mailer.attachText("\n\n") mailer.attachText(str(movie_rating)) mailer.attachText("\n\n") try: mailer.attachText(movie_outline) except UnicodeEncodeError: mailer.attachText("The outline contains non-ascii character.") mailer.attachText("\n\n") if movie_cover: try: mailer.attachImage(movie_cover) except: pass mailer.send()
def _report(self, info): assert(isinstance(info, dict)) title = info['titles'] try: title_en_l = getTitle(title) except TypeError: # May be title is 'None' return title_en = title_en_l[1] strip_title = title_en_l[0] movier = MovieInfo(strip_title) movier.get() movie_cover = movier.cover() movie_rating = movier['rating'] movie_outline = movier['outline'] try: movie_genres = movier['genres'][0] # has form [u'Comedy', u'Crime'] except IndexError: movie_genres = movier['genres'] if not self._require_rating(movie_rating): return subject = "(" + str(movie_rating) + ", " + info['votes'] + ", " + info['hits'] + ", " + movie_genres + ") " + title #print subject mailer = Mailer() mailer.sender = self.sender mailer.receiver = var.receiver mailer.url = info['urls'] mailer.subject = subject mailer.attachText("====================") mailer.attachText(title) mailer.attachText("====================") mailer.attachText(movier['title']) mailer.attachText("\n\n") mailer.attachText(str(movie_rating)) mailer.attachText("\n\n") try: mailer.attachText(movie_outline) except UnicodeEncodeError: mailer.attachText("The outline contains non-ascii character.") mailer.attachText("\n\n") if movie_cover: try: mailer.attachImage(movie_cover) except: pass mailer.send()