mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 07:29:42 +00:00
Compare commits
7 Commits
4794a27025
...
ec66cd8b8b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec66cd8b8b | ||
|
|
95e09ffc94 | ||
|
|
968fd09eb3 | ||
|
|
1a32264bc7 | ||
|
|
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.",
|
||||
|
||||
@ -5,7 +5,7 @@ import 'dart:io';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:dio/io.dart';
|
||||
import 'package:dio_http2_adapter/dio_http2_adapter.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart'
|
||||
hide X509Certificate;
|
||||
@ -19,6 +19,7 @@ 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';
|
||||
import 'package:spotube/utils/service_utils.dart';
|
||||
|
||||
extension ExpirationAuthenticationTableData on AuthenticationTableData {
|
||||
bool get isExpired => DateTime.now().isAfter(expiration);
|
||||
@ -34,13 +35,17 @@ extension ExpirationAuthenticationTableData on AuthenticationTableData {
|
||||
|
||||
class AuthenticationNotifier extends AsyncNotifier<AuthenticationTableData?> {
|
||||
static final Dio dio = () {
|
||||
final dio = Dio();
|
||||
|
||||
(dio.httpClientAdapter as IOHttpClientAdapter)
|
||||
.createHttpClient = () => HttpClient()
|
||||
..badCertificateCallback = (X509Certificate cert, String host, int port) {
|
||||
return host.endsWith("spotify.com") && port == 443;
|
||||
};
|
||||
final dio = Dio()
|
||||
..httpClientAdapter = Http2Adapter(
|
||||
ConnectionManager(
|
||||
idleTimeout: const Duration(seconds: 10),
|
||||
onClientCreate: (uri, clientSettings) {
|
||||
clientSettings.onBadCertificate = (X509Certificate cert) {
|
||||
return uri.host.endsWith("spotify.com");
|
||||
};
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return dio;
|
||||
}();
|
||||
@ -163,7 +168,18 @@ class AuthenticationNotifier extends AsyncNotifier<AuthenticationTableData?> {
|
||||
|
||||
final secret = base32FromBytes(secretBytes, secretSauce);
|
||||
|
||||
final res = await dio.get("https://open.spotify.com/server-time");
|
||||
final res = await dio.get(
|
||||
"https://open.spotify.com/server-time",
|
||||
options: Options(
|
||||
headers: {
|
||||
"Host": "open.spotify.com",
|
||||
"User-Agent": ServiceUtils.randomUserAgent(
|
||||
kIsDesktop ? UserAgentDevice.desktop : UserAgentDevice.mobile,
|
||||
),
|
||||
"accept": "*/*",
|
||||
},
|
||||
),
|
||||
);
|
||||
final serverTimeSeconds = res.data["serverTime"] as int;
|
||||
|
||||
final totp = TOTP(
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
||||
|
||||
@ -28,6 +28,11 @@ import 'package:spotube/collections/env.dart';
|
||||
|
||||
import 'package:version/version.dart';
|
||||
|
||||
enum UserAgentDevice {
|
||||
desktop,
|
||||
mobile,
|
||||
}
|
||||
|
||||
abstract class ServiceUtils {
|
||||
static final _englishMatcherRegex = RegExp(
|
||||
"^[a-zA-Z0-9\\s!\"#\$%&\\'()*+,-.\\/:;<=>?@\\[\\]^_`{|}~]*\$",
|
||||
@ -417,4 +422,16 @@ abstract class ServiceUtils {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static int randomNumber(int min, int max) {
|
||||
return min + Random().nextInt(max - min);
|
||||
}
|
||||
|
||||
static String randomUserAgent(UserAgentDevice type) {
|
||||
if (type == UserAgentDevice.desktop) {
|
||||
return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_${randomNumber(11, 15)}_${randomNumber(4, 9)}) AppleWebKit/${randomNumber(530, 537)}.${randomNumber(30, 37)} (KHTML, like Gecko) Chrome/${randomNumber(80, 105)}.0.${randomNumber(3000, 4500)}.${randomNumber(60, 125)} Safari/${randomNumber(530, 537)}.${randomNumber(30, 36)}";
|
||||
} else {
|
||||
return "Mozilla/5.0 (Linux; Android ${randomNumber(8, 13)}) AppleWebKit/${randomNumber(530, 537)}.${randomNumber(30, 36)} (KHTML, like Gecko) Chrome/${randomNumber(101, 116)}.0.${randomNumber(3000, 6000)}.${randomNumber(60, 125)} Mobile Safari/${randomNumber(530, 537)}.${randomNumber(30, 36)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
16
pubspec.lock
16
pubspec.lock
@ -544,6 +544,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.7.0"
|
||||
dio_http2_adapter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dio_http2_adapter
|
||||
sha256: b8bd5d587fd228a461711f8b82f378ccd4bf1fbf7802e7663ca60d7b5ce0e3aa
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
dio_web_adapter:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1186,6 +1194,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.2"
|
||||
http2:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http2
|
||||
sha256: "382d3aefc5bd6dc68c6b892d7664f29b5beb3251611ae946a98d35158a82bbfa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
http_methods:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -141,6 +141,7 @@ dependencies:
|
||||
http_parser: ^4.1.2
|
||||
collection: any
|
||||
otp_util: ^1.0.2
|
||||
dio_http2_adapter: ^2.6.0
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.4.13
|
||||
|
||||
Loading…
Reference in New Issue
Block a user