makhalaf / safaribooks

Download and generate EPUB of your favorite books from O'Reilly Learning (aka Safari Books Online) library.
Do What The F*ck You Want To Public License
0 stars 0 forks source link

Sweep: Retrieve and save all the books from the user’s playlists. #1

Open makhalaf opened 1 year ago

makhalaf commented 1 year ago

Read the user’s playlists and download all of the books in them

sweep-ai[bot] commented 1 year ago

Here's the PR! https://github.com/makhalaf/safaribooks/pull/3.

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 5 GPT-4 tickets left. For more GPT-4 tickets, visit our payment portal.To get Sweep to recreate this ticket, leave a comment prefixed with "sweep:" or edit the issue.


Step 1: 🔍 Code Search

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L766-L1001 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L931-L1124 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L166-L448 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L456-L650 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/README.md#L1-L176

Step 2: 🧐 Snippet Analysis

From looking through the relevant snippets, I decided to make the following modifications:

File Path Proposed Changes
safaribooks.py Add a new function to retrieve the user's playlists. This function should make a request to the appropriate API endpoint and parse the response to get a list of the user's playlists. Then, for each playlist, retrieve the list of books in that playlist by making a request to the appropriate API endpoint for each playlist and parsing the response to get a list of book IDs. Finally, for each book ID, download the book by calling the existing function to download a book with the book ID as an argument.

Step 3: 📝 Planning

I have created a plan for writing the pull request. I am now working my plan and coding the required changes to address this issue. Here is the planned pull request:

Implement feature to retrieve and save all books from user's playlists sweep/retrieve-save-books-from-playlists

Description

This PR implements a new feature to retrieve and save all the books from the user's playlists in the Safari Books Online library. It adds the functionality to read the user's playlists, retrieve the list of books in each playlist, and download each book.

Summary of Changes

  • Added a new function to retrieve the user's playlists by making a request to the appropriate API endpoint and parsing the response.
  • For each playlist, retrieved the list of books by making a request to the appropriate API endpoint and parsing the response.
  • Downloaded each book by calling the existing function to download a book with the book ID as an argument.

These changes enable users to easily retrieve and save all the books from their playlists, providing a convenient way to access their favorite books offline.


Step 4: ⌨️ Coding

File Instructions Progress
safaribooks.py Add a new function to retrieve the user's playlists. This function should make a request to the appropriate API endpoint and parse the response to get a list of the user's playlists. Then, for each playlist, retrieve the list of books in that playlist by making a request to the appropriate API endpoint for each playlist and parsing the response to get a list of book IDs. Finally, for each book ID, download the book by calling the existing function to download a book with the book ID as an argument. ✅ Done with commit a3c25f4 I have finished coding the issue. I am now reviewing it for completeness.

Step 5: 🔁 Code Review

Here are the my self-reviews of my changes at sweep/retrieve-save-books-from-playlists.

I finished incorporating these changes.


To recreate the pull request, leave a comment prefixed with "sweep:" or edit the issue. Join Our Discord