Ejemplo n.º 1
0
 def deal_url_5_res(self, dict_json, av, url):
     db = MySql()
     for i in dict_json["data"]:
         title = i[title]
         sql = f'''Update bvlist set title="{title} where av = {av}"'''
         db.execute(sql)
         sql2 = f'''Update video_url valid_2=0 where av={av}'''
         db.execute(sql2)
Ejemplo n.º 2
0
 def execute_many(self, name):  #将url初始化进入数据库
     db = MySql()
     sql = []
     if name == "build_urls_1":
         sql = self.build_urls_1()
     elif name == "build_urls_2":
         sql = self.build_urls_2()
     elif name == "build_url4_and_url5":
         sql = self.build_url4_and_url5()
     else:
         assert "excute_many name is wrong"
     for i in sql:
         print(i)
         db.execute(i)
     print("ok")
Ejemplo n.º 3
0
 def deal_url_2_res(self, res, mid):
     info = {}
     print("res", res)
     for i, j in res["data"].items():
         if i in self.need:
             if j == "":
                 j = " "
             info[i] = j
     sql2 = f'''update upbasic set following={info["following"]},black={info["black"]},follower={info["follower"]} where mid = {mid}'''
     sql3 = f'''update baida_up set url_2_valid = 0 where mid = {mid}'''
     db = MySql()
     print(sql2)
     db.execute(sql2)
     db.execute(sql3)
     print("ok")
Ejemplo n.º 4
0
 def input_url3(self):
     loads = self.load_mid_without_limit()
     db = MySql()
     for i in loads:
         pn = 1
         mid = i[0]
         sql1 = f'''select sum from getbvlist where mid={mid}'''
         res = int(db.fetch_one(sql1)[0])
         while (res > 0):
             res = res - 100
             pn += 1
             url = self.format_url_3(mid, pn)
             sql = f'''Insert Into getbvlist values({mid},"{url}",1,{res})'''
             print(sql)
             db.execute(sql)
         print(mid)
Ejemplo n.º 5
0
 def deal_url_1_res(self, res, mid):
     info = {}
     for i, j in res["data"].items():
         if i in self.need:
             if j == "":
                 j = " "
             info[i] = j
     sql2 = f'''insert into upbasic values({info["mid"]},"{info["name"]}","{info["sex"]}","null",{info["level"]},"{info["birthday"]}",{info["coins"]},null,null,null)'''
     sql1 = f'''select mid from upbasic where mid = {mid}'''
     sql3 = f'''update baida_up set url_1_valid = 0 where mid = {mid}'''
     db = MySql()
     call = db.fetch_one(sql1)
     print(call)
     if call == None:
         print(sql2)
         db.execute(sql2)
         db.execute(sql3)
     print("ok")
Ejemplo n.º 6
0
 def deal_url_4_res(self, dict_json, av, url):
     print(av)
     if av == 0 or av == 1299:
         return
     db = MySql()
     i = dict_json["data"]
     view = i["view"]
     if isinstance(view, str):  #用来处理视频不见了的状况
         view = -1
     danmaku = i["danmaku"]
     reply = i["reply"]
     favorite = i["favorite"]
     coin = i["coin"]
     share = i["share"]
     his_rank = i["his_rank"]
     like = i["like"]
     sql = f'''Update bvlist set view={view},danmaku={danmaku},reply={reply},favorite={favorite},coin={coin},share={share},his_rank={his_rank},likes={like} where av={av}'''
     print(sql)
     db.execute(sql)
     sql2 = f'''Update video_url set valid_1=0 where av={av}'''
     db.execute(sql2)
Ejemplo n.º 7
0
 def deal_url_3_res(self, dict_json, mid, url):
     videolist = []
     moreinfo = {}
     for i in dict_json["data"]["list"]["vlist"]:
         videolist.append(str(i["aid"]))
         moreinfo[str(i["aid"])] = {}
         for keyj, valuej in i.items():
             if keyj in self.videoneed:
                 moreinfo[str(i["aid"])][keyj] = valuej
     db = MySql()
     for i in videolist:
         sql_check = f'''select mid from bvlist where av = "{i}" '''
         res = db.execute(sql_check)
         print("res", res)
         if res == 0:
             sql = f'''Insert into bvlist values({mid},null,"{i}",1,{moreinfo[i]["typeid"]},{moreinfo[i]["created"]},"{moreinfo[i]["length"]}",{moreinfo[i]["is_union_video"]})'''  #将信息插入bvlist
             print(sql)
             db.execute(sql)
     sql2 = f'''update getbvlist set valid=0 where url="{url}"'''
     db.execute(sql2)
     print("videolist", videolist)
     print("moreinfo", moreinfo)
Ejemplo n.º 8
0
 def delete_today(self):#将今天的数据全部删除
     sql = "Delete from ip_pool where 1=1"
     db = MySql()
     res = db.execute(sql)
     print("delete all ok")
Ejemplo n.º 9
0
 def update_valid(self,ip):#将valid变为0
     sql = f'''update  ip_pool set valid = 0   where ip="{ip}"'''
     db = MySql()
     res = db.execute(sql)
     print("delete ok")
Ejemplo n.º 10
0
 def ip_store(self,ip):
     db = MySql()
     sql = f'''insert into ip_pool values(null,'{ip}',NOW(),1)'''
     print(sql)
     db.execute(sql)