Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

Commit

Permalink
Add as many thumbnails as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Nov 26, 2023
1 parent f14589b commit ce03c81
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ plugins {
}

project.group = "com.dunctebot"
project.version = "1.8.5"
project.version = "1.9.0"
val archivesBaseName = "sourcemanagers"

repositories {
mavenCentral()
jcenter()
maven("https://m2.dv8tion.net/releases")
maven("https://maven.lavalink.dev/releases")

maven {
url = uri("https://jitpack.io")
Expand All @@ -41,11 +41,12 @@ repositories {
dependencies {
compileOnly(group = "dev.arbjerg", name = "lavaplayer", version = "2.0.3")

implementation("org.slf4j:slf4j-api:2.0.7")
implementation("commons-io:commons-io:2.7")
implementation(group = "org.jsoup", name = "jsoup", version = "1.15.3")
implementation(group = "com.google.code.findbugs", name = "jsr305", version = "3.0.2")

testImplementation(group = "dev.arbjerg", name = "lavaplayer", version = " 2.0.3")
testImplementation(group = "dev.arbjerg", name = "lavaplayer", version = "2.0.3")
}

configure<JavaPluginExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public AudioItem loadItem(AudioPlayerManager manager, AudioReference reference)
);

return new GetyarnAudioTrack(
AudioTrackInfoBuilder.create(ref, null).build(),
AudioTrackInfoBuilder.create(ref, null)
.setArtworkUrl("https://y.yarn.co/" + videoId + "_screenshot.jpg")
.build(),
this
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
Expand All @@ -41,15 +40,21 @@
import java.util.regex.Pattern;

import static com.dunctebot.sourcemanagers.Utils.urlDecode;
import static com.dunctebot.sourcemanagers.Utils.urlEncode;

public class MixcloudAudioSourceManager extends AbstractDuncteBotHttpSource {
private static final String THUMBNAILER_BASE = "https://thumbnailer.mixcloud.com/unsafe/390x390/";
private static final String GRAPHQL_AUDIO_REQUEST = "query PlayerHeroQuery(\n" +
" $lookup: CloudcastLookup!\n" +
") {\n" +
" cloudcast: cloudcastLookup(lookup: $lookup) {\n" +
" id\n" +
" name\n" +
" picture {\n" +
" isLight\n" +
" primaryColor\n" +
" darkPrimaryColor: primaryColor(darken: 60)\n" +
" ...UGCImage_picture\n" +
" }\n" +
" owner {\n" +
" ...AudioPageAvatar_user\n" +
" id\n" +
Expand Down Expand Up @@ -87,6 +92,11 @@ public class MixcloudAudioSourceManager extends AbstractDuncteBotHttpSource {
" }\n" +
" audioLength\n" +
" seekRestriction\n" +
"}\n" +
"\n" +
"fragment UGCImage_picture on Picture {\n" +
" urlRoot\n" +
" primaryColor\n" +
"}\n";
private static final Pattern URL_REGEX = Pattern.compile("https?://(?:(?:www|beta|m)\\.)?mixcloud\\.com/([^/]+)/(?!stream|uploads|favorites|listens|playlists)([^/]+)/?");

Expand Down Expand Up @@ -136,6 +146,7 @@ private AudioItem loadItemOnce(AudioReference reference, Matcher matcher) throws
);
}

final String picturePath = trackInfo.get("picture").get("urlRoot").text();
final String title = trackInfo.get("name").text();
final long duration = trackInfo.get("audioLength").as(Long.class) * 1000;
final String uploader = trackInfo.get("owner").get("username").text(); // displayName
Expand All @@ -147,7 +158,9 @@ private AudioItem loadItemOnce(AudioReference reference, Matcher matcher) throws
duration,
slug,
false,
reference.identifier
reference.identifier,
THUMBNAILER_BASE + picturePath,
null
),
this
);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/MixcloudTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class MixcloudTest {
public static void main(String[] args) {
// System.out.println(MixcloudAudioSourceManager.GRAPHQL_AUDIO_REQUEST);

// final var url = "https://www.mixcloud.com/jordy-boesten2/the-egotripper-lets-walk-to-my-house-mix-259/";
final var url = "https://www.mixcloud.com/Hirockn/the-100-best-tracks-2020-hip-hop-rb-pops-etc-the-weeknd-dababy-dua-lipa-juice-wrld-etc/";
final var url = "https://www.mixcloud.com/jordy-boesten2/the-egotripper-lets-walk-to-my-house-mix-259/";
// final var url = "https://www.mixcloud.com/Hirockn/the-100-best-tracks-2020-hip-hop-rb-pops-etc-the-weeknd-dababy-dua-lipa-juice-wrld-etc/";
final var mnrg = new MixcloudAudioSourceManager();
final AudioItem track = mnrg.loadItem(null, new AudioReference(url, null));

Expand Down

0 comments on commit ce03c81

Please sign in to comment.