This commit introduces the `borg collect archive` command, allowing users to collect items from the Internet Archive. The command includes three subcommands: - `search [query]`: Searches for items and collects them. - `item [identifier]`: Collects a specific item. - `collection [identifier]`: Collects all items in a collection. A new package, `pkg/archive`, has been created to handle all API interactions with archive.org. The implementation includes pagination to ensure all items are retrieved from large searches or collections. Downloaded items are stored in an `archive/` directory, with each item's files and metadata saved in a subdirectory named after its identifier. Unit and integration tests have been added to verify the functionality of the new commands and the API client. All existing tests continue to pass. Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
22 lines
600 B
Go
22 lines
600 B
Go
package cmd
|
|
|
|
import (
|
|
"github.com/Snider/Borg/pkg/archive"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// collectArchiveItemCmd represents the collect archive item command
|
|
var collectArchiveItemCmd = &cobra.Command{
|
|
Use: "item [identifier]",
|
|
Short: "Collect an item from the Internet Archive.",
|
|
Long: `Collect an item and all of its files from the Internet Archive.`,
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
identifier := args[0]
|
|
return archive.DownloadItem(identifier, "archive", "")
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
collectArchiveCmd.AddCommand(collectArchiveItemCmd)
|
|
}
|