martijnlentink / propresenter-custom-bibles

Tutorial to import custom Bibles in ProPresenter
34 stars 13 forks source link

proposal: Download bible chapters async #11

Closed tatang26 closed 7 months ago

tatang26 commented 7 months ago

Hey @martijnlentink, thank you so much for this script, I could test it in both windows and mac machines and is working great.

I want to propose downloading Bible chapters asynchronously to significantly reduce the time it takes for the script to import them into PP.

We can leverage of the metadata object, which already has chapters, and loop through them as:


for book in metadata["books"]:
        for chapter in book["chapters"]:
           // async chapter download

An use this url path to retrieve the chapter

https://www.bible.com/_next/data/{api_id}/en/bible/{bible_id}/{chapter.usfm}/{bible_id}.json?parallel={bible_id}

for instance:

https://www.bible.com/_next/data/{api_id}/en/bible/3699/GEN.1/3699.json?parallel=3699
martijnlentink commented 7 months ago

Hi there,

Thanks for your suggestion. Although I agree that it might be beneficial for the user of the script to run the retrieval in a parallel fashion I don't want to burden the API with an abundance of requests. It did build it this way intentionally.

Now I have worked on moving to downloading the zip files with encoded files containing the complete bible. I actually got it working alright and with that started working in moving the script to a class based solution, that is where I'm at right now.

I could extract the former - the downloading of the Yves files - from my branch and commit that for you to use and keep working on moving everything to classes. I'll let you know.

tatang26 commented 7 months ago

That's great! I agree with you about using classes to perform actions and having subjects for specific process steps. It's a great way to keep the project code organized. Thank you!

martijnlentink commented 7 months ago

Hi,

I just created a PR for this change, you can find it here #12. If you have time please take a look at it 😄