Skip to main content

Download audio from youtube-dl soures and import into beets

Project description

beets-yt-dlp

Download audio from yt-dlp sources and import into beets.

Forked from vmassuchetto/beets-yt-dlp — extended with yt-dlp support and YouTube search functionality.

Download a direct URL:

$ beet yt-dlp "https://www.youtube.com/watch?v=wW6ykueIhX8"

Search YouTube and download the best match:

$ beet yt-dlp --search "Short Music for Short People Fat Wreck"

List imported tracks:

$ beet ls short music for short people

59 Times the Pain - Short Music for Short People - We Want the Kids
7 Seconds - Short Music for Short People - F.O.F.O.D.
88 Fingers Louie - Short Music for Short People - All My Friends Are in Popular Bands
Adrenalin O.D. - Short Music for Short People - Your Kung Fu Is Old... And Now You Must Die!
Aerobitch - Short Music for Short People - Steamroller Blues
[...]

Installation

pip install beets-yt-dlp

uv add beets-yt-dlp

Then enable the plugin in your config.yaml:

plugins: yt-dlp

Configuration

Available options and default values in config.yaml:

plugins: yt-dlp

yt-dlp:
    download: True          # download files from sources after getting information
    split_files: True       # try to split album files into separate tracks
    import: True            # import files into beets after downloading and splitting
    youtubedl_options: {}   # yt-dlp options -- https://github.com/yt-dlp/yt-dlp/blob/6f796a2bff332f72c3f250207cdf10db852f6016/yt_dlp/YoutubeDL.py#L199
    urls: []                # list of default URLs to download when no arguments are
                            # provided; you can point this at a playlist to check every time

How it works

The plugin's main goal is to deliver an importable file set to the beet import command. It downloads an audio file, looks for a tracklist with track times in the video description, splits the file into per-track files, assigns basic ID3 tags to them, and finally runs beet import on ${BEETS_CONFIG}/yt-dlp-cache/${VIDEO_ID}.

Search mode

When the --search / -s flag is used, the argument is treated as a free-text query instead of a URL. The plugin will:

  1. Query YouTube for the top 10 matching results using yt-dlp's ytsearch10: scheme (metadata only — nothing is downloaded at this stage).
  2. Pass those results through a ranking function (rank_results) to pick the best match.
  3. Hand the winning URL to the normal download and import flow.

The ranking function is simple view count, title similarity, and official audio title. Implement your own scoring logic inside rank_results() in the plugin source — see the docstring there for ideas and a ready-to-use skeleton using difflib.

CLI flags:

Flag Short Description
--search -s Treat the argument as a search query rather than a URL
--no-download Fetch metadata only, skip downloading
--no-split-files Skip splitting album files into tracks
--no-import Skip importing into beets
--force-download -f Re-download even if already in library
--keep-files -k Keep cached files after import
--write-dummy-mp3 -w Write blank MP3s with valid ID3 tags (for testing)
--verbose -v Print detailed processing information

Tips

  • Search mode picks the first-ranked result automatically. If the wrong video is chosen, try a more specific query or implement custom ranking logic in rank_results().

  • The video title can trick beets into misidentifying an album — if that happens, manually enter a search term when beets prompts you.

  • Use the bandcamp plugin for better metadata results.

  • Use a .netrc file to access your own YouTube playlists:

    machine youtube login somelogin@gmail.com password somepassword
    

    Check the yt-dlp netrc docs for more information. This lets you download private playlists or your subscriptions:

    beet yt-dlp "https://www.youtube.com/feed/subscriptions"
    
  • Download now, import later:

    Download and split without importing:

    beet yt-dlp "<url>" --keep-files --no-import
    

    Then import when ready:

    beet yt-dlp "<url>" --no-download --no-split-files
    

    Useful for large playlists that need manual beets intervention.

  • (Possibly) enhance audio quality:

    The default format is bestaudio/best at 192 kbps. For higher quality:

    yt-dlp:
        youtubedl_options:
            format: 'best'
            postprocessors:
                key: 'FFmpegExtractAudio'
                preferredcodec: 'mp3'
                preferredquality: '320'
                nopostoverwrites: True
    

    Note that 320 kbps may be nominal if the source audio isn't that quality. See this discussion.

Development

uv sync
uv run test.py

Credits

Based on vmassuchetto/beets-yt-dlp by Vinicius Massuchetto, originally licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beets_yt_dlp-0.1.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

beets_yt_dlp-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file beets_yt_dlp-0.1.0.tar.gz.

File metadata

  • Download URL: beets_yt_dlp-0.1.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for beets_yt_dlp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e52e41496aa7136a749cb7341d2647eecae24351ce9cdd6be38a801d698dc0d3
MD5 cac311f658a0dbe223702aafabf6c643
BLAKE2b-256 3926a78a2a7b718bd1d1d7fb6251f2748c28d8757c8f3687ff50b50008096367

See more details on using hashes here.

File details

Details for the file beets_yt_dlp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: beets_yt_dlp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for beets_yt_dlp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f9118ae16eb409ec3567de2e1b1b4058baf5469f535941f9cd2f2896aa6c119
MD5 8aab00ce4407ecf85a50a51019856225
BLAKE2b-256 cc2c7faed656e2aa3e009eeffb7995fb8c7e278fbbf323903e5e592cd4df0f07

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page