Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

direct download and import from youtube #2913

Closed
rachmadaniHaryono opened this issue May 3, 2018 · 10 comments
Closed

direct download and import from youtube #2913

rachmadaniHaryono opened this issue May 3, 2018 · 10 comments
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." stale

Comments

@rachmadaniHaryono
Copy link
Contributor

rachmadaniHaryono commented May 3, 2018

Problem

my problem is not all my favorite artist/track is on musicbrainz, so there is some steps that i have to take before import it to beets

current workflow

  • search if track/artist is on musicbrainz
  • search youtube
  • download audio
  • import to beets

so why not cut some step from that.

here is proof of concept of that as script

https://gist.github.com/rachmadaniHaryono/934d0ba8eea14f3be5e91eb033481518

  • this require lot of dependencies especially pyav, which require little bit extra effort
  • no cache on youtube, so it take a while for single search
  • tested on python 3.6.5 and ubuntu 18.04 only
  • pyav not support unicode filename
  • no direct result from music brainz to youtube yet
@sampsyo
Copy link
Member

sampsyo commented May 3, 2018

Hi! Interesting work. What’s your proposal here? It seems like your solution is working OK already.

@sampsyo sampsyo added the needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." label May 3, 2018
@rachmadaniHaryono
Copy link
Contributor Author

rachmadaniHaryono commented May 3, 2018

I'm still learning how to make this as plugin for beet

  • I actually want to ask if anyone have done it before or maybe something better or could it be done another way?
  • is there a way to import a file but also give directly artist and title value for musicbrainz match track? Currently using simple import will depend on filename and if user enable fromfilename plugin
  • a way to save youtube metada to track? (views, up vote, down vote YouTube url, uploader, etc)

Updated script https://github.com/rachmadaniHaryono/beets/blob/master/yt_beets.py

E:

  • does beet support saving data from plugin? Or the plugin must handle it by themselves?

  • is it possible to add YouTube thumbnail as additional cover?

@wisp3rwind
Copy link
Member

In fact, I've a working (but completely undocumented and not very well tested or maintained) plugin in a local repository that does something along those lines. I had planned on uploading that to github at some point anyway, maybe I could do so soon, if I do, I'll drop a note here.

It hooks into youtube-dl in a rather hacky way and uses its commandline parser, lets it do its job and then starts a normal beets import session for anything that has been download, usage is like

beet ydl [beets-ydl options] -- [youtube-dl options]
# Import as singletons
beet ydl -- -f bestaudio <youtube link>
# import as album (useful for playlists for example)
beet ydl --album -- -f bestaudio <youtube link>

Beets' templating engine is used to set initial metadata (before the import) such that the importer has a good chance of matching musicbrainz entries. Because this is configurable, it could also be used to save any of the other metadata you mention as long as youtube-dl supports it.

@sampsyo
Copy link
Member

sampsyo commented May 4, 2018

is there a way to import a file but also give directly artist and title value for musicbrainz match track?

Not exactly, but perhaps more usefully: there is a --search-id flag to the import command that lets you specify a specific MBID.

a way to save YouTube metadata to track?

Have you seen the modify command? You can save any field name you like.

does beet support saving data from plugin?

I’m not sure exactly what you mean… but certainly, there are lots of plugins (lyrics, lastgenre, etc.) that store metadata. And see the fetchart plugin for an example of associating album art images with albums.

@vmassuchetto
Copy link
Contributor

Hey guys. I did some effort on this. Made a small plugin to download albums from Youtube. It will also parse track times from youtube-dl sources and split the mp3 album files into tracks. Tested only in some YouTube URLs by now. https://github.com/vmassuchetto/beets-ydl

@rachmadaniHaryono
Copy link
Contributor Author

hi @vmassuchetto , i would love it if you can improve it.

it would be better if the song can be searched without having to know the youtube url.

so search musicbrainz > search mb result on youtube (or others) > download with tags and info from youtube

@vmassuchetto
Copy link
Contributor

vmassuchetto commented Feb 8, 2019

@sampsyo this could be greatly improved if we could import one-track albums. I see that this is implemented in c9141a6, but doing beet import full-album.mp3 and entering some search to the correct album will try to import the file as a track of the album, and not as the full album.

Any ideas of how to achieve this? Would be great if tracklists could go into the description or something like this. Thanks.

@sampsyo
Copy link
Member

sampsyo commented Feb 9, 2019

That would be really hard to do, probably! It would require some fundamental changes to beets to decouple files from tracks—it currently believes that every item is backed by exactly one file. So multiple tracks can't be ranges within a single audio file on disk.
#136 discusses this kind of refactoring in more detail.

@stale
Copy link

stale bot commented Jul 12, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@mgoltzsche
Copy link
Contributor

mgoltzsche commented Dec 12, 2023

FWIW I created another plugin to download from Youtube: beets-ytimport. By default the plugin splits tracks that define chapters into separate tracks and imports them grouped as album into beets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needinfo We need more details or follow-up from the filer before this can be tagged "bug" or "feature." stale
Projects
None yet
Development

No branches or pull requests

6 participants
@sampsyo @vmassuchetto @rachmadaniHaryono @mgoltzsche @wisp3rwind and others