def get(self):
		csv=CSV();
		csv.type="movie_calendar";
		result="Time:"+str(datetime.datetime.now())+"\n";
		log="";
		failed=0;
		
		for i in range(10):
			try:
				cal=get_from_24h();
				for row in cal.list_show: 
					result+=row.toCSV()+'\n';
			except:
				pass;
			else:
				break;
		else:
			failed+=1;
			log+="Cant get from 24h, there is an error!!!!!!!!!!!!!!!!!!!!!!\n";
		
		for i in range(10):
			try:
				cal=get_from_cineplex();
				for row in cal.list_show: 
					result+=row.toCSV()+'\n';
			except:
				pass;
			else:
				break;
		else:
			failed+=1;
			log+="Cant get from Cineplex, there is an error!!!!!!!!!!!!!!!!!!!!!!\n";
		#print sys.exc_info();
		
		for i in range(10):
			try:
				#24h
				cal=get_from_mega_star();
				for row in cal.list_show: 
					result+=str(row)+'\n';
			except:
				pass;
			else:
				break;
		else:
			failed+=1;
			log+="Cant get from Megastar, there is an error!!!!!!!!!!!!!!!!!!!!!!\n";
		
		if failed<=1:
			csv.content=db.Text(result, encoding="utf-8");
			csv.log=db.Text(log, encoding="utf-8");
			csv.put();
		
		print "Done with Failed=",failed;
		print "Log:\n",log;
	def get(self):
		csv=CSV();
		csv.type="movie_info";
		result="Time:"+str(datetime.datetime.now())+"\n";
		today=datetime.date.today();
		failed=0;
		global log;
		log='Log'+str(today)+'\n';
		
		##########Get CSV ########
		query = db.Query(CSV, keys_only=False);
		query.filter("type =","movie_calendar");
		query.order("-created");
		data=query.fetch(1);
		mm=re.findall('\n(.+?)\|',data[0].content);
		dict_title={};
		for movie_title in mm:
			movie_title=movie_title.strip();#trim
			movie_title=re.sub(r'\(.+?\)','',movie_title,1);#remove (linh tinh)
			movie_title=re.sub(' +',' ',movie_title);#strip multiple spaces
			dict_title.setdefault(movie_title,''); #save to dict
		#find info and 
		finder=SearchMovie();
		movie_dict={};
		for movie_title in dict_title:
			info=None;
			for i in range(3):#try 3 time;	
				try:
					info=finder.get_movie_info(movie_title);
				except:
					error=str(sys.exc_info());
					pass;
				else:
					break;
			else:
				failed+=1;
				log+=movie_title+' failed: '+str(error)+'\n';
			
			if info==None:continue;
			movie_dict.setdefault(info.title,info);
			
		for title in movie_dict:
			result+=movie_dict[title].toCSV()+'\n';
		
		if failed<=30:
			csv.content=db.Text(result, encoding="utf-8")
			csv.log=db.Text(log)
			csv.put();
			
		print "Done with Failed=",failed;
		print "Log:\n",log;
	def get(self):
		csv=CSV();
		csv.type="tv_calendar";
		result="Time:"+str(datetime.datetime.now())+"\n";
		today=datetime.date.today();
		failed=0;
		global log;
		log='Log'+str(today)+'\n';
		
		##########VCTV########
		cal=VCTV();
		
		for i in range(5): #try 5 time
			try:
				result_get=cal.get_tv_channel();
			except:
				printf(sys.exc_info());
			else:
				break;
		else:
			printf("Cant get list channel from VCTV, Connection error!");
			result_get=None;
		
		if result_get:
			printf("Get list channel VCTV success!");
			for id in cal.dict_channel.keys():
				for i in range(8): # get today and next 7 day
					date=today+datetime.timedelta(days=i);
					for attemp in range(3): #attemt 3 time if not success
						try:
							cal.get_tv_show(id,date.day,date.month,date.year);
						except:
							pass;
						else:
							break;
					else:
						failed+=1;
						printf(str(cal.dict_channel[id])+str(date)+" failed "+str(failed));
						
			#save to result
			for row in cal.list_show: 
				result+=str(row)+'\n';
		
		##########SCTV########
		cal=SCTV();
		
		for i in range(5): #try 5 time
			try:
				result_get=cal.get_tv_channel();
			except:
				printf(sys.exc_info());
			else:
				break;
		else:
			printf("Cant get list channel from SCTV, Connection error!");
			result_get=None;
		
		if result_get:
			printf("Get list channel SCTV success!");
			for id in cal.dict_channel.keys():
				for i in range(8): # get today and next 7 day
					date=today+datetime.timedelta(days=i);
					for attemp in range(3): #attemt 3 time if not success
						try:
							cal.get_tv_show(id,date.day,date.month,date.year);
						except:
							pass;
						else:
							break;
					else:
						failed+=1;
						printf(str(cal.dict_channel[id])+str(date)+" failed "+str(failed));
						
			#save to result
			for row in cal.list_show: 
				result+=str(row)+'\n';
		
		if failed<=6:
			csv.content=db.Text(result, encoding="utf-8")
			csv.log=db.Text(log, encoding="utf-8")
			csv.put();
		
		print "Done with Failed=",failed;
		print "Log:\n",log;