https://github.com/hackerb9/getsong
Wrapper for yt-dlp that makes searching and downloading songs easier
https://github.com/hackerb9/getsong
bash closed-captions download imfeelinglucky lyrics search wrapper youtube yt-dlp
Last synced: about 1 month ago
JSON representation
Wrapper for yt-dlp that makes searching and downloading songs easier
- Host: GitHub
- URL: https://github.com/hackerb9/getsong
- Owner: hackerb9
- License: gpl-3.0
- Created: 2023-10-12T05:07:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-12T07:24:39.000Z (over 2 years ago)
- Last Synced: 2025-01-29T01:56:16.478Z (over 1 year ago)
- Topics: bash, closed-captions, download, imfeelinglucky, lyrics, search, wrapper, youtube, yt-dlp
- Language: Shell
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getsong
Given a song name, artist, lyrics or whatever, search for and download a song using yt-dlp.
* Handles multiple arguments (including embedded spaces) correctly.
* Uses youtube.com URL, instead of yt-dlp's ytsearch.
* Allows `-c` to restrict search to videos with closed captions (manually generated lyrics/subtitles).
* Can read search terms from a file, downloading one song per line.
* If `xsel` is installed, will search for whatever words are currently highlighted by the mouse cursor and download that song.
* Can download videos instead by changing the script's name: `ln -s getsong getvideo`
## Installation
It's just a bash script. Download it, make it executable, and put it in your PATH.
```bash
wget https://raw.githubusercontent.com/hackerb9/getsong/main/getsong
chmod +x getsong
sudo mv getsong /usr/local/bin/
```
## Usage
Usage: **getsong** [ _-c_ ] [ _keywords_ ... ]
_-c_: filter to only results with closed captions (subtitles)
_keywords_: a song title, lyrics, artist name, or anything, really.
If no keywords are specified, then the X selection (the
last text highlighted by the mouse) will be used.
If you redirect a file to stdin, then getsong will perform a search for
every song listed in the file, one per line.
## Examples
Search YouTube for a term and download the audio:
getsong genjer
Search and download audio that matches two phrases:
getsong "Mr. Orange" "Dengue Fever"
Limit search to only results with "closed captions" (i.e., lyrics or other subtitles manually generated by the uploader):
getsong -c "A week ago last Thursday"
## Seeing lyrics on the command line as audio plays
The `mpv` program displays subtitles on the terminal if no video window was opened. While playing, one can hit the j key to see the subtitles. Alternately, one can use a command line argument `--sid=1`:
```bash
$ mpv --vo null --sid=1 makeba.mka
(+) Audio --aid=1 --alang=eng (opus 2ch 48000Hz)
(+) Subs --sid=1 --slang=eng 'English - en' (webvtt-webm)
AO: [pipewire] 48000Hz stereo 2ch floatp
"Ooohe" Makeba, Makeba
ma qué bella Can I get a
A: 00:00:40 / 00:03:43 (18%)
```
## Caveats
Note, that the `-c` option makes captions a requirement, not just a preference. Ideally, we'd get an error message if no captioned version exists, but instead YouTube mangles and ignores the search terms until it finds an incorrect video that _does_ have closed captions.
Another possible issue: YouTube doesn't look at the quality or even quantity of the captions, only whether they exist or not. Occasionally, the "lyrics" to a song will be a single subtitle which reads, unhelpfully, "🎜 (singing) 🎝". In those cases, using the 2nd result (`--playlist-items 2:2`) usually helps.