Esempio n. 1
0
	def GET(self,tips=None):
		user = self.getcurrentuser()
		#所有RSS源和已订阅的源
		ownfeeds = model.userid2feeds(user.k_id) if user else None
		books = list(model.get_allbooks())#webpy返回的是storage对象,用一次就不见了
		category = list(model.get_category())
		return jjenv.get_template("my.html").render(nickname=session.username,current='my',title='My subscription',books=books,ownfeeds=ownfeeds,tips=tips,level=user.level,cate=category)
Esempio n. 2
0
	def GET(self):
		username = web.input().get('u')
		if username:
			#搜索自动处理的feed(字符串http开头)
			feeds = []
			#搜索手动处理的feed
			mfeeds = []
			ownfeeds = model.username2feeds(username)
			if len(ownfeeds) != 0:
				#取feeds信息
				books = (model.get_allbooks())
				for book in books:
					if book.f_id in ownfeeds:
						b=[]
						if cmp('http',book.url[0:4].lower()) == 0:
							b.append(book.title)
							b.append(book.url)
							if book.isfulltext == 1:
								b.append(True)
							else:
								b.append(False)
							feeds.append(b)
						else:
							b.append(book.url)
							mfeeds.append(b)
				#取用户信息
				user = model.getuser(username)[0]
				#加入eq
				if user and user.kindle_email:
					jobq.enqueue(pushwork,user.kindle_email,feeds,mfeeds,user.keep_image)
			return jjenv.get_template("autoback.html").render(nickname=session.username,title='Delivering',tips='books put to queue!')
Esempio n. 3
0
 def GET(self, tips=None):
     user = self.getcurrentuser()
     #所有RSS源和已订阅的源
     ownfeeds = model.userid2feeds(user.k_id) if user else None
     books = list(model.get_allbooks())  #webpy返回的是storage对象,用一次就不见了
     return jjenv.get_template("my.html").render(nickname=session.username,
                                                 current='my',
                                                 title='My subscription',
                                                 books=books,
                                                 ownfeeds=ownfeeds,
                                                 tips=tips,
                                                 level=user.level)
Esempio n. 4
0
    def GET(self):
        username = web.input().get('u')
        adminpush = web.input().get('p')

        if username and adminpush != None:  #用于管理员测试
            #搜索自动处理的feed(字符串http开头)
            feeds = []
            #搜索手动处理的feed
            mfeeds = []
            feeds_num = 0
            ownfeeds = model.username2feeds(username)
            if len(ownfeeds) != 0:
                #取feeds信息
                books = (model.get_allbooks())
                for book in books:
                    if book.f_id in ownfeeds:
                        b = []
                        if cmp('http', book.url[0:4].lower()) == 0:
                            b.append(book.title)
                            b.append(book.url)
                            if book.isfulltext == 1:
                                b.append(True)
                            else:
                                b.append(False)
                            feeds.append(b)
                        else:
                            b.append(book.url)
                            mfeeds.append(b)
                        feeds_num += 1
                #取用户信息
                user = model.getuser(username)[0]
                #加入eq
                if user and user.kindle_email:
                    jobq.enqueue(pushwork,
                                 args=(user.kindle_email, feeds, mfeeds,
                                       user.keep_image),
                                 timeout=feeds_num * 300)
            return jjenv.get_template("autoback.html").render(
                nickname=session.username,
                title='Delivering',
                tips='admin已投递!')
        else:
            user = model.getuser(username)[0]
            if user and user.kindle_email:
                ROOT = path.dirname(path.abspath(__file__))
                output_dir = path.join(ROOT, 'templates2')
                mobi_file = path.join(output_dir, 'WelcomeRedKindle.mobi')
                jobq.enqueue(send_mail, SrcEmail, user.kindle_email, mobi_file)
            return jjenv.get_template("autoback.html").render(
                nickname=session.username, title='Delivering', tips='已投递!')
