yt-music-id
Identify music from any segment of a YouTube video. Point it at a URL and a time range — it'll pull the audio, slice the clip, and Shazam it.
Install
pip install yt-music-id
Prerequisites: ffmpeg must be installed and on your PATH.
Usage
CLI
# By start + end time
yt-music-id "https://youtube.com/watch?v=xyz" --start 1:23 --end 1:45
# By start + duration (seconds)
yt-music-id "https://youtube.com/watch?v=xyz" --start 0:30 --duration 15
# Just start time (defaults to 10s clip)
yt-music-id "https://youtube.com/watch?v=xyz" --start 2:00
# Auto-split long segments (recommended for anything >15s)
yt-music-id "https://youtube.com/watch?v=xyz" --start 7:00 --end 8:00 --multi
# Raw JSON output
yt-music-id "https://youtube.com/watch?v=xyz" --start 1:00 --end 1:20 --json
# Keep extracted audio files
yt-music-id "https://youtube.com/watch?v=xyz" --start 1:00 --keep-files
Python API
import asyncio
from yt_music_id import download_audio, extract_segment, identify_music, print_match
async def find_song():
# Download audio
path, title, duration = download_audio(
"https://youtube.com/watch?v=xyz", "/tmp/raw"
)
# Extract a segment (7:00 to 7:15)
extract_segment(path, "/tmp/clip.mp3", start=420, duration=15)
# Identify
result = await identify_music("/tmp/clip.mp3")
# Print result
if result.get("track"):
print_match(result["track"], video_title=title)
asyncio.run(find_song())
Options
| Flag | Description |
|---|---|
--start TIME |
Start time (required). Formats: 1:30, 90, 0:01:30 |
--end TIME |
End time. Mutually exclusive with --duration |
--duration SEC |
Duration in seconds. Default: 10 |
--multi |
Auto-split long segments into 10s overlapping chunks for better accuracy |
--json |
Output raw Shazam JSON instead of formatted text |
--keep-files |
Don't delete temp audio files after identification |
Tips
- 5-15 seconds is the sweet spot for Shazam recognition
- Use
--multifor anything over 15 seconds — it auto-chops into overlapping 10s slices - Works best when the music is prominent (less dialogue/SFX over it)
- Some montage videos use original/custom music that won't be in Shazam's database
- Requires
ffmpegon PATH — install viabrew install ffmpeg,apt install ffmpeg, or ffmpeg.org
License
MIT
Metadata
Release files for yt-music-id 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yt_music_id-1.0.0.tar.gz | 6.2 kB | Without provenance | Details for yt_music_id-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yt_music_id-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for yt_music_id-1.0.0-py3-none-any.whl |
Total release size: 14.0 kB
Release files / yt_music_id-1.0.0.tar.gz
| Download URL | yt_music_id-1.0.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17a8bb8ffcafaa0fe8ec6d2660ba44c9154c6f829dea3a76f6b2ddc76dc73c07
|
|
BLAKE2b-256 checksum How to use checksums |
1e2d49d6dff35115b291ea071cf0fdae9d982bce84f1b2d6e1b87b3b5281e6ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / yt_music_id-1.0.0-py3-none-any.whl
| Download URL | yt_music_id-1.0.0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fad3d2e76db695c71e5dd1eda5e6a0ccbe6ad55761f9117754fd49911f414d35
|
|
BLAKE2b-256 checksum How to use checksums |
0d48a6fd529c6b2c03354a2e40240d950de0545a0a518f0b46d56399fa2c3e97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for yt-music-id 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.