class Country(): def __init__(self): self.lib = lib.Lib() self.moviedb = Moviedb() def get_movie(self, label): vdict = copy.deepcopy(config.vdict) vdict['site_title'] = 'ប្រភេទភាពយន្ត' session['page'] = 0 session['label'] = label vdict['movies'] = self.moviedb.select(vdict['country_max_movie'], label=label) vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type='movie') return render_template('country.html', data=vdict) def load_movie(self): vdict = copy.deepcopy(config.vdict) session['page'] += 1 vdict['movies'] = self.moviedb.select(vdict['country_max_movie'], page=session['page'], label=session['label']) vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type="movie") new_list = [] for movie in vdict['movies']: new_movie = list(movie) new_movie[6] = movie[6].strftime('%d/%m/%Y') new_movie[7] = movie[7].strftime('%H:%M:%S') new_list.append(new_movie) vdict['movies'] = new_list return vdict
class Home(): def __init__(self): self.lib = lib.Lib() self.moviedb = Moviedb() self.seriesdb = Seriesdb() def get_youtube(self): self.vdict = copy.deepcopy(config.vdict) self.get_movie() self.get_series() return render_template('index.html', data=self.vdict) def get_movie(self): self.vdict['movies'] = self.moviedb.select( self.vdict['home_max_movie']) self.vdict['thumbs'] = self.lib.get_thumbs(self.vdict['movies'], 5, type='movie') def get_series(self): self.vdict['series'] = self.seriesdb.select( self.vdict['home_max_movie']) self.vdict['series-thumbs'] = self.lib.get_thumbs(self.vdict['series'], 4, type='movie')
class Movie(): def __init__(self): self.lib = lib.Lib() self.userdb = Userdb() self.moviedb = Moviedb() def get_movie(self, id): vdict = copy.deepcopy(config.vdict) vdict['site_title'] = 'ភាពយន្តទោល' vdict['movies'] = self.moviedb.select(vdict['random_max_movie'], random=id) vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type='movie') vdict['movie'] = self.moviedb.select(id=id) date = (vdict['movie'][6]).strftime('%d/%m/%Y') time = (vdict['movie'][7]).strftime('%H:%M:%S') vdict['datetime'] = (date, time) vdict['author'] = self.userdb.select(username=vdict['movie'][8]) return render_template('movie.html', data=vdict)
def __init__(self): self.lib = lib.Lib() self.moviedb = Moviedb()
class Movie(): def __init__(self): self.lib = lib.Lib() self.moviedb = Moviedb() def get_post(self): vdict = copy.deepcopy(config.vdict) vdict['site_title'] = "ទំព័រភាពយន្តទោល" vdict['datetime'] = self.lib.get_timezone() session['page'] = 0 if (request.method == "POST") and ('logged-in' in session): vid = request.form['fvid'] type = request.form['ftype'] title = request.form['ftitle'] content = request.form['fcontent'] country = request.form['fcountry'] date = request.form['fdate'] time = request.form['ftime'] edit_id = request.form['fedit-id'] author = session['logged-in'] try: date = datetime.datetime.strptime(date, "%d/%m/%Y") except ValueError: vdict['message'] = 'ទំរង់កាលបរិច្ឆេទមិនត្រឹមត្រូវ!' return render_template('dashboard/movie.html', data=vdict) try: time = datetime.datetime.strptime(time, "%H:%M:%S") except ValueError: vdict['message'] = 'ទំរង់ពេលវេលាមិនត្រឹមត្រូវ!' return render_template('dashboard/movie.html', data=vdict) if edit_id: self.moviedb.update(vid, type, title, country, content, date, time, author, edit_id) else: id = str(uuid.uuid4().int) self.moviedb.insert(id, vid, type, title, country, content, date, time, author) vdict['movies'] = self.moviedb.select(vdict['dashboard_max_post']) vdict['count'] = self.moviedb.count() vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type='movie') return render_template('dashboard/movie.html', data=vdict) elif 'logged-in' in session: vdict['movies'] = self.moviedb.select(vdict['dashboard_max_post']) vdict['count'] = self.moviedb.count() vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type='movie') return render_template('dashboard/movie.html', data=vdict) else: return redirect('/login/') def edit(self, id): vdict = copy.deepcopy(config.vdict) vdict['site_title'] = 'កែតំរូវភាពយន្តទោល' vdict['edit-id'] = id if 'logged-in' in session: vdict['movies'] = self.moviedb.select(vdict['dashboard_max_post']) vdict['count'] = self.moviedb.count() vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type='movie') vdict['movie'] = self.moviedb.select(id=id) date = (vdict['movie'][6]).strftime('%d/%m/%Y') time = (vdict['movie'][7]).strftime('%H:%M:%S') vdict['datetime'] = (date, time) return render_template('dashboard/movie.html', data=vdict) return redirect('/login/') def delete(self, id): self.moviedb.delete(id) return redirect('/dashboard/movie/') def load(self): if 'logged-in' in session: vdict = copy.deepcopy(config.vdict) session['page'] += 1 vdict['movies'] = self.moviedb.select(vdict['dashboard_max_post'], page=session['page']) vdict['thumbs'] = self.lib.get_thumbs(vdict['movies'], 5, type="movie") new_list = [] for movie in vdict['movies']: new_movie = list(movie) new_movie[6] = movie[6].strftime('%d/%m/%Y') new_movie[7] = movie[7].strftime('%H:%M:%S') new_list.append(new_movie) vdict['movies'] = new_list return vdict else: return render_template('login.html', data=vdict)