mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 07:29:42 +00:00
Compare commits
5 Commits
b2ee5b2ec2
...
4794a27025
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4794a27025 | ||
|
|
59f298a935 | ||
|
|
ff252d6b14 | ||
|
|
195cad8f39 | ||
|
|
19f525fa3c |
@ -137,16 +137,16 @@
|
||||
"pre_download_play_description": "Anzi che effettuare lo stream dell'audio, scarica invece i byte e li riproduce (raccomandato per gli utenti con banda più alta)",
|
||||
"skip_non_music": "Salta i segmenti non di musica (SponsorBlock)",
|
||||
"blacklist_description": "Tracce e artisti in blacklist",
|
||||
"wait_for_download_to_finish": "Prego attendere che lo scaricamento corrente finisca",
|
||||
"wait_for_download_to_finish": "Prego attendere che il download corrente finisca",
|
||||
"desktop": "Desktop",
|
||||
"close_behavior": "Comportamento Chiusura",
|
||||
"close": "Chiudi",
|
||||
"minimize_to_tray": "Minimizza in tray",
|
||||
"show_tray_icon": "Mostra icona in tray di sistema",
|
||||
"about": "A proposito di",
|
||||
"about": "Informazioni su",
|
||||
"u_love_spotube": "Sappiamo che ami Spotube",
|
||||
"check_for_updates": "Controlla aggiornamenti",
|
||||
"about_spotube": "A proposito di Spotube",
|
||||
"about_spotube": "Informazioni su Spotube",
|
||||
"blacklist": "Blacklist",
|
||||
"please_sponsor": "Per favore sponsorizza/dona",
|
||||
"spotube_description": "Spotube, un client spotify gratis per tutti, multipiattaforma e leggero",
|
||||
@ -187,7 +187,7 @@
|
||||
"generate_playlist": "Genera Playlist",
|
||||
"track_exists": "La traccia {track} esiste già",
|
||||
"replace_downloaded_tracks": "Sostituisci tutte le tracce scaricate",
|
||||
"skip_download_tracks": "Salta lo scaricamento di tutte le tracce scaricate",
|
||||
"skip_download_tracks": "Salta il download di tutte le tracce scaricate",
|
||||
"do_you_want_to_replace": "Vuoi sovrascrivere la traccia esistente??",
|
||||
"replace": "Sovrascrivi",
|
||||
"skip": "Salta",
|
||||
@ -256,7 +256,7 @@
|
||||
"querying_info": "Richiesta informazioni...",
|
||||
"piped_api_down": "Le Piped API non funzionano",
|
||||
"piped_down_error_instructions": "L'istanza di Piped {pipedInstance} è correntemente offline\n\nCambia istanza o cambia 'Tipo API' alle API ufficiali YouTube\n\nAssicurati di riavviare l'app dopo il cambio",
|
||||
"you_are_offline": "Sei correntemente offline",
|
||||
"you_are_offline": "Al momento sei offline",
|
||||
"connection_restored": "Connessione ad internet ripristinata",
|
||||
"use_system_title_bar": "Usa la barra del titolo di sistema",
|
||||
"crunching_results": "Elaborazione risultati...",
|
||||
@ -267,15 +267,15 @@
|
||||
"change_cover": "Cambia copertina",
|
||||
"add_cover": "Aggiungi copertina",
|
||||
"restore_defaults": "Ripristina default",
|
||||
"download_music_codec": "Codec musicale scaricamento",
|
||||
"streaming_music_codec": "Codec musicale streaming",
|
||||
"login_with_lastfm": "Accesso a Last.fm",
|
||||
"connect": "Connetti",
|
||||
"disconnect_lastfm": "Disconnetti Last.fm",
|
||||
"download_music_codec": "Codec download musica",
|
||||
"streaming_music_codec": "Codec streaming musica",
|
||||
"login_with_lastfm": "Accedi con Last.fm",
|
||||
"connect": "Connettiti",
|
||||
"disconnect_lastfm": "Disconnettiti da Last.fm",
|
||||
"disconnect": "Disconnetti",
|
||||
"username": "Nome utente",
|
||||
"password": "Password",
|
||||
"login": "Accesso",
|
||||
"login": "Accedi",
|
||||
"login_with_your_lastfm": "Accedi con il tuo account Last.fm",
|
||||
"scrobble_to_lastfm": "Invia a Last.fm",
|
||||
"audio_source": "Fonte audio",
|
||||
@ -299,7 +299,7 @@
|
||||
"song_link": "Link della Canzone",
|
||||
"skip_this_nonsense": "Salta questa sciocchezza",
|
||||
"freedom_of_music": "“Libertà della Musica”",
|
||||
"freedom_of_music_palm": "“Libertà della Musica nel palmo della tua mano”",
|
||||
"freedom_of_music_palm": "“Libertà della Musica nelle tue mani”",
|
||||
"get_started": "Cominciamo",
|
||||
"youtube_source_description": "Consigliato e funziona meglio.",
|
||||
"piped_source_description": "Ti senti libero? Come YouTube ma molto più gratuito.",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
@ -15,6 +16,9 @@ import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/database/database.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:otp_util/otp_util.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:otp_util/src/utils/generic_util.dart';
|
||||
|
||||
extension ExpirationAuthenticationTableData on AuthenticationTableData {
|
||||
bool get isExpired => DateTime.now().isAfter(expiration);
|
||||
@ -100,6 +104,83 @@ class AuthenticationNotifier extends AsyncNotifier<AuthenticationTableData?> {
|
||||
.insert(refreshedCredentials, mode: InsertMode.replace);
|
||||
}
|
||||
|
||||
String base32FromBytes(Uint8List e, String secretSauce) {
|
||||
var t = 0;
|
||||
var n = 0;
|
||||
var r = "";
|
||||
for (int i = 0; i < e.length; i++) {
|
||||
n = n << 8 | e[i];
|
||||
t += 8;
|
||||
while (t >= 5) {
|
||||
r += secretSauce[n >>> t - 5 & 31];
|
||||
t -= 5;
|
||||
}
|
||||
}
|
||||
if (t > 0) {
|
||||
r += secretSauce[n << 5 - t & 31];
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
Uint8List cleanBuffer(String e) {
|
||||
e = e.replaceAll(" ", "");
|
||||
final t = List.filled(e.length ~/ 2, 0);
|
||||
final n = Uint8List.fromList(t);
|
||||
for (int r = 0; r < e.length; r += 2) {
|
||||
n[r ~/ 2] = int.parse(e.substring(r, r + 2), radix: 16);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
Future<String> generateTotp() async {
|
||||
const secretSauce = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
final secretCipherBytes = const [
|
||||
12,
|
||||
56,
|
||||
76,
|
||||
33,
|
||||
88,
|
||||
44,
|
||||
88,
|
||||
33,
|
||||
78,
|
||||
78,
|
||||
11,
|
||||
66,
|
||||
22,
|
||||
22,
|
||||
55,
|
||||
69,
|
||||
54
|
||||
].mapIndexed((t, e) => e ^ t % 33 + 9).toList();
|
||||
|
||||
final secretBytes = cleanBuffer(
|
||||
utf8
|
||||
.encode(secretCipherBytes.join(""))
|
||||
.map((e) => e.toRadixString(16))
|
||||
.join(),
|
||||
);
|
||||
|
||||
final secret = base32FromBytes(secretBytes, secretSauce);
|
||||
|
||||
final res = await dio.get("https://open.spotify.com/server-time");
|
||||
final serverTimeSeconds = res.data["serverTime"] as int;
|
||||
|
||||
final totp = TOTP(
|
||||
secret: secret,
|
||||
algorithm: OTPAlgorithm.SHA1,
|
||||
digits: 6,
|
||||
interval: 30,
|
||||
);
|
||||
|
||||
return totp.generateOTP(
|
||||
input: Util.timeFormat(
|
||||
time: DateTime.fromMillisecondsSinceEpoch(serverTimeSeconds * 1000),
|
||||
interval: 30,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<AuthenticationTableCompanion> credentialsFromCookie(
|
||||
String cookie,
|
||||
) async {
|
||||
@ -108,10 +189,17 @@ class AuthenticationNotifier extends AsyncNotifier<AuthenticationTableData?> {
|
||||
.split("; ")
|
||||
.firstWhereOrNull((c) => c.trim().startsWith("sp_dc="))
|
||||
?.trim();
|
||||
|
||||
final totp = await generateTotp();
|
||||
final timestamp = (DateTime.now().millisecondsSinceEpoch / 1000).floor();
|
||||
|
||||
final accessTokenUrl = Uri.parse(
|
||||
"https://open.spotify.com/get_access_token?reason=transport&productType=web_player"
|
||||
"&totp=$totp&totpVer=5&ts=$timestamp",
|
||||
);
|
||||
|
||||
final res = await dio.getUri(
|
||||
Uri.parse(
|
||||
"https://open.spotify.com/get_access_token?reason=transport&productType=web_player",
|
||||
),
|
||||
accessTokenUrl,
|
||||
options: Options(
|
||||
headers: {
|
||||
"Cookie": spDc ?? "",
|
||||
|
||||
18
pubspec.lock
18
pubspec.lock
@ -166,6 +166,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
base32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: base32
|
||||
sha256: ddad4ebfedf93d4500818ed8e61443b734ffe7cf8a45c668c9b34ef6adde02e2
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
bonsoir:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -440,7 +448,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.3.4+2"
|
||||
crypto:
|
||||
dependency: "direct dev"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
|
||||
@ -1639,6 +1647,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.3"
|
||||
otp_util:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: otp_util
|
||||
sha256: dd8956c6472bacc3ffabe62c03f8a9782d1e5a5a3f2674420970f549d642b1cf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -140,10 +140,10 @@ dependencies:
|
||||
url: https://github.com/KRTirtho/flutter_new_pipe_extractor.git
|
||||
http_parser: ^4.1.2
|
||||
collection: any
|
||||
otp_util: ^1.0.2
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.4.13
|
||||
crypto: ^3.0.3
|
||||
envied_generator: ^1.0.0
|
||||
flutter_gen_runner: ^5.4.0
|
||||
flutter_launcher_icons: ^0.14.2
|
||||
|
||||
Loading…
Reference in New Issue
Block a user