TrackSearch is for searching track metadata on different sources, like YouTube and SoundCloud for now.
Note: TrackSearch isn't using any API-Key, it uses the public API (like your browser).
Since TrackSearch focuses on searching for music (although YouTube offers more than music) I decided to add following providers for now:
There could be more added if there are interesting sources to go for.
- search
- paging
- multiple clients asynchronous
- metadata like: duration, channel, views, thumbnail, ...
With release 1.0.0 the capability of getting all available audio formats and the actual stream URL was removed, as it takes too much effort to maintain it and there are other huge projects that offer that with a large community like yt-dlp.
To get the stripped functionality back use e.g.:
yt-dlp -J <url> | jq '.formats | map(select(.vcodec == "none"))'I decided against implementing a simple wrapper to bring back the stripped functionalities as usage will differ from user to user.
TrackSearch is available on Maven Central:
<dependency>
<groupId>io.sfrei</groupId>
<artifactId>tracksearch</artifactId>
<version>1.0.0</version>
</dependency>implementation("io.sfrei:tracksearch:1.0.0")on GitHub Packages or directly from GitHub Releases.
// Client to search on all available sources asynchronous
MultiTrackSearchClient searchClient = new MultiSearchClient();
// Client for explicit source
TrackSearchClient<SoundCloudTrack> explicitClient = new SoundCloudClient();
try {
TrackList<Track> tracksForSearch = searchClient.getTracksForSearch("<your keywords>");
Track track = tracksForSearch.get(0);
final String url = track.getUrl();
final String title = track.getTitle();
final Duration duration = track.getDuration();
final TrackMetadata trackMetadata = track.getTrackMetadata();
final String channelName = trackMetadata.channelName();
final String channelUrl = trackMetadata.channelUrl();
final String thumbNailUrl = trackMetadata.thumbNailUrl();
final Long streamAmount = trackMetadata.streamAmount();
// Get next tracks page
TrackList<Track> nextTracks = tracksForSearch.next();
// Get a track for URL
SoundCloudTrack trackForUrl = explicitClient.getTrack("<soundcloud-url>");
} catch (TrackSearchException e) {
// Damn
}For more information check the related interface documentation or have a look into the tests.
I haven't found anything which is capable of doing this kind of stuff, except it offered something similar and could be abused for this, or it wasn't written in Java.
Note: JDK 17 is required! (sdk env install)
Fire up following in your shell:
$ ./mvnw clean installThe simple test runs daily to get notified when something is not working. Test it on your own:
$ ./mvnw testFor detailed test (about ~250 tracks for each client):
$ ./mvnw test -P detailed-client-testFeel free to contribute! - How?