コード例 #1
0
ファイル: test.py プロジェクト: zzhj/pixivDownloader
def api_search(keyword, api, page=1, download_threshold=DOWNLOAD_THRESHOLD):
    illusts = []
    if CommonUtils.is_empty(keyword):
        raise PixivError('[ERROR] keyword is empty')
    ids = set()
    count = 0
    for data in api.search_popular_illust('百合').illusts:
        if download_threshold:
            if data.total_bookmarks >= download_threshold:
                if data.id not in ids:
                    ids.add(data.id)
                    illusts.append(data)
        elif data.id not in ids:
            ids.add(data.id)
            illusts.append(data)
    if page:
        while page > 0:
            for data in api.search_illust('百合', offset=count).illusts:
                count = count + 1
                if download_threshold:
                    if data.total_bookmarks >= download_threshold:
                        if data.id not in ids:
                            ids.add(data.id)
                            illusts.append(data)
                elif data.id not in ids:
                    ids.add(data.id)
                    illusts.append(data)
            page = page - 1
    return illusts
コード例 #2
0
ファイル: SearchFrame.py プロジェクト: zzhj/pixivDownloader
 def handle_search(self):
     keywords = self.keywords.get().strip()
     if CommonUtils.is_empty(keywords):
         showwarning("warning", "Please enter search keywords!")
         print("warning", "Please enter search keywords!")
         return
     if CommonUtils.is_empty(self.path_var.get()):
         showwarning("warning", "path can't be empty!")
         print("warning", "path can't be empty!")
         return
     path = self.path_var.get().strip()
     if not os.path.exists(path):
         showerror("error", " No such file or directory!")
         print('error', 'No such file or directory')
         return
     path = path + "/" + CommonUtils.filter_dir_name("search_" + keywords)
     showinfo("info", "Is searching:")
     search_handler = Thread(target=self.search, args=(keywords, path))
     search_handler.start()
コード例 #3
0
ファイル: AuthPixivApi.py プロジェクト: zzhj/pixivDownloader
 def __init__(self,
              username,
              password,
              access_token=None,
              refresh_token=None,
              use_proxy=pixiv_config.USE_PROXY):
     self.username = username
     self.password = password
     self.user_id = None
     self.refresh_token = refresh_token
     self.access_token = access_token
     self.use_proxy = use_proxy
     if use_proxy and len(pixiv_config.PROXIES) == 0:
         raise PixivError('Proxy config Error')
     if CommonUtils.is_empty(access_token):
         self.login(username, password, refresh_token)
コード例 #4
0
 def handle_related(self):
     id_var = CommonUtils.set_int(self.id_var.get().strip())
     if id_var <= 0:
         showwarning("warning", "Please enter search keywords!")
         print("warning", "Please enter search keywords!")
         return
     if CommonUtils.is_empty(self.path_var.get()):
         showwarning("warning", "path can't be empty!")
         print("warning", "path can't be empty!")
         return
     path = self.path_var.get().strip()
     if not os.path.exists(path):
         showerror("error", " No such file or directory!")
         print('error', 'No such file or directory')
         return
     path = path + "/" + CommonUtils.filter_dir_name("related_" +
                                                     str(id_var))
     showinfo("info", "Get related illus of " + str(id_var) + " :")
     related_handler = Thread(target=self.related, args=(id_var, path))
     related_handler.start()
コード例 #5
0
ファイル: RankingFrame.py プロジェクト: zzhj/pixivDownloader
 def handle_ranking(self):
     mode = self.mode_var.get()
     path = self.path_var.get().strip()
     page = CommonUtils.set_int(self.page_number.get(), 2)
     date = self.date_var.get().strip()
     if CommonUtils.is_empty(path):
         showwarning("warning", "path can't be empty!")
         print ("warning", "path can't be empty!")
         return
     if not os.path.exists(path):
         showerror("error", " No such file or directory!")
         print ('error', 'No such file or directory')
         return
     if not CommonUtils.validate_date_str(date):
         showerror("error", "Date Wrong!")
         print ('error', 'Date Wrong')
         return
     if datetime.datetime.strptime(date, '%Y-%m-%d') > datetime.datetime.now():
         showerror("error", "The date can not be greater than the day!")
         print ('error', 'The date can not be greater than the day')
         return
     showinfo("info", "Get ranking...")
     ranking_handler = Thread(target=self.ranking, args=(path, mode, date, page))
     ranking_handler.start()