fix api request delay to not get rate limited with the --wait cli argument
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
20ce0b6571
commit
78a4e1827f
4 changed files with 6 additions and 4 deletions
|
@ -89,6 +89,7 @@ if __name__ == "__main__":
|
|||
dest="wait",
|
||||
required=False,
|
||||
type=float,
|
||||
default=0.5,
|
||||
help="Time to wait for each picture to download in seconds(float). Defaults 0.5",
|
||||
)
|
||||
parser.add_argument(
|
||||
|
|
|
@ -171,7 +171,7 @@ class Mangadex:
|
|||
return chapter_data
|
||||
|
||||
# get images for the chapter (mangadex@home)
|
||||
def get_chapter_images(self, chapter):
|
||||
def get_chapter_images(self, chapter, wait_time):
|
||||
if self.verbose:
|
||||
print(f"INFO: Getting chapter images for: {self.manga_uuid}")
|
||||
athome_url = f"{self.api_base_url}/at-home/server"
|
||||
|
@ -192,6 +192,7 @@ class Mangadex:
|
|||
for image in chapter_img_data:
|
||||
image_urls.append(f"{self.img_base_url}/data/{chapter_hash}/{image}")
|
||||
|
||||
sleep(wait_time)
|
||||
return image_urls
|
||||
|
||||
# create list of chapters
|
||||
|
|
|
@ -4,7 +4,7 @@ from time import sleep
|
|||
import requests
|
||||
|
||||
# download images
|
||||
def download_chapter(image_urls, chapter_path, md_wait=0.5, md_verbose=False):
|
||||
def download_chapter(image_urls, chapter_path, md_wait, md_verbose):
|
||||
img_num = 1
|
||||
for img in image_urls:
|
||||
# set image path
|
||||
|
@ -27,7 +27,7 @@ def download_chapter(image_urls, chapter_path, md_wait=0.5, md_verbose=False):
|
|||
print(f"INFO: Downloaded image {img_num}")
|
||||
|
||||
img_num += 1
|
||||
sleep(0.5)
|
||||
sleep(md_wait)
|
||||
else:
|
||||
print(f"ERR: Image {img} could not be downloaded. Exiting")
|
||||
exit(1)
|
||||
|
|
|
@ -183,7 +183,7 @@ def get_manga(
|
|||
chapter_infos = Api.get_chapter_infos(chapter)
|
||||
|
||||
# get image urls for chapter
|
||||
chapter_image_urls = Api.get_chapter_images(chapter)
|
||||
chapter_image_urls = Api.get_chapter_images(chapter, download_wait)
|
||||
|
||||
# get filename for chapter
|
||||
chapter_filename = Api.get_filename(chapter)
|
||||
|
|
Loading…
Reference in a new issue