Skip to content

Commit

Permalink
use head request to resolve spotify short links
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Nov 26, 2023
1 parent 33dab00 commit f2af253
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
Expand Down Expand Up @@ -114,7 +115,7 @@ public AudioItem loadItem(AudioPlayerManager manager, AudioReference reference)

// If the identifier is a share URL, we need to follow the redirect to find out the real url behind it
if (reference.identifier.startsWith(SHARE_URL)) {
var request = new HttpGet(reference.identifier);
var request = new HttpHead(reference.identifier);
request.setConfig(RequestConfig.custom().setRedirectsEnabled(false).build());
try (var response = this.httpInterfaceManager.getInterface().execute(request)) {
if (response.getStatusLine().getStatusCode() == 307) {
Expand Down

0 comments on commit f2af253

Please sign in to comment.