Esempio n. 5
0
	def GET(self):
		username = web.input().get('u')
		adminpush = web.input().get('p')

		if username and adminpush != None:#用于管理员测试
			#搜索自动处理的feed(字符串http开头)
			feeds = []
			#搜索手动处理的feed
			mfeeds = []
			feeds_num = 0
			ownfeeds = model.username2feeds(username)
			if len(ownfeeds) != 0:
				#取feeds信息
				books = (model.get_allbooks())
				for book in books:
					if book.f_id in ownfeeds:
						b=[]
						if cmp('http',book.url[0:4].lower()) == 0:
							b.append(book.title)
							b.append(book.url)
							if book.isfulltext == 1:
								b.append(True)
							else:
								b.append(False)
							feeds.append(b)
						else:
							b.append(book.url)
							mfeeds.append(b)
						feeds_num += 1
				#取用户信息
				user = model.getuser(username)[0]
				#加入eq
				if user and user.kindle_email:
					jobq.enqueue(pushwork,args=(user.kindle_email,feeds,mfeeds,user.keep_image),timeout=feeds_num*300)
			return jjenv.get_template("autoback.html").render(nickname=session.username,title='Delivering',tips='admin已投递!')
		else:
			user = model.getuser(username)[0]
			if user and user.kindle_email:
				ROOT = path.dirname(path.abspath(__file__))
				output_dir = path.join(ROOT, 'templates2')
				mobi_file = path.join(output_dir,'WelcomeRedKindle.mobi')
				jobq.enqueue(send_mail,SrcEmail,user.kindle_email,mobi_file)
			return jjenv.get_template("autoback.html").render(nickname=session.username,title='Delivering',tips='已投递!')
Esempio n. 6
0
tz = pytz.timezone('GMT')
date = datetime.now(tz)
hour = date.hour
users =  model.get_current_push_users(hour)
if len(users) == 0:
	print '-=end=-'
else:
	#推送
	for user in users:
		feeds = []
		mfeeds = []
		feeds_num = 0
		ownfeeds = model.username2feeds(user.name)
		if len(ownfeeds) != 0:
			books = (model.get_allbooks())
			for book in books:
				if book.f_id in ownfeeds:
					b=[]
					if cmp('http',book.url[0:4].lower()) == 0:
						b.append(book.title)
						b.append(book.url)
						if book.isfulltext == 1:
							b.append(True)
						else:
							b.append(False)
						feeds.append(b)
					else:
						b.append(book.url)
						mfeeds.append(b)
					feeds_num += 1
Esempio n. 7
0
import web
import model

from config import *

# 计算时间差
def Caltime(date1, date2):
    date1 = time.strptime(date1, "%Y-%m-%d %H:%M:%S")
    date2 = time.strptime(date2, "%Y-%m-%d %H:%M:%S")
    date1 = datetime.datetime(date1[0], date1[1], date1[2], date1[3], date1[4], date1[5])
    date2 = datetime.datetime(date2[0], date2[1], date2[2], date2[3], date2[4], date2[5])
    return (date2 - date1).seconds / 3600


print "-------------------"
feeds = model.get_allbooks()

for feed in feeds:
    # 是否需要更新
    if (feed.last_update == None) or (
        Caltime(feed.last_update.strftime("%Y-%m-%d %H:%M:%S"), datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        >= feed.update_cycle
    ):
        # 更新
        temp_feed = []
        temp_f = []
        temp_f.append(feed.title)
        temp_f.append(feed.url)
        if feed.isfulltext == 1:
            temp_f.append(True)
        else:
Esempio n. 8
0
from config import *


#计算时间差
def Caltime(date1, date2):
    date1 = time.strptime(date1, "%Y-%m-%d %H:%M:%S")
    date2 = time.strptime(date2, "%Y-%m-%d %H:%M:%S")
    date1 = datetime.datetime(date1[0], date1[1], date1[2], date1[3], date1[4],
                              date1[5])
    date2 = datetime.datetime(date2[0], date2[1], date2[2], date2[3], date2[4],
                              date2[5])
    return (date2 - date1).seconds / 3600


print '-------------------'
feeds = model.get_allbooks()

for feed in feeds:
    #是否需要更新
    if (feed.last_update == None) or (Caltime(
            feed.last_update.strftime("%Y-%m-%d %H:%M:%S"),
            datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) >=
                                      feed.update_cycle):
        #更新
        temp_feed = []
        temp_f = []
        temp_f.append(feed.title)
        temp_f.append(feed.url)
        if feed.isfulltext == 1:
            temp_f.append(True)
        else:
Esempio n. 9
0
tz = pytz.timezone('GMT')
date = datetime.now(tz)
hour = date.hour
users = model.get_current_push_users(hour)
if len(users) == 0:
    print '-=end=-'
else:
    #推送
    for user in users:
        feeds = []
        mfeeds = []
        feeds_num = 0
        ownfeeds = model.username2feeds(user.name)
        if len(ownfeeds) != 0:
            books = (model.get_allbooks())
            for book in books:
                if book.f_id in ownfeeds:
                    b = []
                    if cmp('http', book.url[0:4].lower()) == 0:
                        b.append(book.title)
                        b.append(book.url)
                        if book.isfulltext == 1:
                            b.append(True)
                        else:
                            b.append(False)
                        feeds.append(b)
                    else:
                        b.append(book.url)
                        mfeeds.append(b)
                    feeds_num += 1