I'm trying to write a new extractor for youtube-dl. First I want to debug the __main__.py
to get to know the tool, but I cannot debug using VS Code. Here's my launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": ["a_youtube_video"]
}
]
}
My breakpoint is set in the __main__.py
, which looks like this:
from __future__ import unicode_literals
# Execute with
# $ python youtube_dl/__main__.py (2.6+)
# $ python -m youtube_dl (2.7+)
import sys
if __package__ is None and not hasattr(sys, 'frozen'):
# direct call of __main__.py
import os.path
path = os.path.realpath(os.path.abspath(__file__))
sys.path.insert(0, os.path.dirname(os.path.dirname(path)))
import youtube_dl
if __name__ == '__main__':
youtube_dl.main() # Breakpoint here
The error I'm facing is the import youtube_dl
line, it reports that there's no module named youtube_dl
. What am I missing here?
Edit: I've just found a way to debug it. It said right in the comments of the __main__.py
: From 2.7, the program must be run as a module. However I still don't understand this module thing.