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

Build youtube-dl from source #32076

Closed
3 tasks done
YoshiKill opened this issue Apr 21, 2023 · 33 comments
Closed
3 tasks done

Build youtube-dl from source #32076

YoshiKill opened this issue Apr 21, 2023 · 33 comments

Comments

@YoshiKill
Copy link

YoshiKill commented Apr 21, 2023

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

Hello can you help me and give (noob)instruction how to build step by step youtube-dl.exe with python 2.7 version?

@dirkf
Copy link
Contributor

dirkf commented Apr 21, 2023

In some order ...

  1. Read the code (and the developer documentation in the Manual)
  2. What platform?
  3. Are sure you don't want one of the update solutions proposed in [YouTube] Unable to extract uploader id #31530?

[ ] I've searched the bugtracker for similar questions including closed ones

  1. Why not?

@YoshiKill
Copy link
Author

YoshiKill commented Apr 21, 2023

I've searched the bugtracker for similar questions including closed ones
4. Why not?

already search not found any answer, forget to click

  1. Read the code (and the developer documentation in the Manual)

read but need more information because >(noob)instruction

2. What platform?

for Old PC Pentium III\Athlon Xp (no SSE2) Python 2.7 Windows xp sp3

Are sure you don't want one of the update solutions proposed in #31530?

yep, dlp is not solution in my case, because in Old PC(no SSE2) python version is under support 3.7+

@dirkf
Copy link
Contributor

dirkf commented Apr 21, 2023

yt-dlp wasn't the solution I meant but the unofficial Windows nightly yt-dl build won't help you if Python 3.4 is not supported. I'm fairly sure no-one here now can remember how to do what you want to do, but @Vangelis66 may have some idea (eg, where to find a later Python for your system).

If you have Py 2.7 installed and a working git, you can clone the master branch (or any other commit) and run the code from the local clone, or possibly install it as a Python module.

@YoshiKill
Copy link
Author

unofficial Windows nightly yt-dl build won't help you if Python 3.4 is not supported

if you about this https://github.com/ytdl-patched/youtube-dl/releases
Its work on python 2.7, but have issues with speed 50kbs.

In this git you fix low speed problem, some enthusiast from forum make build exe and its work with full speed, but he use modern python and its not work on win xp python 2.7 old pc.

If you have Py 2.7 installed and a working git

nope, just have clean ubuntu virtualbox and my enthusiasm to try build it.
Python 2.7 only on my old Win xp PIII machine for use youtube-dl

@dirkf
Copy link
Contributor

dirkf commented Apr 21, 2023

