ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.7k stars 10.07k forks source link

Running on an AWS Lambda #32650

Closed ryangonzalez133 closed 1 year ago

ryangonzalez133 commented 1 year ago

Checklist

Question

Does anyone know a way to run Youtube-dl in an AWS Lambda? I've tried everything and I just get the error ("errorMessage": "Unable to import module 'lambda_function': No module named 'youtube_dl'", "errorType": "Runtime.ImportModuleError")

dirkf commented 1 year ago

Your problem is really about setting up a "function" to run in AWS Lambda. Nonetheless here are two suggestions based on a few seconds of web search, which would really be your best way forward together with reading the AWS Lambda docs.

  1. A Linux program can be launched in your AWS Lambda through a supported runtime, provided that its dependencies have been installed.
  2. One supported runtime is Python: install youtube-dl as a module and make your function invoke it through the API. But...
  3. Streaming sites frown on IP addresses associated with data centres: your downloads may be throttled or blocked.
ryangonzalez133 commented 1 year ago

I'm trying to run on an ARM lambda and I get this error. Do you know a way to run on ARM architecture?

(Function Logs [ERROR] OSError: Cannot load native module 'Cryptodome.Cipher._raw_ecb': Not found '_raw_ecb.cpython-310-aarch64-linux-gnu.so', Cannot load '_raw_ecb.abi3.so': /opt/python/Cryptodome/Util/../Cipher/_raw_ecb.abi3.so: cannot open shared object file: No such file or directory, Not found '_raw_ecb.so' Traceback (most recent call last):   File "/var/lang/lib/python3.10/importlib/init.py", line 126, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   File "", line 1050, in _gcd_import   File "", line 1027, in _find_and_load   File "", line 1006, in _find_and_load_unlocked   File "", line 688, in _load_unlocked   File "", line 883, in exec_module   File "", line 241, in _call_with_frames_removed   File "/var/task/index.py", line 1, in     import yt_dlp   File "/opt/python/yt_dlp/init.py", line 19, in     from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS   File "/opt/python/yt_dlp/cookies.py", line 21, in     from .aes import (   File "/opt/python/yt_dlp/aes.py", line 5, in     from .dependencies import Cryptodome   File "/opt/python/yt_dlp/dependencies/init.py", line 80, in     from . import Cryptodome   File "/opt/python/yt_dlp/dependencies/Cryptodome.py", line 19, in     from Cryptodome.Cipher import AES, PKCS1_OAEP, Blowfish, PKCS1_v1_5   File "/opt/python/Cryptodome/Cipher/init.py", line 27, in     from Cryptodome.Cipher._mode_ecb import _create_ecb_cipher   File "/opt/python/Cryptodome/Cipher/_mode_ecb.py", line 35, in     raw_ecb_lib = load_pycryptodome_raw_lib("Cryptodome.Cipher._raw_ecb", """   File "/opt/python/Cryptodome/Util/_raw_api.py", line 315, in load_pycryptodome_raw_lib     raise OSError("Cannot load native module '%s': %s" % (name, ", ".join(attempts)))INIT_REPORT Init Duration: 556.90 ms Phase: init Status: error Error Type: Runtime.ExitError INIT_REPORT Init Duration: 3063.30 ms Phase: invoke Status: error Error Type: Runtime.Unknown START RequestId: 45b04ca4-ff42-42c6-9e03-06c851d5eb79 Version: $LATEST 2023-12-01T00:23:25.424Z 45b04ca4-ff42-42c6-9e03-06c851d5eb79 Task timed out after 3.19 seconds)

dirkf commented 1 year ago

30839: "if you were actually running yt-dlp ..."

But as above, you have to do whatever AWS wants you to do to ensure that the necessary dependencies are available.