Skip to content

[BandcampBridge] Fix JS challenge by setting User-Agent in apiGet()#4979

Open
sid115 wants to merge 2 commits into
RSS-Bridge:masterfrom
sid115:bandcamp-user-agent-in-apiget
Open

[BandcampBridge] Fix JS challenge by setting User-Agent in apiGet()#4979
sid115 wants to merge 2 commits into
RSS-Bridge:masterfrom
sid115:bandcamp-user-agent-in-apiget

Conversation

@sid115

@sid115 sid115 commented May 5, 2026

Copy link
Copy Markdown

Bandcamp's mobile API returns a JavaScript challenge page when requests are made without a User-Agent header, causing json_decode() to return null and a subsequent count(null) TypeError.

Explicitly set a browser User-Agent in apiGet() to bypass this. Also add null check on the response to give a meaningful error instead of a TypeError if the API returns an unexpected response in the future.

Resolves #4978.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

Pull request artifacts

Bridge Context Status
Bandcamp 1 By tag (current) ✔️
Bandcamp 1 By tag (pr) ✔️
Bandcamp 2 By band (current) Bridge returned error 0! (20578)
Type: Exception
Message: Invalid parameters value(s): limit
Bandcamp 2 By band (pr) Bridge returned error 0! (20578)
Type: Exception
Message: Invalid parameters value(s): limit
Bandcamp 3 By label (current) ✔️
Bandcamp 3 By label (pr) ✔️
Bandcamp 4 By album (current) ✔️
Bandcamp 4 By album (pr) ✔️

last change: Tuesday 2026-05-05 22:39:41

@sid115

sid115 commented May 5, 2026

Copy link
Copy Markdown
Author

Ok, I need some help fixing the gh actions. Not sure what is going wrong here. I am very confident that the fix works since I run my fork on my RSS-Bridge instance successfully.

@Mynacol Mynacol added the Bridge-Broken Confirmed broken bridge label May 23, 2026
// todo: 429 Too Many Requests happens a lot
$response = getContents($url);
$header = [
'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is Firefox version 124 coming from? Why not 140 (current esr) or sth. else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bridge-Broken Confirmed broken bridge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bandcamp Label failed with: count(): Argument #1 ($value) must be of type Countable|array, null given

2 participants