about import #162

Closed
opened 2026-02-20 21:04:15 -05:00 by deekerman · 3 comments
Owner

Originally created by @kusoayan on GitHub (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!

Originally created by @kusoayan on GitHub (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!
Author
Owner

@phihag commented on GitHub (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).

@phihag commented on GitHub (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).
Author
Owner

@archaeologistdev commented on GitHub (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)
@archaeologistdev commented on GitHub (May 23, 2014): @phihag and @kusoayan This has now been possible for a while, **let's close the issue.** Here's [jaimeMF](http://stackoverflow.com/users/1391487/jaimemf)'s [StackOverflow answer](http://stackoverflow.com/a/18947879/1106367) 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) ```
Author
Owner

@jaimeMF commented on GitHub (May 23, 2014):

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

@jaimeMF commented on GitHub (May 23, 2014): Yes, I think that the module is usable now. We can uses new issues for improvementes or problems.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl#162
No description provided.