-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enhance core functionality and restructure the codebase #8
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module name: 'yt-urlfmt' This module provides all supported YouTube URL formats in regular expression, including: - Standard video URL - Shortened video URL - Playlist URL - Channel URL - YouTube Music URL
This utility module provides several helper functions for the core library, such as: - `logger` : A logger object to log info messages and error messages with ANSI color codes to the terminal - `ProgressBar` : A class to create the progression bar, this is useful to bring the information during download process to the terminal - `createDirIfNotExist` : This function will checks the specified directory, if not exist then creates new using asynchronous operation
Additionally, introduce a new option called `deleteOld` to choose whether to delete the old audio file or not.
This enhancements includes: - Added the progress information to the console - Added FFmpeg checker before performing audio conversion - Renamed the function `convertToMp3` to `convertAudio` - Improved exceptions handler - Revised and improved all documentations within `acodecs-cvt` module
This change also improved the documentations within the module.
The core module named `ytmp3`, this module will provide all APIs related to downloads YouTube videos as audio files. Also, I've moved several functions from the main module (`index.js`) to this module, including: * `getVideosInfo` * `singleDownload` * `batchDownload` This change also made the core module more robust and efficient, aiming at the download process. Previously, it only downloaded the first 15 URLs from the given file. Now, it downloads all of them sequentially and users can download more than 15 URLs in one batch. In addition, some internal functions has been defined to enhance the download process and make it more reliable, and also improved documentations and errors handling.
No new features added. But removed several internal functions in the main module as it was not used, such as: * `getVideosInfo` (moved to `ytmp3` module) * `singleDownload` (moved to `ytmp3` module) * `batchDownload` (moved to `ytmp3` module) * `normalizeYtMusicUrl` (removed permanently) In addition, renamed the `argumentParser` function to `getInput`, remove its parameter and small refactor. The function checks whether the given argument is an URL or a file path. If URL is given, the function returns the URL as a `URL` object. Otherwise, if the argument is a file path, the function returns the file path as a string.
This change also refactored the package.json by adding several fields such as, `files`, `exports`, `repository`, `keywords`, and more.
This issue was due to unexpectedly call the `trim()` function on URL object. Now it checked first before trimming whitespace.
Refactored the `getVideosInfo(...urls)` function to ensure it runs sequential instead parallel. This quite helpful for users with slow internet connection.
Implemented a checker within `batchDownload` function to check the FFmpeg before converting the downloaded audios.
mitsuki31
added
refactor
Refactor and enhancement changes
chore
Maintenance updates to improve project maintainability
labels
Jun 30, 2024
mitsuki31
changed the title
refactor: Enhance core functionality and restructure the codebase
Enhance core functionality and restructure the codebase
Jun 30, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 focuses on significant enhancements and refactoring across various modules of the project. These changes aim to improve the functionality, efficiency, and maintainability of the codebase. It includes new features, refactoring of existing functions, improvements in documentation, and several chore updates.
Changes Made
Features
YT URL Formats Module
Added a new module named
yt-urlfmt
which provides regular expressions for all supported YouTube URL formats including:This module standardizes URL validation across the project, making it easier to handle different types of YouTube URLs consistently.
Utility Module
Introduced a new utility module that provides several helper functions for the core library, such as:
logger
A namespace to log info, warning and error messages with ANSI color codes to the terminal, improving the visibility of process statuses and errors.
ProgressBar
A class to create a progress bar for displaying download progress in the terminal, enhancing user experience by providing visual feedback during downloads.
createDirIfNotExist
Checks if a specified directory exists and creates it if not, ensuring that necessary directories are available before file operations.
Function implementation:
Core Module
Added a core module named
ytmp3
which provides all APIs related to downloading YouTube videos as audio files. Functions such asgetVideosInfo
,singleDownload
, andbatchDownload
were moved from the main module to this core module. The download process was enhanced to handle all URLs sequentially, removing the previous limit of 15 URLs per batch.This change centralizes download-related functionality, making the codebase more modular and easier to maintain. It also improves the download process by handling large batches of URLs more efficiently.
Refactors & Enhancements
Rename and Improve Options in Audio Converter
Renamed
optionsMp3
todefaultOptions
and introduced a new optiondeleteOld
to decide whether to delete the old audio file.This change improves clarity by using more descriptive names and adds flexibility by allowing users to choose whether to keep old audio files.
Audio Converter Enhancements
Refined and improved the audio converter module. Changes include:
convertToMp3
toconvertAudio
to better reflect its functionality.Sequential Video Info Retrieval
Refactored the
getVideosInfo(...urls)
function to run sequentially instead of in parallel. This helps users with slow internet connections by reducing the load on the network and preventing potential timeouts.This change ensures more reliable video info retrieval, particularly for users with limited bandwidth.
Main Module Enhancements
Enhanced the functionality of the main module by removing unused internal functions and renaming
argumentParser
togetInput
. This function now checks if the given argument is a URL or a file path, improving input validation and processing.These changes streamline the main module, removing unnecessary code and improving the clarity and functionality of the
getInput
function.Chores & Maintenances
Change Indentation
Changed the indentation to two spaces for better readability, ensuring a consistent coding style across the project.
Ignore Directories in ESLint and Git
Updated ESLint and Git configurations to ignore the
docs
directory, reducing noise and potential conflicts during development.Add JSDoc Dependency
Added
jsdoc
dependency and its configuration file.Refactor the
package.json
Refactored
package.json
to include several fields likefiles
,exports
,repository
,keywords
, and more. This change improves documentation generation and package configuration.Documentation
Improve Utils Module Docs
Fixed and improved the documentation in the
utils
module, making it easier for developers to understand and use the provided functions.Summary
This pull request introduces several significant enhancements and refactors across the project:
These changes aim to make the codebase more robust, efficient, and maintainable, providing a better user experience and easier future development.