-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init with support for models and album endpoint
- Loading branch information
0 parents
commit f5acede
Showing
30 changed files
with
2,996 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# The .vscode folder contains launch configuration and tasks you configure in | ||
# VS Code which you may wish to be included in version control, so this line | ||
# is commented out by default. | ||
#.vscode/ | ||
|
||
# Flutter/Dart/Pub related | ||
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
/pubspec.lock | ||
**/doc/api/ | ||
.dart_tool/ | ||
.packages | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file tracks properties of this Flutter project. | ||
# Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
# | ||
# This file should be version controlled and should not be manually edited. | ||
|
||
version: | ||
revision: "ff5b5b5fa6f35b717667719ddfdb1521d8bdd05a" | ||
channel: "stable" | ||
|
||
project_type: package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: Add your license here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!-- | ||
This README describes the package. If you publish this package to pub.dev, | ||
this README's contents appear on the landing page for your package. | ||
For information about how to write a good package README, see the guide for | ||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). | ||
For general information about developing packages, see the Dart guide for | ||
[creating packages](https://dart.dev/guides/libraries/create-library-packages) | ||
and the Flutter guide for | ||
[developing packages and plugins](https://flutter.dev/developing-packages). | ||
--> | ||
|
||
TODO: Put a short description of the package here that helps potential users | ||
know whether this package might be useful for them. | ||
|
||
## Features | ||
|
||
TODO: List what your package can do. Maybe include images, gifs, or videos. | ||
|
||
## Getting started | ||
|
||
TODO: List prerequisites and provide or point to information on how to | ||
start using the package. | ||
|
||
## Usage | ||
|
||
TODO: Include short and useful examples for package users. Add longer examples | ||
to `/example` folder. | ||
|
||
```dart | ||
const like = 'sample'; | ||
``` | ||
|
||
## Additional information | ||
|
||
TODO: Tell users more about the package: where to find more information, how to | ||
contribute to the package, how to file issues, what response they can expect | ||
from the package authors, and more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
# Additional information about this file can be found at | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
library jiosaavn; | ||
|
||
export 'src/jiosaavn.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:dio/dio.dart'; | ||
|
||
abstract class BaseClient { | ||
final BaseOptions? options; | ||
final Dio dio; | ||
BaseClient([this.options]) | ||
: dio = Dio( | ||
options ?? | ||
BaseOptions( | ||
baseUrl: 'https://www.jiosaavn.com/api.php', | ||
queryParameters: { | ||
'_format': 'json', | ||
'_marker': '0', | ||
'ctx': 'wap6dot0', | ||
}, | ||
responseType: ResponseType.json, | ||
), | ||
); | ||
|
||
Future<Map<String, dynamic>> request({ | ||
/// Use [endpoints] from [lib/collection/endpoints.dart] | ||
required String call, | ||
bool isAPIv4 = false, | ||
String language = 'english', | ||
Map<String, dynamic>? queryParameters, | ||
}) async { | ||
final res = await dio.get( | ||
"/", | ||
queryParameters: { | ||
if (isAPIv4) 'api_version': 4, | ||
'__call': call, | ||
...?queryParameters, | ||
}, | ||
options: Options( | ||
headers: { | ||
"cookie": | ||
'L=${Uri.encodeComponent(language)}; gdpr_acceptance=true; DL=english', | ||
}, | ||
), | ||
); | ||
|
||
return jsonDecode(res.data) as Map<String, dynamic>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const endpoints = ( | ||
modules: 'content.getBrowseModules', | ||
search: ( | ||
all: 'autocomplete.get', | ||
songs: 'search.getResults', | ||
albums: 'search.getAlbumResults', | ||
artists: 'search.getArtistResults', | ||
playlists: 'search.getPlaylistResults', | ||
), | ||
songs: (id: 'song.getDetails',), | ||
albums: (id: 'content.getAlbumDetails',), | ||
playlists: (id: 'playlist.getDetails',), | ||
artists: ( | ||
id: 'artist.getArtistPageDetails', | ||
songs: 'artist.getArtistMoreSong', | ||
albums: 'artist.getArtistMoreAlbum', | ||
topSongs: 'search.artistOtherTopSongs', | ||
), | ||
lyrics: 'lyrics.getLyrics', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:jiosaavn/src/client.dart'; | ||
import 'package:jiosaavn/src/collection/endpoints.dart'; | ||
import 'package:jiosaavn/src/models/album.dart'; | ||
|
||
class AlbumEndpoint extends BaseClient { | ||
AlbumEndpoint([super.options]); | ||
|
||
Future<AlbumResponse> detailsById(String id) async { | ||
// api v4 does not contain media_preview_url | ||
final response = await request(call: endpoints.albums.id, queryParameters: { | ||
'albumid': id, | ||
}); | ||
|
||
final albumResults = | ||
AlbumResponse.fromAlbumRequest(AlbumRequest.fromJson(response)); | ||
|
||
return albumResults; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import 'package:jiosaavn/src/client.dart'; | ||
|
||
class SearchEndpoint extends BaseClient { | ||
SearchEndpoint([super.options]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:jiosaavn/src/endpoints/album.dart'; | ||
|
||
class JioSaavnClient { | ||
final AlbumEndpoint albums; | ||
|
||
JioSaavnClient([BaseOptions? options]) : albums = AlbumEndpoint(options); | ||
} |
Oops, something went wrong.