mirror of
https://github.com/Radiquum/furaffinity-dl.git
synced 2025-04-05 07:44:37 +00:00
feat: add disable of threading and configure the number of running threads
fix: NoneType error if no arguments are provided
This commit is contained in:
parent
d8a6fffa0b
commit
c0962094ca
2 changed files with 60 additions and 35 deletions
|
@ -163,6 +163,20 @@ parser.add_argument(
|
|||
action="store_true",
|
||||
help="check all files size when download, this will skip build-in archive",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--disable-threading",
|
||||
dest="disable_threading",
|
||||
action="store_true",
|
||||
help="disable multithreading download",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--num-threads",
|
||||
"-t",
|
||||
dest="num_threads",
|
||||
default=3,
|
||||
help="how many threads will be used for parallel download [default: 3]",
|
||||
type=int,
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -181,30 +195,32 @@ if username is not None:
|
|||
username = username[0]
|
||||
|
||||
# Custom input
|
||||
cookies = args.cookies
|
||||
output_folder = args.output_folder
|
||||
download = args.download
|
||||
interval = args.interval
|
||||
user_agent = args.user_agent
|
||||
start = args.start
|
||||
stop = args.stop
|
||||
folder = args.folder
|
||||
cookies: str = args.cookies
|
||||
output_folder: str = args.output_folder
|
||||
download: int = args.download
|
||||
interval: int = args.interval
|
||||
user_agent: str = args.user_agent
|
||||
start: int = args.start
|
||||
stop: int = args.stop
|
||||
folder: str = args.folder
|
||||
num_threads: int = args.num_threads
|
||||
|
||||
# True\False
|
||||
|
||||
login = args.login
|
||||
check = args.check
|
||||
index = args.index
|
||||
submissions = args.submissions
|
||||
html_description = args.html_description
|
||||
json_description = args.json_description
|
||||
metadata = args.metadata
|
||||
dont_redownload = args.redownload
|
||||
rating = args.rating
|
||||
submission_filter = args.submission_filter
|
||||
real_category = args.real_category
|
||||
request_compress = args.request_compress
|
||||
check_file_size = args.check_file_size
|
||||
login: bool = args.login
|
||||
check: bool = args.check
|
||||
index: bool = args.index
|
||||
submissions: bool = args.submissions
|
||||
html_description: bool = args.html_description
|
||||
json_description: bool = args.json_description
|
||||
metadata: bool = args.metadata
|
||||
dont_redownload: bool = args.redownload
|
||||
rating: bool = args.rating
|
||||
submission_filter: bool = args.submission_filter
|
||||
real_category: bool = args.real_category
|
||||
request_compress: bool = args.request_compress
|
||||
check_file_size: bool = args.check_file_size
|
||||
disable_threading: bool = args.disable_threading
|
||||
|
||||
if check_file_size:
|
||||
request_compress = False
|
||||
|
|
|
@ -82,16 +82,19 @@ it\'s already downloaded{config.END}'
|
|||
)
|
||||
continue
|
||||
|
||||
#download(img_url)
|
||||
q.put(img_url)
|
||||
if config.disable_threading:
|
||||
download(img_url)
|
||||
else:
|
||||
q.put(img_url)
|
||||
sleep(config.interval)
|
||||
q.join()
|
||||
page_num = next_button(page_url)
|
||||
stop_threads = True
|
||||
for _ in range(3):
|
||||
q.put("shutdown")
|
||||
for t in workers:
|
||||
t.join()
|
||||
if not config.disable_threading:
|
||||
stop_threads = True
|
||||
for _ in range(config.num_threads):
|
||||
q.put("shutdown")
|
||||
for t in workers:
|
||||
t.join()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -126,12 +129,13 @@ is inaccessible{config.END}"
|
|||
download(f"/view/{config.download}/")
|
||||
exit()
|
||||
|
||||
stop_threads = False
|
||||
for id in range(3):
|
||||
print(id, 'started thread')
|
||||
tmp = threading.Thread(target=worker, daemon=False)
|
||||
workers.append(tmp)
|
||||
tmp.start()
|
||||
if not config.disable_threading:
|
||||
stop_threads = False
|
||||
for id in range(config.num_threads):
|
||||
print(id, 'started thread')
|
||||
tmp = threading.Thread(target=worker, daemon=False)
|
||||
workers.append(tmp)
|
||||
tmp.start()
|
||||
|
||||
if config.submissions is True:
|
||||
download_url = f"{config.BASE_URL}/msg/submissions"
|
||||
|
@ -160,6 +164,11 @@ downloading "{config.folder[1]}"{config.END}'
|
|||
)
|
||||
exit()
|
||||
|
||||
if not config.username:
|
||||
print("Not enough arguments")
|
||||
config.parser.print_help()
|
||||
os._exit(1)
|
||||
|
||||
for username in config.username:
|
||||
username = username.split("#")[0].translate(
|
||||
str.maketrans(config.username_replace_chars)
|
||||
|
|
Loading…
Add table
Reference in a new issue