YunzheZJU / youtube-po-token-generator

It generates a valid poToken with visitorData fetched from YouTube.
27 stars 3 forks source link

Add HTTP proxy support #1

Closed mooleshacat closed 1 month ago

mooleshacat commented 1 month ago

Hi

I have forked your repo ( https://github.com/mooleshacat/youtube-po-token-generator ) and added unauthenticated HTTP proxy support but I am not good at programming and changed the http.get over to a request. I used request because it was the only way I could find to get the proxy to work.

I was wondering if you could add proxy support to the code.

I would much rather use your code instead but it does not support proxy.

Thanks :)

YunzheZJU commented 1 month ago

Thank you for your suggestion.

It is said that Node.js would find and use the proxy settings from env, which is to say, this should work for static https proxy configurations without any modifications to youtube-po-token-generator:

export HTTP_PROXY=http://192.168.0.10:8888
export HTTPS_PROXY=http://192.168.0.10:8888
node index.js

Commands change on Windows but that is not difficult to find out.

There also exists a lib named global-agent to simply add proxy for all requests in Node.js, which can also be transparent to youtube-po-token-generator.

require('global-agent/bootstrap')

global.GLOBAL_AGENT.HTTP_PROXY = 'http://192.168.0.10:8888'

const { generate } = require('youtube-po-token-generator')

generate(options).then(console.log, console.error)

I can help you if you have tried the methods above but nothing works.

mooleshacat commented 1 month ago

Ok, I will try the first one. If I still can't get it to work I will re-open ticket.

I just find it hard to tell if it is actually working over the proxy or not but I am sure I can test it somehow.

Thank you :)

mooleshacat commented 1 month ago

I put export HTTP_PROXY=192.168.10.201:8888 and when I run a test script using http.get that goes to get the current IP it still shows it as my naked IP and not my VPN IP. I don't think this environment variable has any effect at all on the nodeJS code.

I will keep poking around with it but I'll keep the ticket open for now.

mooleshacat commented 1 month ago

I think I give up and don't want to waste your time so closing ticket

mooleshacat commented 1 month ago

Reopened to say I figured the easy way out, you have to specify both HTTP_PROXY and HTTPS_PROXY as the same http:// proxy. Your initial answer was correct , I just thought for some reason I don't need the HTTPS_PROXY set.

When I curl ipinfo.io/ip now I get VPN IP. Thanks 👍