def get_response(self): data = dict() data["site_title"] = self.site_name data['dy_hot_video'] = Database.get_hot_videos("电影") data['dsj_hot_video'] = Database.get_hot_videos("电视剧") data['dm_hot_video'] = Database.get_hot_videos("动漫") self.html("normal/index.html", data=data)
def get_response(self): vclass = "" tag = self.get_argument("n", None) type = self.get_argument("t", None) if type == "dy": vclass = "电影" elif type == "dm": vclass = "动漫" elif type == "dsj": vclass = "电视剧" data = dict() if type: data["type"] = type data["vclass"] = vclass data[ "site_title"] = "最新" + vclass + "_推荐" + vclass + "_" + self.site_name videos = Database.get_vclass_videos(vclass) data["tag"] = None if tag: data["tag"] = tag videos = Database.get_vclass_tag_videos(vclass, tag) data[ "site_title"] = "标签_" + tag + "_最新" + vclass + "_推荐" + vclass + "_" + self.site_name data["video"] = self.page(videos) self.html("normal/vclass.html", data=data) else: data["site_name"] = self.site_name self.render("404.html", data=data)
def get_response(self): id = self.get_argument("id", None) vsb = self.get_argument("vsb", None) Database.add_hot(id) if id and vsb: video = Database.get_video(id) data = dict() data[ "site_title"] = "正在播放_" + video.name + "_" + vsb + "_" + self.site_name data['video'] = video subvideo = [] curvideo = [] for sub in video.links.split("\r\n"): temp = dict() temp["episode"] = sub.split("@")[0] temp["link"] = sub.split("@")[1] if temp["episode"] == vsb: curvideo.append(temp) subvideo.append(temp) data['video'] = video data["online"] = random.randint(1, 50) data['sub_video'] = subvideo data['cur_video'] = curvideo[0] self.html("normal/play.html", data=data)
def post_response(self): form = ChatForm(self.fdata) data = Database.get_msg(int(form.data['vid'])) result = [] for v in data: result.append(json.loads(v.content)) self.write(dict(data=result))
def validate_pwd(self, field): if len(field.data) > 14: raise ValidationError("密码长度过长!") data = Database.check_login(self.name.data, field.data) if not data: raise ValidationError("密码不正确!")
def validate_name(self, field): if len(field.data) > 14: raise ValidationError("用户名长度过长!") data = Database.user_unique(field.data) if data: raise ValidationError("昵称已经存在!")
def on_message(self, message): try: data = json.loads(message) data['datenow'] = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S") content = json.dumps(data) sendflag = False if data['code'] == 2: msgs = Database.get_msg_for_ip(self.session.conn_info.ip) if len(msgs) == 5: _a = str(msgs[0].createdAt)[:-3] _b = str(msgs[1].createdAt)[:-3] _c = str(msgs[2].createdAt)[:-3] _d = str(msgs[3].createdAt)[:-3] _e = str(msgs[4].createdAt)[:-3] if _a == _b == _c == _d == _e: sendflag = True Database.create_black(self.request.remote_ip) Database.delete_gbook(self.request.remote_ip) if not sendflag: Database.create_msg(int(data['vid']), data["vsb"], content, self.session.conn_info.ip) self.broadcast(self.waiters, content) except: pass
def get_response(self): data = dict() if self.name.decode(encoding='utf-8') == "admin": data["site_title"] = "后台管理_" + self.site_name data["video"] = self.page(Database.get_videos()) self.html("admin/manage.html", data=data) else: data["site_name"] = self.site_name self.html("404.html", data=data)
def post_response(self): form = UserProfileEditForm(self.fdata) res = dict(code=0) if form.validate(): if Database.save_user(form): res["code"] = 1 else: res = form.errors res["code"] = 0 self.write(res)
def post_response(self): form = RegistForm(self.fdata) res = dict(code=0) if form.validate(): if Database.create_regist_user(form): res["code"] = 1 else: res = form.errors res["code"] = 0 self.write(res)
def get_response(self): q = self.get_argument("q", None) data = dict() if q: data["query"] = q data["site_title"] = "搜索_" + q + "_下的视频列表_" + self.site_name videos = Database.query_videos(q) data["video"] = self.page(videos) self.html("normal/search.html", data=data) else: data["site_name"] = self.site_name self.html("404.html", data=data)
def post_response(self): gbooks = None sendflag = False if self.request.remote_ip: try: gbooks = Database.get_gbook_for_ip(self.request.remote_ip) except: pass if len(gbooks) == 3: _a = str(gbooks[0].createdAt)[:-3] _b = str(gbooks[1].createdAt)[:-3] _c = str(gbooks[2].createdAt)[:-3] if _a == _b == _c: sendflag = True Database.create_black(self.request.remote_ip) Database.delete_gbook(self.request.remote_ip) form = GbookForm(self.fdata) res = dict(code=0) if (not sendflag) and form.validate() and (form.chkcode.data.lower() == self.session["chkcode"].lower()): if Database.create_gbook(form, self.request.remote_ip): res["code"] = 1 else: res = form.errors res["code"] = 0 self.write(res)
def get_response(self): data = dict() if self.name.decode(encoding='utf-8') == "admin": id = self.get_argument("id", None) if id: data = dict() data["site_title"] = "编辑视频_" + self.site_name data["video"] = Database.get_video(id) self.html("admin/edit.html", data=data) else: self.write("编辑失败! <a href=\"/manage/\">点击返回</a>") else: data["site_name"] = self.site_name self.html("404.html", data=data)
def get_response(self): data = dict() if self.name.decode(encoding='utf-8') == "admin": id = self.get_argument("id", None) if id: if Database.delete_video(id): self.write("删除成功! <a href=\"/manage/\">点击返回</a>") else: self.write("删除失败! <a href=\"/manage/\">点击返回</a>") else: self.write("删除失败! <a href=\"/manage/\">点击返回</a>") else: data["site_name"] = self.site_name self.html("404.html", data=data)
def post_response(self): data = dict() if self.name.decode(encoding='utf-8') == "admin": form = InsertForm(self.fdata) res = dict(code=0) if form.validate(): if Database.create_video(form): res["code"] = 1 else: res = form.errors res["code"] = 0 self.write(res) else: data["site_name"] = self.site_name self.html("404.html", data=data)
def get(self, *args, **kwargs): videos = Database.get_videos() data = dict() tags = [] for video in videos: for tag in video.tags.split(" / "): if tag: tags.append(tag) tags = {}.fromkeys(tags).keys() data["tags"] = [] index = 4 for tag in tags: index += 1 temp = dict() temp["index"] = index temp["name"] = tag data["tags"].append(temp) self.render("sitemap.html", data=data)
def get_response(self): id = self.get_argument("id", None) if id: video = Database.get_video(id) data = dict() data["site_title"] = video.name + "_" + self.site_name data['video'] = video data['hot'] = random.randint(45, 99) data['tags'] = video.tags.replace(' ', '').split("/") subvideo = [] for sub in video.links.split("\r\n"): try: temp = dict() temp["episode"] = sub.split("@")[0] temp["link"] = sub.split("@")[1] subvideo.append(temp) except: break data['sub_video'] = subvideo self.html("normal/detail.html", data=data)
def validate_email(self, field): data = Database.user_unique(field.data, 2) if data: raise ValidationError("邮箱已经存在!")
def validate_phone(self, field): data = Database.user_unique(field.data, 3) if data: raise ValidationError("手机已经存在!")
def prepare(self): blacks = Database.get_black() for black in blacks: if self.request.remote_ip == black.ipaddr: self.redirect('/inblack/') break
def user(self): if self.name: return Database.get_user(self.name) else: return None
def get_videos(url_page): print(url_page) try: req = requests.get(url_page, timeout=15) except: return req.encoding = "utf8" soup = BeautifulSoup(req.text, "lxml") links = soup.select( "body > div.movie-wrap > div.container > div > div.filtrate > div > div > div.filtrate-container > div.filtrate-container-body > div > ul > li > a" ) inner_links = [] for link in links: inner_links.append("http://www.007hd.com" + link.get("href")) headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36" } for inner_one in inner_links: try: req = requests.get(inner_one, timeout=15) except: continue req.encoding = "utf8" soup = BeautifulSoup(req.text, "lxml") if len(soup.select("ul.playurl > li")) != 0: video = dict() video["name"] = str(soup.select("div.art-title > h1")[0].string) video["logo"] = str( soup.select("div.details-con1 > a > img")[0].get("data-url")) try: urlretrieve(video["logo"], './temp/' + str(time.time()) + '.png') except: continue video["links"] = "" video_link = "http://www.007hd.com" + soup.select( "ul.details-con2-list > li > a")[0].get("href") try: req = requests.get(video_link, headers=headers, timeout=15) except: continue req.encoding = "utf8" if req.text.find(".m3u8") == -1: continue links = re.findall(r"ff_urls='(.*?)'", req.text) video_link_json = json.loads(links[0]) try: for url in video_link_json["Data"][0]["playurls"]: video["links"] += url[0] + "@" + url[1] + "\r\n" video["links"] = str(video["links"][:-2]) except: continue video["actors"] = "" actors_many = soup.select( "body > div.movie-wrap > div.details-body > div.details-left.fl > div.details-con1 > div > div.synopsis > p:nth-child(2) > a" ) try: for actors in actors_many: video["actors"] += actors.string + " / " video["actors"] = str(video["actors"][:-3]) except: pass video["director"] = "" video["tags"] = "" try: zha_links = soup.select( "div.details-con1 > div > div.synopsis > p:nth-child(1) > a" ) for zha in zha_links: video["tags"] += zha.string + " / " temp = video["tags"][:-3] video["tags"] = str(temp[0:temp.rfind("/") - 1]) video["director"] = str(temp[temp.rfind("/") + 2:]) except: pass video["area"] = str( soup.select( "div.details-content > div.synopsis > p:nth-child(3) > a") [0].string) p = soup.select("div.synopsis > p:nth-child(1)")[0].text video["language"] = str(p.replace(" ", "")[-2:]) y = soup.select( "div.details-content > div.synopsis > p:nth-child(3)")[0].text y = y.replace(" ", "") video["year"] = str(y[y.find("上映") + 4:y.find("更新")]) if url_page.find("dongman") != -1: video["vclass"] = "动漫" elif url_page.find("dianying") != -1: video["vclass"] = "电影" elif url_page.find("dianshiju") != -1: video["vclass"] = "电视剧" video["status"] = "" try: video["status"] = str( soup.select("div.details-con1 > div > div.vod_t > font") [0].string) except: pass video["desc"] = str( soup.select( "div.details-con1 > div > div.synopsis > p.synopsis-article" )[0].text) for k, v in video.items(): if not v: video[k] = "" # for video_data in database_videos: # if video["name"] == video_data.name: # if video["links"] != video_data.links: # Database.update_video_2(video_data.id, video) # break # else: # Database.create_video_2(video) Database.create_video_2(video) print(video)
def get_response(self): data = dict() data["site_title"] = "个人资料_" + self.site_name data["user"] = Database.get_user(self.name) data["xz"] = xz['xing_zuo'] self.html("normal/profile.html", data=data)