16

At first I want to admit that I am a noob in python programming. but still somehow I have managed to figure out how to modify some python regular expressions as the extractor can get some extra data for me. Unfortunately I don't know how to build executable from the changed source code. because I am using a PHP wrapper to use the youtube-dl ubuntu executable for scraping some data.

I have noticed there is a 6+ years old post on this in

Python youtube-dl recompile

but unfortunately the solution didn't provide the way to recompile or rebuild. I even haven't found how to rebuild in the official documentation for developer here in

https://github.com/ytdl-org/youtube-dl#developer-instructions

Most users do not need to build youtube-dl and can download the builds or get them from their distribution.

To run youtube-dl as a developer, you don't need to build anything either.

and at the end for open source contribution using git

  1. Finally, create a pull request. We'll then review and merge it.

but couldn't find anything to build it locally to use locally.

coolsaint
  • 1,291
  • 2
  • 16
  • 27

2 Answers2

13

As documented in the development instructions, you can run youtube-dl interactively with

python -m youtube_dl

while the youtube-dl repository is in your PYTHONPATH, for example because your cwd is the root of the youtube-dl repository.

For development, it's often easier to run the tests instead. Again, as documented, any of these work:

python -m unittest discover
python test/test_download.py
nosetests

If you're developing an extractor, you can run

python test/test_download.py TestDownload.test_YourExtractor

to just test your extractor.

If you actually want a youtube-dl binary, type

make

in the root directory of the youtube-dl repository. You will get a binary called youtube-dl.

Note that make works with any well-maintained software project, although some new-millennium hipster languages prefer to reinvent their own incompatible version.

2

if you are in hurry and want to test you changes on youtube-dl file you can run it from it source python main file src_path/youtube_dl/__main__.py I use this to test running youtube-dl on Python3.8 instead of my system default 2.7.12 I just change #!/usr/bin/env python to #!/usr/bin/env python3.8 and I ad soft link to the file youtube_dl/__main__.py on my system /usr/local/sbin/ so you can test your changes immediately .

Salem
  • 654
  • 7
  • 24