iv-org / youtube-trusted-session-generator

This is a generator for getting a session that passes all the checks from YouTube side
GNU Affero General Public License v3.0
100 stars 8 forks source link

Issue running on AWS Lambda #9

Closed yannickErp closed 1 month ago

yannickErp commented 1 month ago

When trying to run it on AWS Lambda, I get these outputs in the logs:

[INFO] internally launching GUI (X11 environment)
--
[INFO] starting Xvfb
INIT_REPORT Init Duration: 9995.78 ms   Phase: init Status: timeout
[INFO] internally launching GUI (X11 environment)
[INFO] starting Xvfb
(EE)
Fatal server error:
(EE) Server is already active for display 99
If this server is no longer running, remove /tmp/.X99-lock
and start again.
(EE)
[INFO] launching chromium instance
[INFO] defining browser.
Traceback (most recent call last):
File "/usr/app/src/index.py", line 41, in <module>
loop().run_until_complete(main())
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/app/src/index.py", line 10, in main
browser = await start(headless=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/nodriver/core/util.py", line 74, in start
return await Browser.create(config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/nodriver/core/browser.py", line 87, in create
await instance.start()
File "/usr/local/lib/python3.12/site-packages/nodriver/core/browser.py", line 343, in start
raise Exception(
Exception:
---------------------
Failed to connect to browser
---------------------
One of the causes could be when you are running as root.
In that case you need to pass no_sandbox=True
successfully removed temp profile /tmp/uc_y2c1wwvt
INIT_REPORT Init Duration: 42332.40 ms  Phase: invoke   Status: error   Error Type: Runtime.ExitError
START RequestId: 4d84b26c-8c5a-433e-af40-5fef1d9c0beb Version: $LATEST
RequestId: 4d84b26c-8c5a-433e-af40-5fef1d9c0beb Error: Runtime exited with error: exit status 1Runtime.ExitError
END RequestId: 4d84b26c-8c5a-433e-af40-5fef1d9c0beb
REPORT RequestId: 4d84b26c-8c5a-433e-af40-5fef1d9c0beb  Duration: 42352.94 ms   Billed Duration: 42353 ms   Memory Size: 128 MB Max Memory Used: 128 MB
[INFO] internally launching GUI (X11 environment)
[INFO] starting Xvfb
(EE)
Fatal server error:
(EE) Server is already active for display 99
If this server is no longer running, remove /tmp/.X99-lock
and start again.
(EE)
INIT_REPORT Init Duration: 10009.59 ms  Phase: init Status: timeout

Using browser = await start(headless=False, no_sandbox=True) didn't do the trick either.

I am not sure what the problem is, I just pulled from Docker Hub, pushed to ECR and created a lambda that runs it. Haven't been able to run it successfully unfortunately.

unixfox commented 1 month ago

Lamba is not something that we have tested on and we have no plans to make it compatible for it. You are on your own.

There is a huge chance that there is not enough memory allocated to the container. 1GB of RAM is the very minimum.

yannickErp commented 1 month ago

Lamba is not something that we have tested on and we have no plans to make it compatible for it. You are on your own.

There is a huge chance that there is not enough memory allocated to the container. 1GB of RAM is the very minimum.

Is there any other way to run this script to get po_token and visitor_data somewhere else? Somewhere that I can call from my AWS Lambda to work with? I have a website that downloads youtube videos but I can't find a good solution for the recent changes youtube made. This seemed like a good solution for now...

unixfox commented 1 month ago

host the script on a linux server. but there is no API yet, it's WIP: https://github.com/iv-org/youtube-trusted-session-generator/pull/6