TrackSearch is for searching track metadata on different sources, like Youtube and SoundCloud for now and to expose the URL of the underlying audio stream in the highest resolution. That offers the possibility to hand them over to other programs which are able to process them, like VLC, or Firefox which can display the audio directly for example.
Note: TrackSearch isn't using any API-Key, it uses the public API (like your browser).
Since TrackSearch focuses on just exposing the audio streams and to search for music (although YouTube offers more than music) I decided to add following providers first for now:
- YouTube
- SoundCloud
There could be more added if there is interesting content offered to go for.
- Search for keywords
- Paging of track lists
- Expose audio stream url
- Interact with multiple clients asynchronous
- Get track metadata like: duration, channel, views, thumbnail, ...
Maven dependency available on Maven Central:
<dependency>
<groupId>io.sfrei</groupId>
<artifactId>tracksearch</artifactId>
<version>0.9.0</version>
</dependency>
or from GitHub Packages or directly from GitHub Releases.
For more information check the related interface documentation.
// Client to search on all available sources asynchronous
MultiTrackSearchClient searchClient = new MultiSearchClient();
// Client for explicit source
TrackSearchClient<SoundCloudTrack> explicitClient = new SoundCloudClient();
// Search for tracks
TrackList<Track> tracksForSearch = searchClient.getTracksForSearch("your keywords");
// Get the audio stream
String streamUrl = tracksForSearch.get(anyPos).getStreamUrl();
// Get next tracks page
TrackList<Track> nextTracks = tracksForSearch.next();
// Get a track for URL
Track trackForURL = searchClient.getTrack("URL");
// Get the audio stream (retrying on failure)
searchClient.getStreamUrl(trackForURL, TrackSearchConfig.DEFAULT_RESOLVING_RETIRES);
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 install
The simple test runs daily to get notified when something is not working. Test it on your own:
$ ./mvnw test
For detailed test (about 120 tracks for each client):
$ ./mvnw test -P detailed-client-test
Feel free to contribute! - How?
- Direct audio stream URL resolving
- Playlist URL search