Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and enhance download options configuration #9

Merged
merged 10 commits into from
Jul 3, 2024

Conversation

mitsuki31
Copy link
Owner

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

  • Added new features for configuring download and conversion behavior.
  • Refactored existing functions to support and apply the new configuration options.
  • Addressed and fixed various issues related to the download process.
  • Added global configuration module for CLI usage.

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 to downloadHandler:
    Added a verbose parameter to the downloadHandler function. This parameter, when set to false, suppresses the download progress bar. By default, it is set to false. Also added the await keyword to the writeLogError() call.

  • Add downloadOptions Parameter to Downloader Functions:
    Added a new downloadOptions parameter to the singleDownload and batchDownload 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

  • Make writeLogError Async to Await Directory Creation:
    Changed writeLogError to an async function and added await to the createDirIfNotExist(LOGDIR) call to ensure the log directory is created before writing the log file.

Chore

  • Include the 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.

If this option enabled (i.e., set to `true`) all log info and error messages will be suppressed, this also include the conversion progress.
Added a new typedef called `DownloadOptions` as an interface for the download options object. Later the download options will be used to configure the download process on `singleDownload` and `batchDownload` functions. Additionally, a function to resolve the download options object has been implemented and will strictly check the type for each option.
- Changed `writeLogError` to be an async function.
- Added `await` to `createDirIfNotExist(LOGDIR)` call to ensure the log directory is created before attempting to write the log file.
This parameter can be useful to suppress the download progress bar when set to `false`. Defaults to `false`. And also added `await` keyword on `writeLogError()` call.
Added a new parameter called `downloadOptions` (type of `DownloadOptions`) to `singleDownload` and `batchDownload` functions to configure the download process. In addition to this change, those functions are respectively refactored and updated to apply the given options.
This module provides global configuration options for the CLI usage of this project, it is not intended for programmatic use.

Note:
Options within the config module might be changed in future, because it is still in development.
@mitsuki31 mitsuki31 self-assigned this Jul 3, 2024
@mitsuki31 mitsuki31 added the refactor Refactor and enhancement changes label Jul 3, 2024
@mitsuki31 mitsuki31 merged commit cb0ae03 into master Jul 3, 2024
8 checks passed
@mitsuki31 mitsuki31 deleted the feature/add-download-options branch July 20, 2024 09:03
@mitsuki31 mitsuki31 added the feature Bring new features label Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Bring new features refactor Refactor and enhancement changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant