def add_trans_to_db(season, episode):
	if deployed_on_sae:
		s = sae.storage.Client()
		filename = 's%02de%02d' % (season, episode)
		ob = s.get('tbbtsubfile', filename + '.txt')
		lines = ob.data.split('\r\n')
	else:
		filename = 's%02de%02d' % (season, episode)
		f = open('storage/tbbtsubfile/' + filename + '.txt','r')
		lines = f.readlines()
		f.close()
	trans = parse_trans(lines)
	episode = Episode(season=season, episode=episode, title='example')
	episode.scenes = []
	for scene in trans:
		s = Scene(title=scene['scene'])
		s.speeches = []
		for speech in scene['speeches']:
			sp = Speech(figure=speech['figure'], content=speech['content'])
			s.speeches.append(sp)
		episode.scenes.append(s)
	
	if not Episode.query.filter_by(season=season, episode=episode).first() :
		db.session.add(episode)
		db.session.commit()
		return 'ok'
	else: 
		return 'exsit'
def get_trans(season, episode):
	if deployed_on_sae:
		s = sae.storage.Client()
		filename = 's%02de%02d' % (season, episode)
		ob = s.get('tbbtsubfile', filename + '.txt')
		lines = ob.data.split('\r\n')
	else:
		filename = 's%02de%02d' % (season, episode)
		f = open('storage/tbbtsubfile/' + filename + '.txt','r')
		lines = f.readlines()
		f.close()
	data = {'status': 'success', 'trans': parse_trans(lines)}
	resp = jsonify(data)
	resp.status_code = 200
	return resp