Library that retrieves SomaFM's recently played songs.
Please support SomaFM's awesome work here.
As stated on this page:
SomaFM API is no longer available to third parties
Thus this library works by parsing SomaFM's "Recently Played Songs" page (example here).
This functionality was originally extracted from the somafm-song-history project.
This lib is developed for my very limited personal use and as such, it is not published on any public artifact repository, only on a private, self-hosted one. You can always grab the jar and include it in your project (see below). I'll be glad to help if you encounter any issue.
See the changelog.
You will find a Spring toy project thats uses the lib in the example-project
module.
Basic usage:
// Normal usage
SomaFm somaFm = SomaFm.of("your-user-agent");
List<Broadcast> broadcasts = somaFm.fetchRecent(PredefinedChannel.GROOVE_SALAD);
// With a channel not yet supported by the lib
CustomChannel myCustomChannel = CustomChannel.of("newchannel", "New Channel", false);
List<Broadcast> otherBroadcasts = somaFm.fetchRecent(myCustomChannel);
In case you are working from user input:
String publicName = getUserInput();
Channel channel = PredefinedChannel
.getByPublicName(publicName)
.orElseThrow(() -> new UnknownChannelException(publicName)); // Create your own exception
This lib might be published on a public repository one day.
To use the jar in a project, I suggest the following workflow:
-
Grab the jar.
-
Create a
lib
directory in your project. -
Still in your project, execute the following Maven command after filling the placeholders:
mvn install:install-file \ -Dfile=[path-to-jar] \ -DgroupId=net.lecigne \ -DartifactId=somafm-recentlib \ -Dversion=0.1.0 \ -Dpackaging=jar \ -DlocalRepositoryPath=lib/ \ -DgeneratePom=true
-
Add this to your POM:
<repositories> <repository> <id>local-repo</id> <url>file://${project.basedir}/lib/</url> <releases> <enabled>true</enabled> </releases> </repository> </repositories>
-
Add this to your dependencies:
<dependency> <groupId>net.lecigne</groupId> <artifactId>somafm-recentlib</artifactId> <version>0.1.0</version> </dependency>
The functional tests are an experiment, under development. The goal is to execute them on a regular basis on a Raspberry Pi to check the lib's compatibility with the page it is parsing, and receive alerts in case of errors.