/TrackSearch

Search on YouTube and/or SoundCloud for tracks, get their metadata, and expose the underlying audio stream

Primary LanguageJavaApache License 2.0Apache-2.0

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

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

  • YouTube
  • SoundCloud

There could be more added if there is interesting content offered to go for.

Current features 🔎

  • Search for keywords
  • Paging of track lists
  • Expose audio stream url
  • Interact with multiple clients asynchronous
  • Get track metadata like: duration, channel, views, thumbnail, ...

How to use it ? 📚

Dependency

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.

Getting started

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);

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 120 tracks for each client):

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

Contributing 🤝

Feel free to contribute! - How?

Stuff to be added

  • Direct audio stream URL resolving
  • Playlist URL search