Skip to content

s-frei/TrackSearch

Repository files navigation

TrackSearch


Contributions welcome License GitHub release (latest by date) Maven Central release
Functionality Test State Latest

What is it ?

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 with the best quality. That offers the possibility to hand them over to other programs which are able to process them, like VLC, or Firefox which can display (most) streams directly, for example.

Note: TrackSearch isn't using any API-Key, it uses the public API (like your browser).

Supported sources

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 for now:

youtube soundcloud

There could be more added if there are interesting sources to go for.

Note: Those sources are accessed vie the public API without the use of any API key or similar.

Current features 🔎

  • search
  • paging
  • (audio) stream url
  • format
  • multiple clients asynchronous
  • metadata like: duration, channel, views, thumbnail, ...

How to use it ? 📚

Dependency

TrackSearch is available on Maven Central:

<dependency>
    <groupId>io.sfrei</groupId>
    <artifactId>tracksearch</artifactId>
    <version>0.10.0</version>
</dependency>
implementation("io.sfrei:tracksearch:0.10.0")

on GitHub Packages or directly from GitHub Releases.

Getting started

// Client to search on all available sources asynchronous
MultiTrackSearchClient searchClient = new MultiSearchClient();

// Client for explicit source
TrackSearchClient<SoundCloudTrack> explicitClient = new SoundCloudClient();

try {
    // Search for tracks
    TrackList<Track> tracksForSearch = searchClient.getTracksForSearch("your keywords");
    TrackStream stream = tracksForSearch.get(0).getStream();

    // Stream URL with format
    final String streamUrl = stream.url();
    final TrackFormat format = stream.format();

    // 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.

Why is this done ?

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.

Develop 🔨

Note: JDK 17 is required! (sdk env install)

Fire up following in your shell:

Build

$ ./mvnw clean install

Test

The simple test runs daily to get notified when something is not working. Test it on your own:

$ ./mvnw test

For detailed test (about ~250 tracks for each client):

$ ./mvnw test -P detailed-client-test

Contributing 🤝

Feel free to contribute! - How?