jiosaavn_dart 1.0.0
jiosaavn_dart: ^1.0.0 copied to clipboard
A powerful Dart wrapper for JioSaavn, allowing developers to search songs, fetch albums and playlists, access lyrics, and decrypt media URLs effortlessly for seamless integration in music apps.
JioSaavn Dart API Wrapper #
JioSaavn Dart is a powerful and user-friendly Dart library designed to provide seamless access to JioSaavn's vast music catalog. This library allows developers to easily search for songs, retrieve detailed song information, fetch album and playlist data, and even access song lyrics, all through a clean and intuitive Dart API.
Project Description #
In the realm of digital music streaming, accessing and integrating with content providers is a common requirement for developers building music-related applications. JioSaavn offers a rich library of music, and jiosaavn_dart bridges the gap by providing a robust Dart wrapper around its unofficial API.
This library simplifies the process of interacting with JioSaavn data. Instead of dealing with complex network requests, data parsing, and potential API changes, developers can leverage jiosaavn_dart to perform these operations with straightforward function calls. Whether you're building a recommendation engine, a music player, a playlist manager, or any application that benefits from a diverse music library, jiosaavn_dart empowers you to integrate JioSaavn's content efficiently and effectively.
The library handles the intricacies of fetching song details, including decrypting media URLs, retrieving lyrics, and parsing responses for albums and playlists, allowing you to focus on the unique features of your application.
Installation #
To get started with jiosaavn_dart, you need to add it to your Dart project's dependencies.
-
Add to
pubspec.yaml:Open your
pubspec.yamlfile and add the following underdependencies:dependencies: jiosaavn_dart: ^1.0.0 -
Run
dart pub get:After saving
pubspec.yaml, run the following command in your terminal in the project's root directory:dart pub get
Usage Examples #
Here's how you can start using jiosaavn_dart in your project:
Searching for Songs #
import 'package:jiosaavn_dart/jiosaavn_dart.dart';
void main() async {
final JioSaavnApi api = JioSaavnApi();
try {
// Search for songs related to the query "hindi"
final List<Song> songs = await api.searchSong("hindi");
if (songs.isNotEmpty) {
print("Found ${songs.length} songs:");
for (var song in songs) {
print("- ${song.song} by ${song.primaryArtists} (Album: ${song.album})");
// You can also access song.mediaUrl, song.lyrics, etc.
}
} else {
print("No songs found for the query.");
}
} catch (e) {
print("An error occurred: $e");
}
}
Fetching Song Details by ID #
import 'package:jiosaavn_dart/jiosaavn_dart.dart';
void main() async {
final JioSaavnApi api = JioSaavnApi();
final String songId = 'your_song_id_here'; // Replace with an actual song ID
try {
final Song? song = await api.getSongFromId(songId, fetchLyrics: true);
if (song != null) {
print("Song Title: ${song.song}");
print("Artist(s): ${song.primaryArtists}");
print("Album: ${song.album}");
print("Media URL: ${song.mediaUrl}");
if (song.lyrics != null) {
print("Lyrics:\n${song.lyrics}");
} else {
print("Lyrics not available.");
}
} else {
print("Song with ID $songId not found.");
}
} catch (e) {
print("An error occurred: $e");
}
}
Fetching Album Details by ID #
import 'package:jiosaavn_dart/jiosaavn_dart.dart';
void main() async {
final JioSaavnApi api = JioSaavnApi();
final String albumId = 'your_album_id_here'; // Replace with an actual album ID
try {
final Album? album = await api.getAlbumFromId(albumId, fetchLyrics: true);
if (album != null) {
print("Album Title: ${album.title}");
print("Primary Artists: ${album.primaryArtists}");
print("Year: ${album.year}");
print("Songs in Album:");
for (var song in album.songs) {
print("- ${song.song}");
}
} else {
print("Album with ID $albumId not found.");
}
} catch (e) {
print("An error occurred: $e");
}
}
Fetching Playlist Details by ID #
import 'package:jiosaavn_dart/jiosaavn_dart.dart';
void main() async {
final JioSaavnApi api = JioSaavnApi();
final String playlistId = 'your_playlist_id_here'; // Replace with an actual playlist ID
try {
final Playlist? playlist = await api.getPlaylistFromId(playlistId, fetchLyrics: true);
if (playlist != null) {
print("Playlist Name: ${playlist.listname}");
print("Created By: ${playlist.firstname}");
print("Songs in Playlist:");
for (var song in playlist.songs) {
print("- ${song.song}");
}
} else {
print("Playlist with ID $playlistId not found.");
}
} catch (e) {
print("An error occurred: $e");
}
}
Key Features #
- Song Search: Easily find songs by keyword queries.
- Song Details: Retrieve comprehensive information about a specific song, including artists, album, and more.
- Media URL Decryption: Automatically handles the decryption of media URLs, providing direct access to song playback links.
- Lyrics Fetching: Obtain lyrics for songs where available.
- Album Information: Fetch details of an album, including its tracklist.
- Playlist Data: Retrieve information about playlists, such as their name and the songs they contain.
- Model Representation: Provides well-defined Dart models (
Song,Album,Playlist) for structured data access. - Error Handling: Basic error handling to gracefully manage potential network or data retrieval issues.
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing & Community #
We're thrilled you're considering contributing to jiosaavn_dart! This project is built with the intention of being a reliable and accessible tool for the Dart community. We believe in making it easier for developers to integrate music data into their applications, and your contributions can help us achieve that goal even further.
Whether you're fixing bugs, improving existing features, adding new capabilities, or even just suggesting enhancements, your input is highly valued. We aim for a welcoming and collaborative environment, so please don't hesitate to open an issue or submit a pull request. Let's build something awesome together!
Notes for Developers #
- API Stability: This library relies on the unofficial JioSaavn API. While efforts have been made to ensure robustness, API changes on JioSaavn's end could potentially affect the library's functionality. Please report any unexpected behavior.
- Dependency Management: Ensure you keep your
dioanddart_desdependencies updated to their latest compatible versions for optimal performance and security. - Error Handling: While the library includes some error handling, it's recommended to implement comprehensive error management in your application logic when making API calls.
- Rate Limiting: Be mindful of potential rate limits on the JioSaavn API. Implement appropriate delays or caching strategies in your application if you are making a large number of requests.