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

about import #217

Closed
kusoayan opened this issue Nov 17, 2011 · 3 comments
Closed

about import #217

kusoayan opened this issue Nov 17, 2011 · 3 comments

Comments

@kusoayan
Copy link

If I want to use 'youtube-dl.py' in my own python program, how can i do it?
import it?
and then @@?
is there any documention for developer to use youtube-dl.py in their own program?

thx for answer
and sorry for my bad english

thx!

@phihag
Copy link
Contributor

phihag commented Nov 17, 2011

Currently, youtube-dl is not ready to be imported as a Python module, but we're working on it (Since there was no issue to track progress of the API-ification, I'll leave this one open).

What you can do is execute youtube-dl as a subprocess. See #152 for plans on a formal shell API (mainly for php).

FiloSottile referenced this issue in FiloSottile/youtube-dl Mar 30, 2012
…oad (#296) (follows current doclines); a small step towards importability #217
@ocisly
Copy link

ocisly commented May 23, 2014

@phihag and @kusoayan
This has now been possible for a while, let's close the issue.
Here's jaimeMF's StackOverflow answer on how to do it:

import youtube_dl

ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s'})
# Add all the available extractors
ydl.add_default_info_extractors()

result = ydl.extract_info('http://www.youtube.com/watch?v=BaW_jenozKc'
    , download=False # We just want to extract the info
    )

if 'entries' in result:
    # Can be a playlist or a list of videos
    video = result['entries'][0]
else:
    # Just a video
    video = result

print(video)
video_url = video['url']
print(video_url)

@jaimeMF
Copy link
Collaborator

jaimeMF commented May 23, 2014

Yes, I think that the module is usable now. We can uses new issues for improvementes or problems.

@jaimeMF jaimeMF closed this as completed May 23, 2014
joedborg referenced this issue in joedborg/youtube-dl Nov 17, 2020
[pull] master from ytdl-org:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants