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: add new parameter to download playlist or specific book #4

Open makhalaf opened 1 year ago

makhalaf commented 1 year ago

add new parameter to download playlist or specific book

sweep-ai[bot] commented 1 year ago

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

⚡ Sweep Free Trial: I used GPT-4 to create this ticket. You have 3 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-L1124 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L770-L910 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L191-L448 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/README.md#L1-L176 https://github.com/makhalaf/safaribooks/blob/48ae9944c89bf1911f392b2721270bc54098821f/safaribooks.py#L166-L250

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 argument in the argparse section for the playlist or specific book. Modify the main function to handle the new argument. If the argument is a playlist, iterate over the books in the playlist and download each one. If the argument is a specific book, download that book. Modify the download function to handle the new types of input (playlist or specific book).

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:

Add new parameter to download playlist or specific book sweep/playlist-download

Description

This PR adds a new feature to the safaribooks codebase that allows downloading a playlist or a specific book. The existing codebase only supports downloading a book based on its ID. With this new feature, users can now specify a playlist or a specific book to download.

Summary of Changes

  • Added a new command-line argument --playlist to accept a playlist URL or a specific book ID.
  • Modified the main function to handle the new argument. If the argument is a playlist, the code iterates over the books in the playlist and downloads each one. If the argument is a specific book, the code downloads that book.
  • Modified the download function to handle the new types of input (playlist or specific book).

This PR enhances the functionality of the safaribooks codebase by allowing users to download playlists or specific books, providing more flexibility and convenience.


Step 4: ⌨️ Coding

File Instructions Progress
safaribooks.py Add a new argument in the argparse section for the playlist or specific book. Modify the main function to handle the new argument. If the argument is a playlist, iterate over the books in the playlist and download each one. If the argument is a specific book, download that book. Modify the download function to handle the new types of input (playlist or specific book). ✅ Done with commit 159eedc 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/playlist-download.

Here is the 1st review

Thanks for your contribution. There are a few changes that need to be made:

  • In safaribooks.py, you've called a function get_books_from_playlist on line 1125, but it's not defined or imported anywhere in the changes. Please make sure to implement or import this function.

  • Also, please ensure that the bookid and playlist arguments are properly validated. They should be valid IDs, and the code should handle the case when they are not provided.

Keep up the good work!

I finished incorporating these changes.


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