The unofficial nightly builds use the latest code including the speed-up fixes (and tomorrow, the fix for #32066, I hope). But the single file self-extracting build uses its own Py 3.4 so probably won't work for you.

There's no non-Python code in yt-dl itself since the hard work is passed to ffmpeg: thus your Py 2.7 should be able to run yt-dl as well as it runs with a new Python, if a bit slower.

@Vangelis66
Copy link

Vangelis66 commented Apr 21, 2023

@YoshiKill: MSFN forums member @nicolaasjan builds a youtube.dl.exe (x86) Windows binary with the py2exe python module, specifically for old CPUs without the SSE2 instructions set...

The binary is built against CPython 3.4.4, the last to support XP SP3... Problem is he hosts those builds on his dropbox account, direct links (which change over time) are only visible in his MSFN member signature (i.e. you need to be a member there to see them...).

https://msfn.org/board/topic/184368-who-here-has-a-youtube-dl-compile-for-winxp/#comment-1236966

SSE

At the time of this writing, the latest link is

https://dl.dropboxusercontent.com/s/f2q5v92qgq0fawp/youtube-dl.zip

(Please, don't abuse that account's bandwidth with mirroring...). The downloaded binary has a "last modified timestamp" of 20230414, so it was built on 26035bd and thus doesn't yet contain the fix for #32066; give him a day or two to update it (the whole process is manual) and, hopefully, you should be fine...

AFAIAA, no youtube-dl.exe based on CPython 2.7 has come to my attention; FWIW, in this specific case, one should avoid PyInstaller as the building module, because it produces EXEs which require SSE2+...

Being a total "noob" should make it a somewhat daunting task to compile the EXE, but nicolaas might be willing to break the process down to "baby" steps 😜 ...

As dirkf wrote above, if py2.7 is an absolute must, you could install CPython 2.7.18 and run youtube-dl from source as a python script, or (if pip is available), install it as a module you'd then invoke via python -m youtube_dl blahblahblah...

@october262
Copy link

see this thread - #30261

@nicolaasjan
Copy link

MSFN forums member @nicolaasjan builds a youtube.dl.exe (x86) Windows binary with the py2exe python module, specifically for old CPUs without the SSE2 instructions set...

The binary is built against CPython 3.4.4, the last to support XP SP3... Problem is he hosts those builds on his dropbox account, direct links (which change over time) are only visible in his MSFN member signature (i.e. you need to be a member there to see them...).

I'm up to date now (211cbfd). 😀️
This time the Dropbox link didn't change.

However, ytdl-patched is now up to date as well. 🙂

@nicolaasjan
Copy link

@YoshiKill, can't you update your Python 2.7 to Python 3.4.4?
(Windows x86 MSI installer)

To build from source:

  • Download the source.
  • Extract.
  • Edit version.py in .\youtube-dl\youtube_dl to reflect the current date.
  • Install dependencies:
    python -m pip install --upgrade "pip<19.2" "setuptools<44" "wheel<0.34.0" py2exe==0.9.2.2
  • In CMD, change directory to .\youtube-dl.
  • Enter python setup.py py2exe
  • Your newly created youtube-dl.exe will be created in that directory.

@DmytroUsenko

This comment was marked as off-topic.

@dirkf

This comment was marked as off-topic.

@dirkf dirkf changed the title Build yotube-dl from source Build youtube-dl from source Apr 23, 2023
@dirkf

This comment was marked as resolved.

@holms

This comment was marked as off-topic.

@dirkf

This comment was marked as off-topic.

@YoshiKill
Copy link
Author

@Vangelis66 @nicolaasjan thanks a lot, this version work good with full speed.

can't you update your Python 2.7 to Python 3.4.4?

yes, now i figure out that latest version that work with out SSE2 is 3.4.10, try to install and its work.
http://matejhorvat.si/en/unfiled/nosse2.htm

@nicolaasjan about your instruction, what OS you use for build? I use Ubuntu 22.04 and in step of "Install dependencies" i have error

ubuntu@ubuntu2004:~$ sudo apt install python -m pip install --upgrade "pip<19.2" "setuptools<44" "wheel<0.34.0" py2exe==0.9.2.2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'python3-pip' instead of 'pip'
Package python is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  2to3 python2-minimal:i386 python2:i386 python2-minimal python2 dh-python
  python-is-python3

E: Package 'python' has no installation candidate
E: Unable to locate package install
E: Unable to locate package pip<19.2
E: Unable to locate package setuptools<44
E: Unable to locate package wheel<0.34.0
E: Unable to locate package py2exe=

Enter python setup.py py2exe

ubuntu@ubuntu2004:~/ytdl/youtube-dl-master$ ./setup.py py2exe
/home/ubuntu/ytdl/youtube-dl-master/./setup.py:14: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  from distutils.core import setup, Command
Traceback (most recent call last):
  File "/home/ubuntu/ytdl/youtube-dl-master/./setup.py", line 11, in <module>
    from setuptools import setup, Command
ModuleNotFoundError: No module named 'setuptools'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/ytdl/youtube-dl-master/./setup.py", line 14, in <module>
    from distutils.core import setup, Command
ModuleNotFoundError: No module named 'distutils.core'

do these answers help?

mostly yes, but now i try to run build correctly from issues up

@dirkf
Copy link
Contributor

dirkf commented Apr 24, 2023

The message is saying that on Ubuntu 22.04 you need to do:

sudo apt install python3 python-is-python3

Then you can run python3 by saying python (probably python3 is delivered with the distro anyway).

Checking the MSFN thread I'm (as usual) in awe of the work there. If it might help, the error reported from Py 3.8 with yt-dlp (missing import GetCPFileNameFromRegistry from Windows kernel) looks like some locale-related thing, perhaps connected to yt-dlp trying to force UTF-8.

@nicolaasjan
Copy link

nicolaasjan commented Apr 24, 2023

about your instruction, what OS you use for build?

I build youtube-dl.exe in a Windows 7 VM, using 32bit Python 3.4.4, but it could be done on XP as well.

As far as I know you can't build an .exe file on Ubuntu with the instructions above.

On Ubuntu you can however build the Linux executable youtube-dl like this:

  • sudo apt-get -y install git zip pandoc man
  • git clone https://github.com/ytdl-org/youtube-dl.git
  • cd youtube-dl
  • make

It uses the system installed Python.

@nicolaasjan

This comment was marked as off-topic.

@YoshiKill
Copy link
Author

YoshiKill commented Apr 25, 2023

@nicolaasjan thanks for instruction, mostly i need the way to build youtube-dl.exe for windows (xp) that is priority method to learn. So can you again, step by step tell what i need to do to build youtube-dl.exe ?

I use (ubuntu) linux example only because i guess this is typical OS to build for all platforms.
I tried your linux method just in case to learn something new.
youtube-dl (python) file is created ok, 1.9mb size, i tried to run it from "home/youtube-dl/" folder with: youtube-dl "link"
but has issues in first log. Then i little bit thinking (it help's some times), read install instruction for linux from "Readme", put youtube-dl to /usr/local/bin/
use chmod a+rx command, and then its works.
So now i need only help how to build youtube-dl.exe in windows for windows(xp) Pyhthon 3.4.4(10).
I have main Windows 10, Windows xp retro Pc with Python 3.4.10 and Windows 7 Virtualbox, for experiments of build.

this is log just in case to show how it build in ubuntu and (not)run youtube-dl from /home dir

ubuntu@ubuntu2004:~$ cd youtube-dl
ubuntu@ubuntu2004:~/youtube-dl$ make
mkdir -p zip
for d in youtube_dl youtube_dl/downloader youtube_dl/extractor youtube_dl/postprocessor ; do \
  mkdir -p zip/$d ;\
  cp -pPR $d/*.py zip/$d/ ;\
done
touch -t 200001010101 zip/youtube_dl/*.py zip/youtube_dl/*/*.py
mv zip/youtube_dl/__main__.py zip/
cd zip ; zip -q ../youtube-dl youtube_dl/*.py youtube_dl/*/*.py __main__.py
rm -rf zip
echo '#!/usr/bin/env python' > youtube-dl
cat youtube-dl.zip >> youtube-dl
rm youtube-dl.zip
chmod a+x youtube-dl
COLUMNS=80 /usr/bin/env python youtube_dl/__main__.py --help | /usr/bin/env python devscripts/make_readme.py
/usr/bin/env python devscripts/make_contributing.py README.md CONTRIBUTING.md
pandoc -f markdown-smart -t plain README.md -o README.txt
/usr/bin/env python devscripts/prepare_manpage.py youtube-dl.1.temp.md
pandoc -s -f markdown-smart -t man youtube-dl.1.temp.md -o youtube-dl.1
rm -f youtube-dl.1.temp.md
/usr/bin/env python devscripts/bash-completion.py
/usr/bin/env python devscripts/zsh-completion.py
/usr/bin/env python devscripts/fish-completion.py
/usr/bin/env python devscripts/make_supportedsites.py docs/supportedsites.md
ubuntu@ubuntu2004:~/youtube-dl$ youtube-dl https://www.youtube.com/watch?v=1V_xRb0x9aw
Command 'youtube-dl' not found, but can be installed with:
sudo snap install youtube-dl  # version 2021.12.17+git01bf89e, or
sudo apt  install youtube-dl  # version 2021.12.17-1
See 'snap info youtube-dl' for additional versions.
ubuntu@ubuntu2004:~/youtube-dl$     

This as i said run fine then you put youtube-dl in right folders /usr/local/bin/

ubuntu@ubuntu2004:~$ youtube-dl https://www.youtube.com/watch?v=1V_xRb0x9aw
[youtube] 1V_xRb0x9aw: Downloading webpage
[download] Destination: Gorillaz - Clint Eastwood (Official Video)-1V_xRb0x9aw.mp4
[download] 100% of 13.90MiB in 00:01

@nicolaasjan
Copy link

nicolaasjan commented Apr 25, 2023

So can you again, step by step tell what i need to do to build youtube-dl.exe ?

Can you tell me which step(s) in my tutorial above you have issues with?
The first step is to download the code (click "Download ZIP"):

screenshot1

The rest speaks for itself I think.

Also, make sure C:\Program Files (x86)\Python3.4.4\ and C:\Program Files (x86)\Python3.4.4\Scripts are in your PATH (tutorial here).
For convenience, also put your youtube-dl folder in your PATH (e.g. C:\youtube-dl).
Also put ffmpeg.exe and ffprobe.exe in there. Then you'll be able to open a CMD prompt everywhere to use youtube-dl.

SSE compatible FFmpeg binaries for XP available here.
ffmpeg-5.2-2131-fcd557a-win32--xpmod-sse.7z 2023-01-07 21:52 30M

@YoshiKill
Copy link
Author

The first step is to download the code (click "Download ZIP")

this is hardest step but i heroically done it ;)

I have problem with this step

  • python -m pip install --upgrade "pip<19.2" "setuptools<44" "wheel<0.34.0" py2exe==0.9.2.2

in my case i don't understand what to do with this, run in cmd or whatever? I try run it in cmd at first time in my windows 7 virtualbox and have error, then run python setup.py py2exe end have error to, and stuck on it.

Then i try another way, i download windows xp for virtualbox(you can find it on web archive), run it, install python 3.4.10, download source zip youtube-dl.
Run cmd.
Try enter command python -m pip install --upgrade "pip<19.2" "setuptools<44" "wheel<0.34.0" py2exe==0.9.2.2
End now it's works and i see how it install all packages.
Then just do as you say in instruction cd \youtube-dl\ folder
run python setup.py py2exe

And all done. It build youtube-dl.exe
Now i understand why you don't understand my problem, its very trivial things, but only when you know all nuances what to do and have normal prepare OS.
So thanks for you patience and help.
Now it all works, and i hope this thread help's any one (stupid) like me to build it with out problem.

@nicolaasjan
Copy link

I try run it in cmd at first time in my windows 7 virtualbox and have error, then run python setup.py py2exe end have error to, and stuck on it.

Good to hear you finally succeeded in building.
And you're not "stupid". Compiling programs - especially on Windows - can be challenging.

Now I'm curious what error you encountered in Windows 7.
Was Python 3.4 not installed properly?

@Vangelis66
Copy link

Vangelis66 commented Apr 29, 2023

I'm up to date now (211cbfd). 😀️
...
However, ytdl-patched is now up to date as well. 🙂

... Incidentally, when that last comment was made (22/04/2023, 05:19Z), ytdl-patched/youtube-dl was "up to date" only in so far as its "version" was concerned 😜 ; code-wise, it was still on 6fece0a 😞 ; nicolaasjan has now read it (and reacted), others should read this report...

Additionally, I should like to highlight some differences (which are not immediately obvious) between the youtube-dl.exe binaries provided by nicolaasjan and the ones provided by "ytdl-patched":

  1. The ytdl-patched variety is built without any crypto support; HLSe streams must be delegated to a recent-ish FFmpeg build capable of handling them.
  2. The nicolaasjan variety is built with pycrypto-2.7a1; hence, HLSe streams can be "managed" by [hlsnative] (= pure-python-based HLS downloader, inside youtube-dl itself); these same builds are also built with merged:

#29581
#29593

so, provided your FFmpeg build is recent enough, they do away with the AtomicParsley extra dependency 😄 ...

@Vangelis66
Copy link

Vangelis66 commented Apr 30, 2023

Well, the opening post of this very issue has the following request:

how to build step by step youtube-dl.exe with python 2.7 version?

Further down in the discussion:

if Python 3.4 is not supported. I'm fairly sure no-one here now can remember how to do what you want to do,

In the MSFN thread I linked above, UK member loblo wrote (on page 4):

I compile my own youtube-dl.exe from git master with python 2.7 when needed, as with the recent breakages, for use on my (Windows) ME system.

Last night I set out to do just that, i.e. build a CPython 2.7.18 youtube-dl.exe binary (SSE-only) for really old H/W+Windows versions...

My old laptop has Vista SP2 32-bit as OS, so I made a (custom) installation of Python-2.7.18_x86 (Windows x86 MSI installer); my main install dir is
C:\Python2718-32\, inside which I created DIR yt-dl_pycompile...

Preparing the env+dependencies:

python -m ensurepip -U => 

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in links: c:\users\<redacted>\appdata\local\temp\tmpjn7mdq
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
python -m pip --no-python-version-warning install -U pip setuptools wheel => 

Collecting pip
  Downloading https://files.pythonhosted.org/packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl (1.5MB)

     |ΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫ| 1.5MB 819kB/s
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/e1/b7/182161210a13158cd3ccc41ee19aadef54496b74f2817cc147006ec932b4/setuptools-44.1.1-py2.py3-none-any.whl (583kB)
     |ΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫ| 583kB 1.1MB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/27/d6/003e593296a85fd6ed616ed962795b2f87709c3eee2bca4f6d0fe55c6d00/wheel-0.37.1-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
  Found existing installation: setuptools 41.2.0
    Uninstalling setuptools-41.2.0:
      Successfully uninstalled setuptools-41.2.0
Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.37.1

PyCrypto: PyPI only holds the source of that module; python -m pip install -U pycrypto would compile locally, but the module contains binary components (C++ extensions) and thus requires "Microsoft Visual C++ Compiler for Python 2.7" installed system-wide; the latter (installer's filename VCForPython27.msi) is no longer available directly from Microsoft 😡, but it has been salvaged by the Web Archive 👍 ... On second thought, I decided to follow an "easy way out" 😉 and opted to use a third-party provided wheel for said module:

python -m pip --no-python-version-warning install "pycrypto@https://github.com/jvansteirteghem/twunnel-app/raw/master/pip/pycrypto-2.6.1-cp27-none-win32.whl" => 

Collecting pycrypto@ https://github.com/jvansteirteghem/twunnel-app/raw/master/pip/pycrypto-2.6.1-cp27-none-win32.whl
  Downloading https://github.com/jvansteirteghem/twunnel-app/raw/master/pip/pycrypto-2.6.1-cp27-none-win32.whl (482 kB)
     |ΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫ| 482 kB 506 kB/s
Installing collected packages: pycrypto
Successfully installed pycrypto-2.6.1

py2exe: PyPI doesn't hold anything suitable for py2.7, as far as this module is concerned 👎 ; the EoS version for CPython-2.7.18 is py2exe-0.6.9; source and binary installer (in .EXE format) for that old version are hosted only on SF; compiling from source would, again, have required VCForPython27.msi globally installed... Fortunately, a kindest soul has prepared and uploaded to PyPI a wheel distribution of py2exe-0.6.9 called py2exe_py2:

python -m pip --no-python-version-warning install py2exe_py2 => 

Collecting py2exe_py2
  Downloading py2exe_py2-0.6.9-cp27-none-win32.whl (134 kB)
     |ΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫΫ| 134 kB 469 kB/s
Installing collected packages: py2exe-py2
Successfully installed py2exe-py2-0.6.9

Lastly,

python -m pip --no-python-version-warning list -u => 

Package    Version
---------- -------
pip        20.3.4
py2exe-py2 0.6.9
pycrypto   2.6.1
setuptools 44.1.1
wheel      0.37.1

Actually compiling:

I downloaded latest youtube-dl source from GitHub (at the time: ytdl-org-youtube-dl-2021.12.17-217-g211cbfd.zip); the contents of the extracted ytdl-org-youtube-dl-211cbfd DIR were placed inside previously prepared DIR
C:\Python2718-32\yt-dl_pycompile\

(i.e.: C:\Python2718-32\yt-dl_pycompile\youtube_dl, etc.)

File ".\youtube_dl\version.py" was edited manually (text editor) to read:

from __future__ import unicode_literals

__version__ = '2023.04.21'

I decided to also enable "Lazy Extractors", to enhance launching performance, thus:

in the Windows Command Prompt, I CD'ed to inside yt-dl_pycompile:

python "devscripts/make_lazy_extractors.py" "youtube_dl/extractor/lazy_extractors.py" => 

WARNING: Lazy loading extractors is an experimental feature that may not always work

As the last step:

python setup.py py2exe => 

(voluminous output curtailed)
...
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.

Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.

   OLEAUT32.dll - C:\Windows\system32\OLEAUT32.dll
   USER32.dll - C:\Windows\system32\USER32.dll
   SHELL32.dll - C:\Windows\system32\SHELL32.dll
   KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
   ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
   WS2_32.dll - C:\Windows\system32\WS2_32.dll
   GDI32.dll - C:\Windows\system32\GDI32.dll
   ole32.dll - C:\Windows\system32\ole32.dll

A new DIR called build was created inside yt-dl_pycompile, adjacent to it (i.e. in the root of yt-dl_pycompile) my sought-for executable 🎉 - testing it under the OS it was built proved that all was OK:

youtube-dl -v => 

[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v']
[debug] Encodings: locale cp1253, fs mbcs, out cp737, pref cp1253
[debug] youtube-dl version 2023.04.21
[debug] Lazy loading extractors enabled
[debug] Python version 2.7.18 (CPython) - Windows-Vista-6.0.6003-SP2
[debug] exe versions: none
[debug] Proxy map: {}
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

I believe my detailed building guide (thanks nicolaasjan 😄 ) is of some value, at least to retrocomputing Windows communities... If there's any interest for it (e.g. testing purposes), I could attach the resultant youtube-dl_py27.exe binary here, maintainer permitting, of course! 😜

Kind regards.

@nicolaasjan
Copy link

python "devscripts/make_lazy_extractors.py" "youtube_dl/extractor/lazy_extractors.py" 

WARNING: Lazy loading extractors is an experimental feature that may not always work

@dirkf
What's the current status of this feature? In which cases does it not work as intended?
Relevant pull request (merged): #8497.

If it's stable enough, I will implement it in my build.

@dirkf
Copy link
Contributor

dirkf commented Apr 30, 2023

I believe it works and may be worth trialling in your build. I have some pending updates as part of the new build but would appreciate knowing of any problems that should be fixed.

One issue with the lazy extractor test (in test/test_execution.py) is that a compiled version of extractor/lazy_extractors.py may be left around that breaks everything.

@nicolaasjan
Copy link

I have some pending updates as part of the new build but would appreciate knowing of any problems that should be fixed.

Could you elaborate?
What exactly should I test?
FWIW, a YouTube video downloaded fine with it, but I have no idea how to measure execution time differences...

In the meantime, I've uploaded the Unix and Windows binaries to Dropbox for you to do some testing, if you wish (with #29581 and #29593 included and also the Soundcloud fix #30998).

One issue with the lazy extractor test (in test/test_execution.py) is that a compiled version of extractor/lazy_extractors.py may be left around that breaks everything.

I don't quite understand that part.

@Vangelis66
Copy link

Vangelis66 commented May 1, 2023

but I have no idea how to measure execution time differences...

... If on Linux, you can use the time command, e.g.

time youtube.dl --ignore-config

More about that here 😄 ...

As usual, under Windows things are more difficult 😜 ; below, some SU+SO relevant articles:

https://superuser.com/questions/228056/windows-equivalent-to-unix-time-command

https://stackoverflow.com/questions/673523/how-do-i-measure-execution-time-of-a-command-on-the-windows-command-line

https://stackoverflow.com/questions/739606/how-long-does-a-batch-file-take-to-execute/739620#739620

Solutions involve MS and/or 3rd party utilities, batch files and PowerShell scripts (e.g.:

Measure-Command {Start-Process -NoNewWindow ".\youtube-dl.exe" --ignore-config -Wait}

) ...

The (old) timeit.exe utility mentioned inside these articles appears to work well under XP SP3 & Vista SP2 32-bit, but, reportedly, fails to work under Win7 SP1 x64 onwards... For newer 64-bit OSes, perhaps this fork should work 😉 ; it's the one utility that resembles the most its Unix analogue...

I did a comparison between your previous build (2023.04.22_nolazy) and the one you linked above (2023.04.30_lazy), both built from the same yt-dl source snapshot; the test command I used was:

timeit -s "youtube-dl --ignore-config"

Results:

2023.04.22_nolazy:

Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

Version Number:   Windows NT 6.0 (Build 6003)
Exit Time:        2:45 am, Monday, May 1 2023
Elapsed Time:     0:00:04.746
Process Time:     0:00:03.790

2023.04.30_lazy:

Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

Version Number:   Windows NT 6.0 (Build 6003)
Exit Time:        2:55 am, Monday, May 1 2023
Elapsed Time:     0:00:03.372
Process Time:     0:00:02.605

Thus, the LE-enabled second build loads (Process Time) ca. 45.5% faster compared to the default, non-LE-enabled, build...

"Downstream" have further evolved/improved the LE-related code and it's been enabled by default in "their" released builds since many months 😉 ; yt-dlp now prints a [debug] message only when LE have not been enabled; the make_lazy_extractors.py script has been enhanced to automatically place lazy_extractors.py inside ./youtube_dl/extractor/ (so, the LE "enabling" command under Windows is simply python "devscripts/make_lazy_extractors.py" - itself contained inside pyinst.py) ...

@nicolaasjan
Copy link

... If on Linux, you can use the time command, e.g.

time youtube.dl --ignore-config

Thanks!
Earlier I tried it on Windows 7, but got errors.

On Linux now:

2023.04.22_nolazy:

time youtube-dl --ignore-config
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

real	0m1,345s
user	0m1,306s
sys	0m0,037s

2023.04.30_lazy:

time youtube-dl --ignore-config
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.

real	0m0,356s
user	0m0,332s
sys	0m0,024s

@dirkf
Copy link
Contributor

dirkf commented May 1, 2023

"Downstream" have further evolved/improved the LE-related code ...

The pending changes that I mentioned should bring yt-dl up-to-date.

@Vangelis66
Copy link

Vangelis66 commented May 2, 2023

... One last (hopefully 😜 ) bit about Lazy Extractors (LE); it appears it's a known thing, see here where pukkandan wrote:

it seems the lower performance of py3 as opposed to py2 is a well known issue.

, and I was indeed able to verify that claim with my own, LE-enabled, youtube_py27.exe build (see above for details):

timeit -a -s "youtube-dl_py27 --version" => 

2023.04.21

Version Number:   Windows NT 6.0 (Build 6003)
Average is for 3 runs
Exit Time:        3:28 am, Tuesday, May 2 2023
Elapsed Time:     0:00:00.577  Average: 0:00:00.576
Process Time:     0:00:00.452  Average: 0:00:00.494

In contrast, the LE-enabled youtube-dl_py34.exe build prepared and linked by nicolaasjan under-performs considerably:

timeit -a -s "youtube-dl_py34 --version" =>

2023.04.30

Version Number:   Windows NT 6.0 (Build 6003)
Average is for 3 runs
Exit Time:        3:34 am, Tuesday, May 2 2023
Elapsed Time:     0:00:01.549  Average: 0:00:01.647
Process Time:     0:00:01.357  Average: 0:00:01.383

Another case of "newer isn't necessarily better" ? 😉 😄

@dirkf
Copy link
Contributor

dirkf commented May 3, 2023

Newer Python 3s are significantly faster than 3.4, maybe ~1.5x for 3.9, another ~2x for 3.11.

Typically Py3s win against Py2.7 anyway when the latter has to use shims or home-grown Python code to provide compatible APIs. The size of the program may be a significant win for 2.7 in low memory systems: for Linux x86, 2.7: 3.5MB, 3.5: 4.7MB, 3.9: 4.7MB; for Linux MIPS32, 2.7: 1.7MB.

@nicolaasjan
Copy link

nicolaasjan commented Apr 22, 2024

@Vangelis66 said:

2. these same builds are also built with merged:

#29581 #29593

so, provided your FFmpeg build is recent enough, they do away with the AtomicParsley extra dependency 😄 ...

Lately, I can't build youtube-dl any more with these PR's included... 🙁
#29581 now has conflicts that must be resolved.
See my reply under #29593.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants