An open API service indexing awesome lists of open source software.

https://github.com/s-frei/tracksearch

Search on YouTube and/or SoundCloud for tracks and get their metadata
https://github.com/s-frei/tracksearch

expose http-client java metadata-extraction music search search-interface song soundcloud stream youtube

Last synced: 9 months ago
JSON representation

Search on YouTube and/or SoundCloud for tracks and get their metadata

Awesome Lists containing this project

README

          


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.

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

## Supported sources

Since TrackSearch focuses on searching for music (although YouTube offers more than music)
I decided to add following providers for now:

![youtube](https://img.shields.io/badge/-YouTube-FF0000?style=plastic&logo=youtube&logoColor=white)
![soundcloud](https://img.shields.io/badge/-SoundCloud-FF3300?style=plastic&logo=soundcloud&logoColor=white)

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

#### Current features :mag_right:

- search
- paging
- multiple clients asynchronous
- metadata like: duration, channel, views, thumbnail, ...

## Stream

With release [1.0.0](https://github.com/s-frei/TrackSearch/releases/tag/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](https://github.com/yt-dlp/yt-dlp).

To get the stripped functionality back use e.g.:

```shell
yt-dlp -J | 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.

## How to use it ? :books:

### Dependency

*TrackSearch* is available on [Maven Central](https://search.maven.org/artifact/io.sfrei/tracksearch):

```xml

io.sfrei
tracksearch
1.0.0

```

```kotlin
implementation("io.sfrei:tracksearch:1.0.0")
```

on [GitHub Packages](https://github.com/s-frei/TrackSearch/packages) or directly from
[GitHub Releases](https://github.com/s-frei/TrackSearch/releases/latest).

### Getting started

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

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

try {
TrackList tracksForSearch = searchClient.getTracksForSearch("");
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 nextTracks = tracksForSearch.next();

// Get a track for URL
SoundCloudTrack trackForUrl = explicitClient.getTrack("");

} catch (TrackSearchException e) {
// Damn
}
```

For more information check the related interface documentation or have a look into the
[tests](https://github.com/s-frei/TrackSearch/blob/develop/src/test/java/io/sfrei/tracksearch/clients/ClientTest.java).

## 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 :hammer:

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

Fire up following in your shell:

#### Build

```sh
$ ./mvnw clean install
```

#### Test

The *simple* [test runs daily](https://github.com/s-frei/TrackSearch/actions) to get notified when something is not
working. Test it on your own:

```sh
$ ./mvnw test
```

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

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

---

## Contributing :handshake:

Feel free to contribute! - [How?](https://github.com/s-frei/TrackSearch/blob/develop/CONTRIBUTING.md)