def work_one(self, key): kdict = self.log.getName() if key == "画师": self.recount() pidlist = self.log.getTag(key) for pid in pidlist: self.pFind(pid) for pid in pidlist: pname = self.getNameByPid(pid) if not pname: print("\t[%s] 用户已经不存在" % pid, flush=True) continue key = "画师[%s]" % (pid) fullkey = "画师[%s]%s" % (pid, pname) filename = pString.checkDirName(key) self.oGet(filename, wait=True, isP=True) # print("\t\t等待获取完成:") # self.wait_allcomplete("获取下载地址完成.\n") for pid in pidlist: pname = self.getNameByPid(pid) if not pname: print("\t[%s] 用户已经不存在" % pid, flush=True) continue key = "画师[%s]" % (pid) fullkey = "画师[%s]%s" % (pid, pname) filename = pString.checkDirName(key) self.oDown(filename) return if not key in kdict: print("条目名 %s 不在条目表中" % (key), flush=True) return self.recount() self.oFind(key) self.oGet(key, wait="True") self.oDown(key)
def oGet(self, key, wait=False, isP=False): if not self.flag_login: self.clogin() if "画师" in key: # print(key) pid = key[3:-1] pname = self.getNameByPid(pid) if not pname: print("\t[%s] 用户已经不存在" % pid, flush=True) return # print(pid,pname) # input() if isP: adir = defaultDir + "_画师/" + pString.checkDirName(key[2:] + pname) + "/" else: adir = defaultDir + pString.checkDirName(key) + "/" logfd = self.log.getLog(key) iidlist = logfd.get() locallist = [] print("\t[%s] 开始获取下载地址" % key, flush=True) for iid in iidlist: locallist.append(iid) for iid in locallist: self.add_job("get", iid[:-2], adir, logfd) if wait: print("\t\t等待获取完成:", flush=True) self.wait_allcomplete("\t[%s] 获取下载地址完成" % key)
def pFind(self, pid, wait=True): # print(pid) if not self.flag_login: self.clogin() pname = self.getNameByPid(pid) if not pname: print("\t[%s] 用户已经不存在" % pid, flush=True) return key = "画师[%s]" % (pid) fullkey = "画师[%s]%s" % (pid, pname) filename = pString.checkDirName(key) logfd = self.log.getLog(key) # print("画师 [%s]%s 作品遍历开始" % (pid, pname), flush=True) pageid = 1 eflag = True while eflag: domain = "http://www.pixiv.net/member_illust.php?id=%s&type=all&p=%d" % (pid, pageid) html = self.getHtml(domain) if not html: break if pString.isNullInPerson(html.text): break iidlist = pString.getIidByPerson(html.text) # print(domain,iidlist) if len(iidlist) == 0: break for iid in iidlist: if logfd.begin(iid + "_0"): eflag = False if eflag: print("\t画师 [%s]%s 作品前%d页遍历完成" % (pid, pname, pageid), flush=True) pageid += 1 print(" [%s]%s 作品遍历完成" % (pid, pname), flush=True)
def cDown(self): global proxies if not down_by_proxies: proxies = {} # if not self.flag_login: self.clogin() keylist = self.log.getName() print("开始下载全部作品:", flush=True) for key in keylist: if key != "画师": self.oDown(key) else: pidlist = self.log.getTag(key) for pid in pidlist: # pname = self.getNameByPid(pid) # if not pname: # print("\t[%s] 用户已经不存在"%pid); # continue key = "画师[%s]" % (pid) # fullkey = "画师[%s]%s"%(pid, pname) filename = pString.checkDirName(key) self.oDown(filename) print("全部作品下载完成.", flush=True)
def cGet(self): global proxies proxies = use_proxies if not self.flag_login: self.clogin() keylist = self.log.getName() print("获取全部作品下载地址:", flush=True) for key in keylist: if key != "画师": self.oGet(key) else: pidlist = self.log.getTag(key) for pid in pidlist: pname = self.getNameByPid(pid) if not pname: print("\t[%s] 用户已经不存在" % pid, flush=True) continue key = "画师[%s]" % (pid) fullkey = "画师[%s]%s" % (pid, pname) filename = pString.checkDirName(key) self.oGet(filename, isP=True) print("\t\t等待获取完成:", flush=True) self.wait_allcomplete("获取下载地址完成.\n")