freyr-js icon indicating copy to clipboard operation
freyr-js copied to clipboard

Support custom proxy

Open Goooler opened this issue 3 years ago β€’ 15 comments

Like the title, following #95.

Goooler avatar Feb 10 '22 15:02 Goooler

Hopefully, I get to look into this before cutting v0.6.0 this weekend. https://github.com/miraclx/freyr-js/pull/141

🀞🏽

miraclx avatar Feb 16 '22 06:02 miraclx

Hi @Goooler, can you include the log from using a proxy?

My guess is setting HTTP_PROXY / HTTPS_PROXY solves the issue from https://github.com/miraclx/freyr-js/issues/95

But returns another error at the line Awaiting audiofeeds.

Is this assertion correct?

miraclx avatar Feb 18 '22 04:02 miraclx

My .npmrc:

https-proxy = "http://127.0.0.1:7890/"
proxy = "http://127.0.0.1:7890/"
registry = "https://registry.npm.taobao.org/"

Goooler avatar Feb 18 '22 04:02 Goooler

πŸ€”. I wouldn't expect this to work, though.. You're setting environment variables inside your .npmrc, freyr doesn't read that file.

And I doubt node does either.

Try this instead.

export https_proxy=".."
freyr ...

Also, looking at;

https-proxy = "http://127.0.0.1:7890/"

you're setting the proxy URL to localhost. that won't fix the problem. You need a proxy that's not georestricted. In your case, one that's not in china.

miraclx avatar Feb 18 '22 04:02 miraclx

snebula@MBP ξ‚° ~/Downloads ξ‚° freyr https://music.apple.com/cn/album/the-four-seasons-concerto-no-1-in-e-la-primavera/697328812\?i\=697329513
    ____
   / __/_______  __  _______
  / /_/ ___/ _ \/ / / / ___/
 / __/ /  /  __/ /_/ / /
/_/ /_/   \___/\__, /_/
              /____/ v0.5.0

freyr v0.5.0 - (c) Miraculous Owonubi <[email protected]>
-------------------------------------------------------------
Checking directory permissions...[done]
[https://music.apple.com/cn/album/the-four-seasons-concerto-no-1-in-e-la-primavera/697328812?i=697329513]
 [β€’] Identifying service...[Apple Music]
 [β€’] Checking authentication...[authenticated]
 Detected [track]
 Obtaining track metadata...[done]
  ➀ Title: The Four Seasons, Concerto No. 1 in E (La primavera/ Spring) RV269 (Op. 8 No. 1): I. Allegro
  ➀ Album: Vivaldi: The Four Seasons
  ➀ Artist: Anne-Sophie Mutter, 衫伯特・冯・卑拉扬 & Wiener Philharmoniker
  ➀ Year: 1984
  ➀ Playtime: 03:18
 [β€’] Collating...
 β€’ [01 The Four Seasons, Concerto No. 1 in E (La primavera/ Spring) RV269 (Op. 8 No. 1): I. Allegro]
    | ➀ Collating sources...
    |  ➀ [β€’] YouTube Music...


(failed: [connect ETIMEDOUT 203.111.254.117:443])
    |  ➀ [β€’] YouTube...(failed: [connect ETIMEDOUT 142.251.42.238:443
{
  "protocol": "https:",
  "host": "www.youtube.com",
  "hostname": "www.youtube.com",
  "port": null,
  "path": "/results?search_query=the%20four%20seasons%20concerto%20no%201%20in%20e%20la%20primavera%20spring%20rv269%20op%208%20i%20allegro%20%20&hl=en&gl=US",
  "method": "GET",
  "headers": {
    "content-type": "text/plain",
    "user-agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) (yt-search; https://www.npmjs.com/package/yt-search)",
    "accept": "text/html",
    "accept-encoding": "gzip",
    "accept-language": "en-US"
  }
}])
 [β€’] Download Complete
 [β€’] Embedding Metadata...
  β€’ [βœ•] 01 The Four Seasons, Concerto No. 1 in E (La primavera/ Spring) RV269 (Op. 8 No. 1): I. Allegro [apple_music:track:697329513] (failed: Failed collecting sources [connect ETIMEDOUT 142.251.42.238:443
{
  "protocol": "https:",
  "host": "www.youtube.com",
  "hostname": "www.youtube.com",
  "port": null,
  "path": "/results?search_query=the%20four%20seasons%20concerto%20no%201%20in%20e%20la%20primavera%20spring%20rv269%20op%208%20i%20allegro%20%20&hl=en&gl=US",
  "method": "GET",
  "headers": {
    "content-type": "text/plain",
    "user-agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html) (yt-search; https://www.npmjs.com/package/yt-search)",
    "accept": "text/html",
    "accept-encoding": "gzip",
    "accept-language": "en-US"
  }
}])
[β€’] Collation Complete
============ Stats ============
 [β€’] Runtime: [8m 53.4s]
 [β€’] Total queries: [01]
 [β€’] Total tracks: [01]
     Β» Skipped: [00]
     βœ“ Passed:  [00]
     βœ• Failed:  [01]
 [β€’] Output directory: [.]
 [β€’] Cover Art: cover.png (640x640)
 [β€’] Total Output size: 0.00 B
 [β€’] Total Network Usage: 0.00 B
     β™« Media: 0.00 B
     ➀ Album Art: 0.00 B
 [β€’] Output bitrate: 320k
===============================

Goooler avatar Feb 18 '22 04:02 Goooler

Actually I also set proxy in .zshrc:

export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 http_proxy=socks5://127.0.0.1:7890

...

Goooler avatar Feb 18 '22 04:02 Goooler

Still though, the proxy shouldn't point to localhost.

miraclx avatar Feb 18 '22 05:02 miraclx

The http://127.0.0.1:7890 is pointing to a proxy app in my device, it's Clash.

I can use the same proxy to git pull, update brew, and more.

Goooler avatar Feb 18 '22 05:02 Goooler

Oh, makes sense. So it turns out, the http client library freyr uses for YouTube Music – got doesn't read those environment variables by default.

I'll have to add an adapter. And one more for youtube-dl.

Although, the library we use for raw YouTube doesn't support proxies at all. So at most, I should be able to get YouTube Music working for you.

miraclx avatar Feb 18 '22 05:02 miraclx

@Goooler, just to clarify, can you open https://music.youtube.com with your proxy?

miraclx avatar Feb 18 '22 05:02 miraclx

Yep, I can.

Goooler avatar Feb 18 '22 05:02 Goooler

Oh, makes sense. So it turns out, the http client library freyr uses for YouTube Music – got doesn't read those environment variables by default.

Maybe I should file a bug to got?

Goooler avatar Feb 18 '22 05:02 Goooler

it's already there: https://github.com/sindresorhus/got/issues/79

Author thinks it should be a node-specific feature and not a library-specific feature.

miraclx avatar Feb 18 '22 05:02 miraclx

In the meantime, we can use this: https://github.com/sindresorhus/got/blob/main/documentation/tips.md#proxying

miraclx avatar Feb 18 '22 05:02 miraclx

Hey, can you test #143?

miraclx avatar Feb 18 '22 05:02 miraclx