iheanyi / bandcamp-dl

Simple python script to download Bandcamp albums
The Unlicense
941 stars 104 forks source link

Can't download album art #193

Closed gamecat10 closed 2 years ago

gamecat10 commented 2 years ago

Describe the bug bandcamp-dl downloads mp3 files but can't download album art:

('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)) Couldn't download album art.

To Reproduce It doesn't work with any bandcamp url.

Desktop (please complete the following information):

Evolution0 commented 2 years ago

Doesn't look like the location of the art has changed, and the function that grabs it still points to exactly where it should to acquire it.

Just tested to be sure and everything is working fine.

Sure you aren't being rate limited or blocked by the image server?

gamecat10 commented 2 years ago

It looks like bandcamp somehow blocks requests from Russia. I can open for example this url in my browser: https://f4.bcbits.com/img/a2083383032_10.jpg

When I try to download it via curl I get the error:

  • Trying 151.101.86.132:443...
  • Connected to f4.bcbits.com (151.101.86.132) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/cert.pem
  • CApath: none
  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • LibreSSL SSL_connect: Connection reset by peer in connection to f4.bcbits.com:443
  • Closing connection 0 curl: (35) LibreSSL SSL_connect: Connection reset by peer in connection to f4.bcbits.com:443

But curl downloads the file successfully via VPN from Canada:

* Connected to f4.bcbits.com (151.101.126.132) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [227 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [102 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [2869 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [300 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [37 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.bcbits.com
*  start date: Dec 25 20:42:10 2021 GMT
*  expire date: Jan 26 20:42:09 2023 GMT
*  subjectAltName: host "f4.bcbits.com" matched cert's "*.bcbits.com"
*  issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign Atlas R3 DV TLS CA H2 2021
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x149011000)
> GET /img/a3011569679_10.jpg HTTP/2
> Host: f4.bcbits.com
> user-agent: curl/7.77.0
> accept: */*
> 
< HTTP/2 200 
< x-bc-host: boxycentral-b09r
< content-type: image/jpeg
< cache-control: public, max-age=31536000
< last-modified: Tue, 04 Jan 2022 19:33:41 GMT
< via: 1.1 varnish, 1.1 varnish
< accept-ranges: bytes
< date: Thu, 06 Jan 2022 09:14:21 GMT
< age: 135532
< x-served-by: cache-mdw17363-MDW, cache-yyz4543-YYZ
< x-cache: HIT, HIT
< x-cache-hits: 1, 1
< x-timer: S1641460461.475529,VS0,VE1
< content-length: 127366
< 
{ [982 bytes data]
100  124k  100  124k    0     0   132k      0 --:--:-- --:--:-- --:--:--  132k
* Connection #0 to host f4.bcbits.com left intact
Evolution0 commented 2 years ago

Looks like SOCKS support is even more vital then.

gamecat10 commented 2 years ago

Since http links work with no issues, I ended up applying this dirty fix: r = self.session.get(album['art'].replace('https', 'http'), headers=self.headers)

Evolution0 commented 2 years ago

Hmm.. maybe an argument to turn of HTTPS would be useful at some point.