mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
made the secret creating part easy & documented
This commit is contained in:
parent
b157e389a9
commit
1d09eb451e
29
README.md
29
README.md
@ -158,13 +158,34 @@ Download the [Mac OS Disk Image (.dmg) file](https://github.com/KRTirtho/spotube
|
||||
- Install Development dependencies in linux
|
||||
- `libwebkit2gtk-4.0-dev`, `libkeybinder-3.0-0` & `libkeybinder-3.0-0-dev` (for Debian/Ubuntu)
|
||||
- `webkit2gtk` & `libkeybinder3` (for Arch/Manjaro)
|
||||
- Clone the Repo
|
||||
|
||||
- Clone the Repo & run
|
||||
```bash
|
||||
$ flutter pub get
|
||||
$ flutter run -d <window|macos|linux>
|
||||
```
|
||||
|
||||
- Create a `.env` file containing 2 secrets `LYRICS_SECRET` & `SPOTIFY_SECRET`. These secrets should be a **base64 encoded JSON string**
|
||||
- Structure of `LYRICS_SECRET` json string:
|
||||
```jsonc
|
||||
[
|
||||
"<secret genius access tokens>",
|
||||
// and so on...
|
||||
]
|
||||
```
|
||||
- Structure of `SPOTIFY_SECRET` json string:
|
||||
```jsonc
|
||||
[
|
||||
{"clientId": "<Spotify Client Id>", "clientSecret": "<Spotify Client Secret>"},
|
||||
// and so on ....
|
||||
]
|
||||
```
|
||||
> You can base64 encode the JSON [here](https://www.base64encode.org/)
|
||||
- Run following in the terminal to generate secrets for your fork
|
||||
```bash
|
||||
$ dart bin/create-secrets.dart --loadEnv
|
||||
```
|
||||
Finally, to start the app run:
|
||||
```bash
|
||||
$ flutter run -d <window|macos|linux|(android-device-id)>
|
||||
```
|
||||
# Things that don't work
|
||||
|
||||
- Shows & Podcasts aren't supported as it'd require premium anyway
|
||||
|
@ -2,16 +2,31 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:dotenv/dotenv.dart';
|
||||
|
||||
void main(List<String> args) async {
|
||||
String lyricSecret;
|
||||
String spotifySecret;
|
||||
|
||||
if (args.isEmpty) {
|
||||
throw ArgumentError(
|
||||
"Expected 2 arguments but passed ${args.length < 2 || args.length > 2 ? args.length : "none"}");
|
||||
throw ArgumentError("Expected 2 arguments but passed none");
|
||||
}
|
||||
if (args.contains("--loadEnv")) {
|
||||
load();
|
||||
if (env["SPOTIFY_SECRET"] == null || env["LYRICS_SECRET"] == null) {
|
||||
throw Exception(
|
||||
"'LYRICS_SECRET' or 'SPOTIFY_SECRET' environmental variable aren't set correctly ");
|
||||
}
|
||||
lyricSecret = env["LYRICS_SECRET"]!;
|
||||
spotifySecret = env["SPOTIFY_SECRET"]!;
|
||||
} else {
|
||||
lyricSecret = args.first;
|
||||
spotifySecret = args.last;
|
||||
}
|
||||
|
||||
final decodedSecret = utf8.decode(base64Decode(args.first));
|
||||
final decodedSpotifySecrete = utf8.decode(base64Decode(args.last));
|
||||
final val = jsonDecode(decodedSecret);
|
||||
final decodedLyricSecret = utf8.decode(base64Decode(lyricSecret));
|
||||
final decodedSpotifySecrete = utf8.decode(base64Decode(spotifySecret));
|
||||
final val = jsonDecode(decodedLyricSecret);
|
||||
final val2 = jsonDecode(decodedSpotifySecrete);
|
||||
if (val is! List || (val2 is! List && (val2 as List).first is! Map)) {
|
||||
throw Exception(
|
||||
@ -21,6 +36,6 @@ void main(List<String> args) async {
|
||||
await File(path.join(
|
||||
Directory.current.path, "lib/models/generated_secrets.dart"))
|
||||
.writeAsString(
|
||||
"final List<String> lyricsSecrets = $decodedSecret;\nfinal List<Map<String, dynamic>> spotifySecrets = $decodedSpotifySecrete;",
|
||||
"final List<String> lyricsSecrets = $decodedLyricSecret;\nfinal List<Map<String, dynamic>> spotifySecrets = $decodedSpotifySecrete;",
|
||||
);
|
||||
}
|
||||
|
@ -169,6 +169,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
dotenv:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: dotenv
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -70,6 +70,7 @@ dev_dependencies:
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^1.0.0
|
||||
flutter_launcher_icons: ^0.9.2
|
||||
dotenv: ^3.0.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
|
Loading…
Reference in New Issue
Block a user