#NEWLINE# def getdailynews( self ) : #NEWLINE# #INDENT# date = self . getformatdate ( ) #NEWLINE# newslist = [ ] #NEWLINE# newsjsonlist = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# source = [ '268_new.json' , '270_new.json' ] #NEWLINE# for index in range ( 2 ) : #NEWLINE# #INDENT# self . news_url = ( third_party_api . newsapi % ( date , source [ index ] ) ) #NEWLINE# newslist . extend ( self . getpernews ( ) ) #NEWLINE# #UNINDENT# newslist = sorted ( newslist , key = ( lambda newsitem : newsitem [ 'putdate' ] ) , reverse = True ) #NEWLINE# latestnews = basesqlutil . select_latest_news_sql ( ) #NEWLINE# if ( latestnews is None ) : #NEWLINE# #INDENT# newsjsonlist [ 'nextId' ] = '0' #NEWLINE# indexofsame = 2 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# lastnewsid = latestnews [ 1 ] #NEWLINE# newsjsonlist [ 'nextId' ] = lastnewsid #NEWLINE# indexofsame = self . getsameindex ( lastnewsid , newslist ) #NEWLINE# if ( ( indexofsame is not ( - 1 ) ) and ( indexofsame is not 0 ) ) : #NEWLINE# #INDENT# newslist = newslist [ 0 : indexofsame ] #NEWLINE# #UNINDENT# #UNINDENT# newsjsonlist [ 'newslist' ] = newslist #NEWLINE# newsjsonlist = json . dumps ( newsjsonlist ) . decode ( 'unicode-escape' ) #NEWLINE# if ( ( indexofsame is not 0 ) and ( len ( newslist ) > 8 ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# basesqlutil . news_insert_sql ( 'news' , str ( source [ 0 ] [ 'articleId' ] ) , newsjsonlist , str ( date ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return 'error' #NEWLINE# #UNINDENT# #UNINDENT# return str ( newsjsonlist )