Git Product home page Git Product logo

beets-ydl's Introduction

Travis CI

beets ydl

Download audio from youtube-dl sources and import into beets

$ beet ydl "https://www.youtube.com/watch?v=wW6ykueIhX8"

$ 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-ydl

And enable ydl plugin on your config.yaml file.

Configuration

Available options and default values on config.yaml:

plugins: ydl

ydl:
    download: True         # download files from sources after getting information,
    split_files: True       # try to split album files into separate tracks,
    import: True           # import files on youtube-dl after downloading and splitting,
    youtubedl_options: {}  # youtube-dl available options -- https://git.io/fN0c7
    urls: []               # list of default urls to download when no arguments are provided, you
                           # can provide a playlist to get checked every time

How it works

The plugin main goal is to deliver an importable file set to the beet import command, so it will download an audio file, look for a tracklist with track times in the video description, split the file into per-track files, assign some basic ID3 tags to them, and finally run beet import on ${BEETS_CONFIG}/ydl-cache/${VIDEO_ID} directory.

Tips

  • The video title can trick beets to find the correct album, in this case you'll have to manually enter a search term

  • Use the bandcamp plugin for better results

  • Use a .netrc file to use your own YouTube playlists

    Security discussions apart, you can create a ~/.netrc with credentials for youtube-dl to read.

    machine youtube login [email protected] password somepassword
    

    Check this entry on youtube-dl docs for more information.

    Like this, you can download private playlists or your subscriptions:

    beet ydl "https://www.youtube.com/feed/subscriptions"
    
  • Download and import later

    To download and split files without importing into beets:

    beet ydl "<source>" --keep-files --no-import
    

    And later, to import:

    beet ydl "<source>" --no-download --no-split-files
    

    Like this, you can download a big playlist and then run the beets import routine, which requires manual intervention.

  • (possibly) enhance audio quality

    beets-ydl uses a proposed 192kbps extractor 'bestaudio' format because it is more likely that it will find separate audio files on sources. Some high quality videos might have better audio quality embedded, so it can also make sense to set a higher quality extractor:

    ydl:
        youtubedl_options:
            format: 'best',
            postprocessors:
                key: 'FFmpegExtractAudio'
                preferredcodec: 'mp3'
                preferredquality: '320'
                nopostoverwrites: True

    This can, however, end-up with unnecessarily big files that have 320kbps as a merely nominal quality. See this discussion.

Development

Execute the env script to get into a virtualenv.

. ./env.develop

beets-ydl's People

Contributors

vmassuchetto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

beets-ydl's Issues

it doesn't work :-(

Hello,

-> installed python3 -m pip package OK
->beet ydl https://www.youtube.com/watch?v=OoMmK1q6pyw


zsh$ beet ydl "https://www.youtube.com/watch?v=OoMmK1q6pyw&t=18s"
Traceback (most recent call last):
File "/usr/local/bin/beet", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/beets/ui/init.py", line 1266, in main
_raw_main(args)
File "/usr/local/lib/python3.7/site-packages/beets/ui/init.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python3.7/site-packages/beetsplug/ydl.py", line 101, in ydl_func
outer_class.youtubedl(lib, opts, arg)
File "/usr/local/lib/python3.7/site-packages/beetsplug/ydl.py", line 153, in youtubedl
y = YoutubeDL(youtubedl_config)
File "/usr/local/lib/python3.7/site-packages/youtube_dl/YoutubeDL.py", line 353, in init
self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]
TypeError: get() takes from 1 to 2 positional arguments but 3 were given


Wha I could do?

Thank you

Warn user about cache size

When beets-ydl knowns that the user is leaving some cache that will never be deleted, show a warning about it.

KeyError on import

I'm trying to use beets-ydl for tagging Bandcamp albums, but keep getting an error:

$ beet ydl "https://androgynousbanana.bandcamp.com/album/year-of-the-flagon-2011-2014"
Traceback (most recent call last):
File "/usr/local/bin/beet", line 10, in
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/beets/ui/init.py", line 1266, in main
_raw_main(args)
File "/usr/local/lib/python3.7/site-packages/beets/ui/init.py", line 1253, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python3.7/site-packages/beetsplug/ydl.py", line 101, in ydl_func
outer_class.youtubedl(lib, opts, arg)
File "/usr/local/lib/python3.7/site-packages/beetsplug/ydl.py", line 176, in youtubedl
items = [x for x in lib.items('ydl:' + entry['id'])] +
KeyError: 'id'

Setup

OS: MacOS 10.13.6
beets version 1.4.8
Python version 3.7.2
plugins: bandcamp, edit, fetchart, fromfilename, ftintitle, hook, importadded, ydl

Config

plugins: edit ftintitle fromfilename importadded hook bandcamp fetchart ydl

import:
  copy: no         # Copy the file to our directory when importing?
  incremental: yes # Skip directories we already imported?
  write: yes        # Automatically write the file on library import / update?
  resume: yes      # Resume interrupted imports?
  log: beets.log   # Where should we write what we do?
  group_albums: yes

match:
  strong_rec_thresh: 0.1            # Any difference less than this is a strong recommendation
  preferred:                        # Put these at the top of recommendations
    countries: [US, GB|UK]          # My favorite music publishing countries
    media: [CD, Digital Media|File] # My favorite music sources
    original_year: yes              # entry year is close to entry original_year

bandcamp:
  split_artist_title: True

ydl:
  download: True
  split_files: True
  import: True

TypeError: get() takes from 1 to 2 positional arguments but 3 were given

The following error occurs when trying to use ydl with the following config file

[ydl] Calling youtube-dl
Traceback (most recent call last):
  File "/usr/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/usr/lib/python3.8/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/lib/python3.8/site-packages/beets/ui/__init__.py", line 1253, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/lib/python3.8/site-packages/beetsplug/ydl.py", line 101, in ydl_func
    outer_class.youtubedl(lib, opts, arg)
  File "/usr/lib/python3.8/site-packages/beetsplug/ydl.py", line 153, in youtubedl
    y = YoutubeDL(youtubedl_config)
  File "/usr/lib/python3.8/site-packages/youtube_dl/YoutubeDL.py", line 353, in __init__
    self._screen_file = [sys.stdout, sys.stderr][params.get('logtostderr', False)]
TypeError: get() takes from 1 to 2 positional arguments but 3 were given

The config file has this

ydl:
    download: True
    split_files: True
    import: True
    youtubedl_options:
        cookiefile: "~/.cookies.txt"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.