freyr-js
                                
                                 freyr-js copied to clipboard
                                
                                    freyr-js copied to clipboard
                            
                            
                            
                        Support custom proxy
Like the title, following #95.
Hopefully, I get to look into this before cutting v0.6.0 this weekend. https://github.com/miraclx/freyr-js/pull/141
π€π½
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?
My .npmrc:
https-proxy = "http://127.0.0.1:7890/"
proxy = "http://127.0.0.1:7890/"
registry = "https://registry.npm.taobao.org/"
π€. 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.
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
===============================
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
...
Still though, the proxy shouldn't point to localhost.
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.
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.
@Goooler, just to clarify, can you open https://music.youtube.com with your proxy?
Yep, I can.
Oh, makes sense. So it turns out, the
httpclient library freyr uses for YouTube Music β got doesn't read those environment variables by default.
Maybe I should file a bug to got?
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.
In the meantime, we can use this: https://github.com/sindresorhus/got/blob/main/documentation/tips.md#proxying
Hey, can you test #143?