Add and enhance download options configuration #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request introduces significant enhancements and new features to the YTMP3-JS library, primarily focusing on providing configurable options for the download and conversion processes. This includes the addition of a global configuration module tailored for CLI usage and improvements to existing functions to support these options.
Changes Made
Further Details
Features
Add
quiet
Option to Suppress Info in Audio Conversion:Introduced a
quiet
option in the audio conversion process. When enabled (true
), all log info and error messages, including the conversion progress, will be suppressed.Add
DownloadOptions
Typedef and Resolver:Added a new typedef called
DownloadOptions
to serve as an interface for the download options object. Implemented a resolver function to strictly check the types of each option, ensuring valid configuration.Add
verbose
Parameter todownloadHandler
:Added a
verbose
parameter to thedownloadHandler
function. This parameter, when set tofalse
, suppresses the download progress bar. By default, it is set tofalse
. Also added theawait
keyword to thewriteLogError()
call.Add
downloadOptions
Parameter to Downloader Functions:Added a new
downloadOptions
parameter to thesingleDownload
andbatchDownload
functions to configure the download process. Refactored these functions to apply the given options accordingly.Add Global Configuration Module for CLI Usage:
Introduced a new module to provide global configuration options for the CLI usage of the project. This module is not intended for programmatic use. Options in this module may change in future updates.
Apply Global CLI Configuration to Main Module:
Integrated the global CLI configuration options into the main module, ensuring consistent behavior across the CLI.
Refactors
writeLogError
Async to Await Directory Creation:Changed
writeLogError
to an async function and addedawait
to thecreateDirIfNotExist(LOGDIR)
call to ensure the log directory is created before writing the log file.Chore
config
Directory in JSDoc:Updated JSDoc configuration to include the
config
directory for comprehensive documentation coverage.Summary
This pull request enhances the YTMP3-JS library by adding configurable options for both the download and conversion processes. The new
DownloadOptions
typedef and resolver function ensure valid configurations, while the global configuration module provides a convenient way to manage CLI usage behavior. Additionally, improvements and fixes to existing functions ensure a more robust and user-friendly experience.