diff options
author | Suleyman Farajli <suleyman@farajli.net> | 2025-05-02 18:02:29 +0400 |
---|---|---|
committer | Suleyman Farajli <suleyman@farajli.net> | 2025-05-02 18:02:29 +0400 |
commit | 77e0259ebc8f41e3d09a1d189eb805a81d82a5f9 (patch) | |
tree | f0cda65a2178cc7ed69542fdcb3b51ce0e0f205b | |
parent | 5ee153207f49dcd225bddfb07644aa9fa279b2a2 (diff) |
Download songs from the command line
-rw-r--r-- | README.md | 47 | ||||
-rwxr-xr-x | pamus | 11 |
2 files changed, 37 insertions, 21 deletions
@@ -1,6 +1,5 @@ # Pamus -This script allows you to download audio files from YouTube Music based on a list of song names, -and it also tags the downloaded files with relevant metadata (such as title, artist, album, genre). +This script allows you to download audio files from YouTube Music based on a list of song names, and it also tags the downloaded files with relevant metadata (such as title, artist, album, genre). ## Dependencies: - [Python 3](https://www.python.org) @@ -8,35 +7,43 @@ and it also tags the downloaded files with relevant metadata (such as title, art - [mutagen](https://mutagen.readthedocs.io/en/latest/) - [ytmusicapi](https://ytmusicapi.readthedocs.io/en/stable/) -## Script Overview -1. **Reads a list of song names** from a specified input file (by default $HOME/.config/pamus/list.txt). -2. **Searches for each song on YouTube Music** using the YTMusic API. -3. **Downloads the audio** in the specified format (mp3, flac, etc.) to specified directory (by default $HOME/music). -4. **Tags the audio files** with metadata (title, artist, album, genre). -5. Supports downloading multiple songs concurrently using threads. - ## Help -For help run: +For help, run: ```Bash pamus -h -``` ## Install Simply run: ``` Bash make ``` -### Examples +## Usage Examples -``` Bash -pamus -``` -This will download the songs listed in `$HOME/.config/pamus/list.txt` to the `$HOME/music` directory in mp3 format. +1. Using Input File: + To download songs listed in the input file (`$HOME/.config/pamus/list.txt`) to the default output directory (`$HOME/music`) in mp3 format: + ```bash + pamus + ``` -```bash -pamus -o /path/to/save/music -i /path/to/song_list.txt -f mp3 -v -``` -This will download the songs listed in `song_list.txt` to the specified output directory in MP3 format with verbose output enabled. +2. Specifying Songs Directly: + To download songs provided directly on the command line: + ```bash + pamus -s "Song Name 1" "Song Name 2" "Song Name 3" + ``` + This will download the specified songs to the default directory (`$HOME/music`) in the default format (`mp3`). + +3. Combining Both Methods: + To download both songs from the input file and songs provided directly on the command line: + ```bash + pamus -s "Song Name 1" "Song Name 2" -i /path/to/song_list.txt + ``` + This will download the songs listed in `song_list.txt` as well as the songs provided directly via the command line. + +4. With Additional Options: + To download songs from a specific list, save them to a custom directory, use a specific audio format, and enable verbose output: + ```bash + pamus -o /path/to/save/music -i /path/to/song_list.txt -f opus -v + ``` ### Example list.txt file (supports comments) ```txt @@ -123,18 +123,27 @@ def main(): default="mp3", help="Audio format to download (default: mp3)" ) + parser.add_argument( + "-s", "--song", + type=str, + nargs="*", + help="Song names to download (can provide multiple songs separated by space)" + ) args = parser.parse_args() output_dir = args.output_dir verbose = args.verbose input_file = args.input_file audio_format = args.audio_format + song_names = args.song # Replace $HOME with the actual home directory path for input file and output directory output_dir = output_dir.replace("$HOME", os.environ["HOME"]) input_file = input_file.replace("$HOME", os.environ["HOME"]) - song_names = read_song_names(input_file) + # If no songs are provided via command line, use the ones from the input file + if not song_names: + song_names = read_song_names(input_file) with ThreadPoolExecutor(max_workers=MAX_THREADS) as executor: futures = [executor.submit(process_song, name, output_dir, audio_format, verbose) for name in song_names] |