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

@kusoayan kusoayan commented Nov 17, 2011

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 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).

@ocisly
Copy link
Contributor

@ocisly 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 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 May 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.