flashdagger / ytdlp-plugins

plugin manager for yt-dlp which enables releases of extractors as separate python package
The Unlicense
44 stars 4 forks source link

How to use plugin when using in python not using by command line #4

Closed demon071 closed 1 year ago

demon071 commented 1 year ago

Hi, I want how to use the plugin with yt-dlp, can you give me instructions?

flashdagger commented 1 year ago

Sure. But please be more specific. Also give an example how you are using yt-dlp.

demon071 commented 1 year ago

i'm trying to add the plugin to yt-dlp, but it seems to only be able to run the plugin when it's in the same directory as the source code. When I install yt-dlp from pip and create ytdlp_plugin folder in my project folder but it doesn't work

flashdagger commented 1 year ago

So you have project folder with your source code.

Do you want to A) use an existing plugin installed with pip in embedded yt-dlp code or B) develop your own plugin under ytdlp_plugins/extractor/<plugin>.py

Please be as specific as possible by describing your expectation.

demon071 commented 1 year ago

I want use an existing plugin installed with pip in embedded yt-dlp code

flashdagger commented 1 year ago

Try this:

import ytdlp_plugins
from yt_dlp import YoutubeDL

# add found plugin extractors to yt-dlp
ytdlp_plugins.initialize()
ytdlp_plugins.add_plugins()

with YoutubeDL() as ydl:
  ydl.download(...)

In future releases the initialize() won't be necessary...