def wy_update(self): video_url = WangYi().wy_url(self.web_url) video_message = WangYi().wy_message(self.web_url) flags = check_url(self.web_url, video_message, messages()[1][1], messages()[0], video_url) flag1 = flags[0] flag2 = flags[1] flag3 = flags[2] check = '' conn = messages()[0] if flag1 and flag2 and flag3: cur = conn.cursor() sql = "SELECT Video_View, Video_Oppose, Video_Support, Video_Comment, Video_Comment_Fav" \ ", Video_Comment_Against " \ "FROM wangyi " \ "WHERE Video_Web=%s AND Video_Name=%s" try: cur.execute(sql, (self.web_url, video_message[1])) check = cur.fetchone() conn.commit() except Exception as e: print ('videocheck.wangyi.wy_update.check(92): ' + str(e)) conn.rollback() cur.close() flags = update_message(check, conn, self.web_url, video_message) flag4 = flags[0] flag5 = flags[1] flag6 = flags[2] flag7 = flags[3] flag8 = flags[4] flag9 = flags[5] if flag4 and flag5 and flag6 and flag7 and flag8 and flag9: flag = CommentUpdate().wy_update(messages()[0], self.web_url, video_message[1]) if flag: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 没有更新信息。" print (mess) Log.log(mess) conn.close() else: mess = TimeNow.get_time() + " 注意 : 数据库中没有该视频信息,其url : [ %s ]" % self.web_url print (mess) Log.log(mess) try: VideoMysql(self.web_url, messages()[1][1], messages()[0], video_message, video_url).wy_mysql() CommentUpdate().wy_update(messages()[0], self.web_url, video_message[1]) except Exception as e: print ("videocheck.videoupdate.wy_update.wy_mysql(119): " + str(e))
def rr_update(self): video_url = RenRen().rr_url(self.web_url) video_message = RenRen().rr_message(self.web_url) flags = check_url(self.web_url, video_message, messages()[1][0], messages()[0], video_url) flag1 = flags[0] flag2 = flags[1] flag3 = flags[2] check = '' conn = messages()[0] if flag1 and flag2 and flag3: cur = conn.cursor() sql = "SELECT Video_View, Video_Support, Video_Comment " \ "FROM renren " \ "WHERE Video_Web=%s AND Video_Name=%s" try: cur.execute(sql, (self.web_url, video_message[1])) check = cur.fetchone() conn.commit() except Exception as e: print ('videocheck.renren.rr_update.check(43): ' + str(e)) conn.rollback() cur.close() flags = update_message(check, conn, self.web_url, video_message) flag4 = flags[0] flag5 = flags[2] flag6 = flags[3] if flag4 and flag5 and flag6: flag = CommentUpdate().rr_update(messages()[0], self.web_url, video_message[1]) if flag: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 没有更新信息。" print (mess) Log.log(mess) conn.close() else: CommentUpdate().rr_update(messages()[0], self.web_url, video_message[1]) else: mess = TimeNow.get_time() + " 注意 : 数据库中没有该视频信息,其url : [ %s ]" % self.web_url print (mess) Log.log(mess) try: VideoMysql(self.web_url, messages()[1][0], messages()[0], video_message, video_url).rr_mysql() CommentUpdate().rr_update(messages()[0], self.web_url, video_message[1]) except Exception as e: print ("videocheck.videoupdate.rr_update.rr_mysql(68): " + str(e))
def sh_update(self): video_message = SouHu().sh_message(self.web_url) flags = check_url(self.web_url, video_message, messages()[1][4], messages()[0], " ") flag1 = flags[0] flag2 = flags[1] flag3 = flags[2] check = '' conn = messages()[0] if flag1 and flag2 and flag3: cur = conn.cursor() sql = "SELECT Video_View " \ "FROM souhu " \ "WHERE Video_Web=%s AND Video_Name=%s" try: cur.execute(sql, (self.web_url, video_message[1])) check = cur.fetchone() conn.commit() except Exception as e: print ('videocheck.souhu.sh_update.check(234): ' + str(e)) conn.rollback() cur.close() flags = update_message(check, conn, self.web_url, video_message) flag4 = flags[0] if flag4: flag = CommentUpdate().sh_update(messages()[0], self.web_url, video_message[1]) if flag: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 没有更新信息。" print (mess) Log.log(mess) conn.close() else: mess = TimeNow.get_time() + " 注意 : 数据库中没有该视频信息,其url : [ %s ]" % self.web_url print (mess) Log.log(mess) try: VideoMysql(self.web_url, messages()[1][4], messages()[0], video_message, '').sh_mysql() CommentUpdate().sh_update(messages()[0], self.web_url, video_message[1]) except Exception as e: print ("videocheck.videoupdate.sh_update.sh_mysql(256): " + str(e))
def video_download(self): # 视频下载 try: with closing(requests.get(self.video_url, stream=True)) as response: chunk_size = 1024 content_size = int(response.headers['content-length']) if '.mp4' in self.video_url: file_f = self.path + self.video_file + '/' + self.video_message + '.mp4' elif '.flv' in self.video_url: file_f = self.path + self.video_file + '/' + self.video_message + '.flv' else: file_f = self.path + self.video_file + '/' + self.video_message + '.mp4' if 'souhu' in file_f and os.path.exists(file_f): flag = 1 else: flag = 0 if (os.path.exists(file_f) and os.path.getsize(file_f) == content_size or flag): mess = TimeNow.get_time( ) + ' 注意 : [ ' + self.video_message + ' ] 文件或信息已存在,请注意查看!' print(mess) Log.log(mess) else: progress = ProgressBar(time.time(), TimeNow.get_time(), self.video_message.encode('utf8'), total=content_size, unit="KB", chunk_size=chunk_size, run_status="正在下载", fin_status="下载完成") with open(file_f, "wb") as f: for data in response.iter_content( chunk_size=chunk_size): f.write(data) progress.refresh(count=len(data)) return file_f except Exception as e: print('videodownload.download.video_download(53): ' + str(e))
def lost_mess(self): conn = self.connect cur = conn.cursor() sql = flag = " " if ('http://rr.tv/' in self.web_url or 'http://www.rr.tv/' in self.web_url) and self.file_name == "renren": flag = self.file_name sql = "SELECT Video_File,Video_Size,Video_Name " \ "FROM renren " \ "WHERE Video_Web = %s " if 'http://v.163.com/' in self.web_url and self.file_name == "wangyi": flag = self.file_name sql = "SELECT Video_File,Video_Size,Video_Name " \ "FROM wangyi " \ "WHERE Video_Web = %s " if 'http://v.ifeng.com/' in self.web_url and self.file_name == "fenghuang": flag = self.file_name sql = "SELECT Video_File,Video_Size,Video_Name " \ "FROM fenghuang " \ "WHERE Video_Web = %s " if 'https://www.mgtv.com' in self.web_url and self.file_name == "mangotv": flag = self.file_name sql = "SELECT Video_File,Video_Size,Video_Name " \ "FROM mangotv " \ "WHERE Video_Web = %s " if ('http://my.tv.sohu.com/' in self.web_url or 'https://my.tv.sohu.com/' in self.web_url or 'https://tv.sohu.com/' in self.web_url or 'http://tv.sohu.com/' in self.web_url) \ and self.file_name == "souhu": flag = self.file_name sql = "SELECT Video_File,Video_Size,Video_Name " \ "FROM souhu " \ "WHERE Video_Web = %s " try: cur.execute(sql, self.web_url) content = cur.fetchone() conn.commit() cur.close() if content: if not (os.path.exists(content[0])): mess = TimeNow.get_time() + ' 注意 : [ ' + str( content[2]) + ' ] 信息丢失!' print(mess) Log.log(mess) self.switch(flag) # else: # self.download(flag) except Exception as e: print('videocheck.lostmess.lost_mess(93): ' + str(e)) conn.rollback() cur.close()
def retry_get(req_url, headers, count=5, timeout=30): # 网络差时多次get请求 try: request = requests.get(req_url, headers=headers, timeout=timeout) request.raise_for_status() data = request.content except requests.HTTPError and requests.Timeout as e: mess = TimeNow.get_time() + ' ' + 'data.retry_get: ' + str(e) Log.log(mess) print(mess) data = None if count > 0: count -= 1 time.sleep(10) retry_get(req_url, headers, count - 1) return data
def download(self, flag): mess = TimeNow.get_time( ) + " 注意 : 数据库中没有该视频信息,其url : [ %s ]" % self.web_url print(mess) Log.log(mess) if flag == "renren" == self.file_name: VideoMysql(self.web_url, self.file_name, self.connect, self.video_message, self.video_url).rr_mysql() if flag == "wangyi" == self.file_name: VideoMysql(self.web_url, self.file_name, self.connect, self.video_message, self.video_url).wy_mysql() if flag == "fenghuang" == self.file_name: VideoMysql(self.web_url, self.file_name, self.connect, self.video_message, self.video_url).fh_mysql() if flag == "mangotv" == self.file_name: VideoMysql(self.web_url, self.file_name, self.connect, self.video_message, self.video_url).mg_mysql() if flag == "souhu" == self.file_name: VideoMysql(self.web_url, self.file_name, self.connect, self.video_message, self.video_url).sh_mysql()
def update_message(check, connect, web_url, video_message): sql1 = sql2 = sql3 = sql4 = sql5 = sql6 = '' point = 0 if 'http://rr.tv/' in web_url or 'http://www.rr.tv/' in web_url: point = 1 sql1 = "UPDATE renren " \ "SET Video_View=%s " \ "WHERE Video_Web=%s" sql2 = "UPDATE renren " \ "SET Video_Support=%s " \ "WHERE Video_Web=%s" sql4 = "UPDATE renren " \ "SET Video_Comment=%s " \ "WHERE Video_Web=%s" if 'http://v.163.com/' in web_url: point = 2 sql1 = "UPDATE wangyi " \ "SET Video_View=%s " \ "WHERE Video_Web=%s" sql2 = "UPDATE wangyi " \ "SET Video_Support=%s " \ "WHERE Video_Web=%s" sql3 = "UPDATE wangyi " \ "SET Video_Oppose=%s " \ "WHERE Video_Web=%s" sql4 = "UPDATE wangyi " \ "SET Video_Comment=%s " \ "WHERE Video_Web=%s" sql5 = "UPDATE wangyi " \ "SET Video_Comment_Fav=%s " \ "WHERE Video_Web=%s" sql6 = "UPDATE wangyi " \ "SET video_comment_against=%s " \ "WHERE Video_Web=%s" if 'http://v.ifeng.com/' in web_url: point = 3 sql1 = "UPDATE fenghuang " \ "SET Video_View=%s " \ "WHERE Video_Web=%s" sql2 = "UPDATE fenghuang " \ "SET Video_Support=%s " \ "WHERE Video_Web=%s" sql3 = "UPDATE fenghuang " \ "SET Video_Oppose=%s " \ "WHERE Video_Web=%s" sql4 = "UPDATE fenghuang " \ "SET Video_Comment=%s " \ "WHERE Video_Web=%s" if 'https://www.mgtv.com' in web_url: point = 4 sql1 = "UPDATE mangotv " \ "SET Video_View=%s " \ "WHERE Video_Web=%s" sql2 = "UPDATE mangotv " \ "SET Video_Support=%s " \ "WHERE Video_Web=%s" sql3 = "UPDATE mangotv " \ "SET Video_Oppose=%s " \ "WHERE Video_Web=%s" if 'http://my.tv.sohu.com/' in web_url or 'https://my.tv.sohu.com/' in web_url \ or 'https://tv.sohu.com/' in web_url or 'http://tv.sohu.com/' in web_url: point = 5 sql1 = "UPDATE souhu " \ "SET Video_View=%s " \ "WHERE Video_Web=%s" conn = connect # 视频观看数 cur = conn.cursor() if (point == 1 or point == 2 or point == 3 or point == 4 or point == 5) \ and ((point != 1 and check[0].encode('utf8') != str(video_message[6])) or (point == 1 and check[0].encode('utf8') != str(video_message[5]))): try: if point == 1: cur.execute(sql1, (video_message[5], web_url)) else: cur.execute(sql1, (video_message[6], web_url)) conn.commit() except Exception as e: print('videocheck.messupdate.update_message.video_view(92): ' + str(e)) conn.rollback() if point == 1: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_View : " \ + check[0].encode('utf8') + ", 现在Video_View : " + str(video_message[5]) else: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_View : " \ + check[0].encode('utf8') + ", 现在Video_View : " + str(video_message[6]) print(mess) Log.log(mess) flag4 = 0 else: flag4 = 1 cur.close() # 视频不点赞数 cur = conn.cursor() if (point == 2 or point == 3 or point == 4) and check[1].encode('utf8') != str(video_message[7]): try: cur.execute(sql3, (video_message[7], web_url)) conn.commit() except Exception as e: print('videocheck.messupdate.update_message.video_oppose(114): ' + str(e)) conn.rollback() mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_Oppose : " \ + check[1].encode('utf8') + ", 现在Video_Oppose : " + video_message[7] print(mess) Log.log(mess) flag5 = 0 else: flag5 = 1 cur.close() # 视频点赞数 cur = conn.cursor() if (point == 1 or point == 2 or point == 3 or point == 4) \ and (point != 1 and check[2].encode('utf8') != str(video_message[8]) or (point == 1 and check[1].encode('utf8') != str(video_message[6]))): try: if point == 1: cur.execute(sql2, (video_message[6], web_url)) else: cur.execute(sql2, (video_message[8], web_url)) conn.commit() except Exception as e: print('videocheck.messupdate.update_message.video_support(137): ' + str(e)) conn.rollback() if point == 1: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_Support : " \ + check[1].encode('utf8') + ", 现在Video_Support : " + str(video_message[6]) else: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_Support : " \ + check[2].encode('utf8') + ", 现在Video_Support : " + str(video_message[8]) print(mess) Log.log(mess) flag6 = 0 else: flag6 = 1 cur.close() # 视频评论数 cur = conn.cursor() if (point == 1 or point == 2 or point == 3) \ and (point != 1 and check[3].encode('utf8') != str(video_message[9]) or (point == 1 and check[2].encode('utf8') != str(video_message[7]))): try: if point == 1: cur.execute(sql4, (video_message[7], web_url)) else: cur.execute(sql4, (video_message[9], web_url)) conn.commit() except Exception as e: print('videocheck.messupdate.update_message.video_comment(164): ' + str(e)) conn.rollback() if point == 1: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_Comment : " \ + check[2].encode('utf8') + ", 现在Video_Comment : " + str(video_message[7]) else: mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_Comment : " \ + check[3].encode('utf8') + ", 现在Video_Comment : " + str(video_message[9]) print(mess) Log.log(mess) flag7 = 0 else: flag7 = 1 cur.close() # 视频评论点赞数 cur = conn.cursor() if point == 2 and check[4].encode('utf8') != str(video_message[10]): try: cur.execute(sql5, (video_message[10], web_url)) conn.commit() except Exception as e: print( 'videocheck.messupdate.update_message.video_comment_fav(186): ' + str(e)) conn.rollback() mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的Video_Comment_Fav : " \ + check[4].encode('utf8') + ", 现在Video_Comment_Fav : " + video_message[10] print(mess) Log.log(mess) flag8 = 0 else: flag8 = 1 cur.close() # 视频评论不点赞数 cur = conn.cursor() if point == 2 and check[5].encode('utf8') != str(video_message[11]): try: cur.execute(sql6, (video_message[11], web_url)) conn.commit() except Exception as e: print( 'videocheck.messupdate.update_message.video_comment_against(204): ' + str(e)) conn.rollback() mess = TimeNow.get_time() + " 视频 : [ " + video_message[1] + " ] 的video_comment_against : " \ + check[5].encode('utf8') + ", 现在video_comment_against : " + video_message[11] print(mess) Log.log(mess) flag9 = 0 else: flag9 = 1 cur.close() return flag4, flag5, flag6, flag7, flag8, flag9
def mg_update(conn, web_url, video_name): # 芒果TV result = '' message = MangoTV().mg_comment(web_url) vid = message[1] content = message[0] cur = conn.cursor() sql1 = "SELECT vid FROM mg" try: cur.execute(sql1) result = cur.fetchall() conn.commit() except Exception as e: print('videocheck.commentupdate.update.mg(96): ' + str(e)) conn.rollback() cur.close() if (vid.encode('utf8'), ) in result: cur = conn.cursor() sql1 = "SELECT content FROM mg WHERE vid = %s" try: cur.execute(sql1, vid) result = cur.fetchone() conn.commit() except Exception as e: print('videocheck.commentupdate.update.mg(109): ' + str(e)) conn.rollback() cur.close() if content in result[0].encode('utf8'): return 1 else: if len(content) == 0: content = " " cur = conn.cursor() sql = "UPDATE mg SET content = %s WHERE vid = %s" try: cur.execute(sql, (content, vid)) conn.commit() except Exception as e: print('videocheck.commentupdate.update.mg(124): ' + str(e)) conn.rollback() cur.close() mess = TimeNow.get_time( ) + " 视频 : [ " + video_name + " ] 评论更新完毕。" print(mess) Log.log(mess) return 0 else: if len(content) == 0: content = " " cur = conn.cursor() sql = "INSERT INTO mg(vid,content) VALUES (%s,%s)" try: cur.execute(sql, (vid, content)) conn.commit() except Exception as e: print('videocheck.commentupdate.update.mg(140): ' + str(e)) conn.rollback() cur.close() mess = TimeNow.get_time( ) + " 视频 : [ " + video_name + " ] 评论已插入数据库。" print(mess) Log.log(mess)
def fh_update(conn, web_url, video_name): # 凤凰视频 result = '' message = FengHuang().fh_comment(web_url) vid = message[1] content = message[0] cur = conn.cursor() sql1 = "SELECT vid FROM fh" try: cur.execute(sql1) result = cur.fetchall() conn.commit() except Exception as e: print('videocheck.commentupdate.update.fh(225): ' + str(e)) conn.rollback() cur.close() if (vid.encode('utf8'), ) in result: cur = conn.cursor() sql1 = "SELECT content FROM fh WHERE vid = %s" try: cur.execute(sql1, vid) result = cur.fetchone() conn.commit() except Exception as e: print('videocheck.commentupdate.update.fh(237): ' + str(e)) conn.rollback() cur.close() if content in result[0].encode('utf8'): return 1 else: if len(content) == 0: content = " " cur = conn.cursor() sql = "UPDATE fh SET content = %s WHERE vid = %s" try: cur.execute(sql, (content, vid)) conn.commit() except Exception as e: print('videocheck.commentupdate.update.fh(252): ' + str(e)) conn.rollback() cur.close() mess = TimeNow.get_time( ) + " 视频 : [ " + video_name + " ] 评论更新完毕。" print(mess) Log.log(mess) return 0 else: if len(content) == 0: content = " " cur = conn.cursor() sql = "INSERT INTO fh(vid,content) VALUES (%s,%s)" try: cur.execute(sql, (vid, content)) conn.commit() except Exception as e: print('videocheck.commentupdate.update.fh(268): ' + str(e)) conn.rollback() cur.close() mess = TimeNow.get_time( ) + " 视频 : [ " + video_name + " ] 评论已插入数据库。" print(mess) Log.log(mess)
def mg_message(self, web_url): try: # 获取视频vid、cid try: pattern = re.compile(r'/(\d+).html') vid = pattern.findall(web_url)[0] pattern = re.compile(r'/(\d+)/') cid = pattern.findall(web_url)[0] except: data = retry_get(web_url, self.headers) pattern = re.compile(r'vid: (\d+),') vid = pattern.findall(data)[0] pattern = re.compile(r'cid: (\d+),') cid = pattern.findall(data)[0] video_id = vid # 构造请求url req_url = 'https://pcweb.api.mgtv.com/player/video?' + 'video_id=' + vid + '&cid=' + cid # 获取数据 data = retry_get(req_url, self.headers) # 将数据python化 data_json = json.loads(data) # 获取视频名称 try: video_author = data_json['data']['info']['title'].encode( 'utf8') video_name = video_author + '-' + data_json['data']['info'][ 'desc'].encode('utf8') except: try: pattern = re.compile(r'"title":"(.*?)",') video_author = pattern.findall(data)[0] pattern = re.compile(r'"desc":"(.*?)",') video_name = video_author + '-' + pattern.findall(data)[0] except: pattern = re.compile(r'"desc":"(.*?)",') video_name = pattern.findall(data)[0] video_author = '' # 获取视频时长 try: video_modify = data_json['data']['info']['series'].encode( 'utf8') except: pattern = re.compile(r'"series":"(.*?)",') video_modify = pattern.findall(data)[0] # 获取视频长传时间 try: video_time = data_json['data']['info']['duration'].encode( 'utf8') except: pattern = re.compile(r'"duration":"(.*?)",') video_time = pattern.findall(data)[0] # 获取stream_domain try: stream_domain = data_json['data']['stream_domain'].encode( 'utf8') except: pattern = re.compile(r'http://web-disp\d*.titan.mgtv.com') stream_domain = pattern.findall(data) # 获取stream_url try: stream_url = [] stream = data_json['data']['stream'] for each_stream in stream: stream_url.append(each_stream['url'].encode('utf8')) except: # 获取stream pattern = re.compile(r'"stream":\[(.*?)\]', re.S) stream = pattern.findall(data)[0] # 获取stream_url pattern = re.compile(r'"url":"(.*?)"') stream_url = pattern.findall(stream) # 构造url为获取原视频地址部分参数 if len(stream_domain) == len(stream_url): req_url_para_list = stream_domain[len(stream_domain) - 1] \ + stream_url[len(stream_url) - 1] else: req_url_para_list = stream_domain[0] + stream_url[0] # 获取原视频url地址相关参数1 data = retry_get(req_url_para_list, self.headers) data_json = json.loads(data) try: info = data_json['info'].encode('utf8') except: pattern = re.compile(r'"info":"(.*?)"') info = pattern.findall(data)[0] # 获取原视频地址参数1 pattern = re.compile(r'(^http:.*?mp4)') para_list_1 = pattern.findall(info)[0] # 获取原视频url地址相关参数1集合(不能开myeclipse) try: data = retry_get(info, self.headers, timeout=30) except Exception as e: count = 5 while str( e ) == "('Connection aborted.', error(10054, ''))" and count > 0: time.sleep(10) try: count -= 1 data = retry_get(info, self.headers, timeout=30) except Exception as e: mess = TimeNow.get_time( ) + ' ' + 'mangotv.mg_message: ' + str(e) Log.log(mess) print(mess) print( 'videoparse.mangotv.mg_message.Connection aborted(122): ' + str(e)) # 获取原视频大小集合 pattern = re.compile(r'#EXT-MGTV-File-SIZE:(\d+)') video_size = pattern.findall(data) # 获取原视频地址参数2 pattern = re.compile(r',([^0-9|A-Z].*?mp4\.ts\?.*?)#', re.S) para_list_2 = pattern.findall(data) # 获取视频原地址集合 video_url = [] for para_list in para_list_2: original_url = para_list_1 + '/' + para_list.replace("\n", "") video_url.append(original_url) # 构造请求url req_url = 'https://vc.mgtv.com/v2/dynamicinfo?vid=' + vid # 获取数据 data = retry_get(req_url, self.headers) json_data = json.loads(data) # 获取视频播放量 video_view = str(json_data['data']['all']) # 获取视频点赞数 video_support = str(json_data['data']['like']) # 获取视频不点赞数 video_oppose = str(json_data['data']['unlike']) return video_id, video_name, video_author, video_size, video_time, video_modify, video_view, video_oppose,\ video_support, video_url except Exception as e: print('videoparse.mangotv.mg_message(148): ' + str(e))
def lost_update(web_url, video_message, file_name, connect, video_url=''): conn = connect cur = conn.cursor() if 'http://v.ifeng.com' in web_url: download_video = DownloadVideo(video_message[10], unicode(video_message[1], "utf-8"), file_name) video_file = download_video.video_download() sql = "UPDATE fenghuang " \ "SET Video_Id=%s, Video_Name=%s, Video_Author=%s, Video_Size=%s, Video_Time=%s, Video_Modify=%s" \ ", Video_View=%s, Video_Oppose=%s, Video_Support=%s, Video_Comment=%s, Video_Url=%s, Video_File=%s " \ "WHERE Video_Web=%s" try: cur.execute( sql, (video_message[0], video_message[1], video_message[2], video_message[3], video_message[4], video_message[5], video_message[6], video_message[7], video_message[8], video_message[9], video_message[10], video_file, web_url)) conn.commit() except Exception as e: print('videocheck.lostupdate.lost_update.fenghuang(26): ' + str(e)) conn.rollback() if 'http://v.163.com' in web_url: download_video = DownloadVideo(video_url, unicode(video_message[1], "utf-8"), file_name) video_file = download_video.video_download() sql = "UPDATE wangyi " \ "SET Video_Id=%s, Video_Name=%s, Video_Author=%s, Video_Size=%s, Video_Time=%s, Video_modify=%s" \ ", Video_View=%s, Video_Oppose=%s, Video_Support=%s, Video_Comment=%s, Video_Comment_Fav=%s" \ ", Video_Comment_Against=%s, Video_Url=%s, Video_File=%s " \ "WHERE Video_Web=%s" try: cur.execute(sql, (video_message[0], video_message[1], video_message[2], video_message[3], video_message[4], video_message[5], video_message[6], video_message[7], video_message[8], video_message[9], video_message[10], video_message[11], video_url, video_file, web_url)) conn.commit() except Exception as e: print('videocheck.lostupdate.lost_update.wangyi(43): ' + str(e)) conn.rollback() if 'http://rr.tv' in web_url or 'http://www.rr.tv' in web_url: video_file = DownloadVideo(video_url, unicode(video_message[1], "utf-8"), file_name).video_download() sql = "UPDATE renren " \ "SET Video_Id=%s,Video_Name=%s,Video_Author=%s,Video_Size=%s,Video_Time=%s," \ "Video_View=%s,Video_Support=%s,Video_Comment=%s,Video_Url=%s,Video_File=%s " \ "WHERE Video_Web=%s" try: cur.execute(sql, (video_message[0], video_message[1], video_message[2], video_message[3], video_message[4], video_message[5], video_message[6], video_message[7], video_url, video_file, web_url)) conn.commit() except Exception as e: print('videocheck.lostupdate.lost_update.renren(58): ' + str(e)) conn.rollback() if 'https://www.mgtv.com/' in web_url: count = 0 video_file = '' while count < len(video_message[9]): video_name = video_message[1] + '(' + str(count) + ')' download_video = DownloadVideo(video_message[9][count], unicode(video_name, "utf-8"), file_name) video_file = download_video.video_download() count += 1 sql = "UPDATE mangotv " \ "SET Video_Id=%s, Video_Name=%s, Video_Author=%s, Video_Size=%s, Video_Time=%s, Video_Modify=%s" \ ", Video_View=%s, Video_Oppose=%s, Video_Support=%s, Video_Url=%s, Video_File=%s " \ "WHERE Video_Web=%s" try: cur.execute(sql, (video_message[0], video_message[1], video_message[2], video_message[3][count - 1], video_message[4], video_message[5], video_message[6], video_message[7], video_message[8], video_message[9][count - 1], video_file, web_url)) conn.commit() except Exception as e: print('videocheck.lostupdate.lost_update.mangotv(80): ' + str(e)) conn.rollback() if 'http://my.tv.sohu.com/' in web_url or 'https://my.tv.sohu.com/' in web_url \ or 'https://tv.sohu.com/' in web_url or 'http://tv.sohu.com/' in web_url: count = 0 video_file = '' while count < len(video_message[7]): video_name = video_message[1] + '(' + str(count) + ')' video_file = DownloadVideo(video_message[7][count], unicode(video_name, "utf-8"), file_name) \ .video_download() count += 1 sql = "UPDATE souhu " \ "SET Video_Id=%s, Video_Name=%s, Video_Author=%s, Video_Size=%s, Video_Time=%s, Video_Modify=%s" \ ", Video_View=%s, Video_Url=%s, Video_File=%s " \ "WHERE Video_Web=%s" try: cur.execute(sql, (video_message[0], video_message[1], video_message[2], video_message[3], video_message[4], video_message[5], video_message[6], video_message[7][count - 1], video_file, web_url)) conn.commit() except Exception as e: print('videocheck.lostupdate.lost_update.souhu(102): ' + str(e)) conn.rollback() cur.close() mess = TimeNow.get_time( ) + ' 注意 : [ ' + video_message[1] + ' ] 信息已补全,请注意查看!' print(mess) Log.log(mess)