mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
Compare commits
5 Commits
fc9e9f8f4c
...
4459bc16c5
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4459bc16c5 | ||
![]() |
ea329f40e8 | ||
![]() |
ff252d6b14 | ||
![]() |
195cad8f39 | ||
![]() |
19f525fa3c |
@ -60,8 +60,8 @@ class TrackDetailsDialog extends HookConsumerWidget {
|
||||
context.l10n.channel: Text(sourceInfo.artists),
|
||||
if (sourcedTrack.asData?.value.url != null)
|
||||
context.l10n.streamUrl: Hyperlink(
|
||||
sourcedTrack.asData!.value.url,
|
||||
sourcedTrack.asData!.value.url,
|
||||
sourcedTrack.asData!.value.url ?? "",
|
||||
sourcedTrack.asData!.value.url ?? "",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
@ -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.",
|
||||
|
@ -130,7 +130,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
download.status.value == DownloadStatus.queued,
|
||||
)
|
||||
.map((e) => e.request.url)
|
||||
.contains(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||
.contains(sourcedTrack.getUrlOfCodec(downloadCodec)!);
|
||||
}
|
||||
|
||||
/// For singular downloads
|
||||
@ -152,7 +152,9 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
|
||||
if (sourcedTrack.codec == downloadCodec) {
|
||||
final downloadTask = await dl.addDownload(
|
||||
sourcedTrack.getUrlOfCodec(downloadCodec), savePath);
|
||||
sourcedTrack.getUrlOfCodec(downloadCodec)!,
|
||||
savePath,
|
||||
);
|
||||
if (downloadTask != null) {
|
||||
$history.add(sourcedTrack);
|
||||
}
|
||||
@ -169,7 +171,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
return d;
|
||||
});
|
||||
final downloadTask = await dl.addDownload(
|
||||
sourcedTrack.getUrlOfCodec(downloadCodec),
|
||||
sourcedTrack.getUrlOfCodec(downloadCodec)!,
|
||||
savePath,
|
||||
);
|
||||
if (downloadTask != null) {
|
||||
@ -202,18 +204,18 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
|
||||
Future<void> removeFromQueue(SpotubeFullTrackObject track) async {
|
||||
final sourcedTrack = await mapToSourcedTrack(track);
|
||||
await dl.removeDownload(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||
await dl.removeDownload(sourcedTrack.getUrlOfCodec(downloadCodec)!);
|
||||
$history.remove(sourcedTrack);
|
||||
}
|
||||
|
||||
Future<void> pause(SpotubeFullTrackObject track) async {
|
||||
final sourcedTrack = await mapToSourcedTrack(track);
|
||||
return dl.pauseDownload(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||
return dl.pauseDownload(sourcedTrack.getUrlOfCodec(downloadCodec)!);
|
||||
}
|
||||
|
||||
Future<void> resume(SpotubeFullTrackObject track) async {
|
||||
final sourcedTrack = await mapToSourcedTrack(track);
|
||||
return dl.resumeDownload(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||
return dl.resumeDownload(sourcedTrack.getUrlOfCodec(downloadCodec)!);
|
||||
}
|
||||
|
||||
Future<void> retry(SpotubeFullTrackObject track) {
|
||||
@ -222,7 +224,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
|
||||
void cancel(SpotubeFullTrackObject track) async {
|
||||
final sourcedTrack = await mapToSourcedTrack(track);
|
||||
return dl.cancelDownload(sourcedTrack.getUrlOfCodec(downloadCodec));
|
||||
return dl.cancelDownload(sourcedTrack.getUrlOfCodec(downloadCodec)!);
|
||||
}
|
||||
|
||||
void cancelAll() {
|
||||
@ -256,7 +258,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
if (sourcedTrack == null) {
|
||||
return null;
|
||||
}
|
||||
return dl.getDownload(sourcedTrack.getUrlOfCodec(downloadCodec))?.status;
|
||||
return dl.getDownload(sourcedTrack.getUrlOfCodec(downloadCodec)!)?.status;
|
||||
}
|
||||
|
||||
ValueNotifier<double>? getProgressNotifier(SpotubeFullTrackObject track) {
|
||||
@ -266,7 +268,7 @@ class DownloadManagerProvider extends ChangeNotifier {
|
||||
if (sourcedTrack == null) {
|
||||
return null;
|
||||
}
|
||||
return dl.getDownload(sourcedTrack.getUrlOfCodec(downloadCodec))?.progress;
|
||||
return dl.getDownload(sourcedTrack.getUrlOfCodec(downloadCodec)!)?.progress;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,13 +61,20 @@ class ServerPlaybackRoutes {
|
||||
);
|
||||
final trackPartialCacheFile = File("${trackCacheFile.path}.part");
|
||||
|
||||
String? url = track.url;
|
||||
|
||||
url ??= await ref
|
||||
.read(trackSourcesProvider(track.query).notifier)
|
||||
.swapWithNextSibling()
|
||||
.then((track) => track.url!);
|
||||
|
||||
var options = Options(
|
||||
headers: {
|
||||
...headers,
|
||||
"user-agent": _randomUserAgent,
|
||||
"Cache-Control": "max-age=3600",
|
||||
"Connection": "keep-alive",
|
||||
"host": Uri.parse(track.url).host,
|
||||
"host": Uri.parse(url!).host,
|
||||
},
|
||||
responseType: ResponseType.bytes,
|
||||
validateStatus: (status) => status! < 400,
|
||||
@ -75,7 +82,7 @@ class ServerPlaybackRoutes {
|
||||
|
||||
final headersRes = await Future<dio_lib.Response?>.value(
|
||||
dio.head(
|
||||
track.url,
|
||||
url,
|
||||
options: options,
|
||||
),
|
||||
).catchError((_) async => null);
|
||||
@ -95,7 +102,7 @@ class ServerPlaybackRoutes {
|
||||
"accept-ranges": ["bytes"],
|
||||
"content-range": ["bytes 0-$cachedFileLength/$cachedFileLength"],
|
||||
}),
|
||||
requestOptions: RequestOptions(path: track.url),
|
||||
requestOptions: RequestOptions(path: url),
|
||||
),
|
||||
bytes: bytes,
|
||||
);
|
||||
@ -118,7 +125,7 @@ class ServerPlaybackRoutes {
|
||||
|
||||
final res = await dio
|
||||
.get<Uint8List>(
|
||||
track.url,
|
||||
url,
|
||||
options: options.copyWith(headers: {
|
||||
...?options.headers,
|
||||
"user-agent": _randomUserAgent,
|
||||
@ -136,7 +143,7 @@ class ServerPlaybackRoutes {
|
||||
// }
|
||||
|
||||
return await dio.get<Uint8List>(
|
||||
sourcedTrack.url,
|
||||
sourcedTrack.url!,
|
||||
options: options.copyWith(headers: {
|
||||
...?options.headers,
|
||||
"user-agent": _randomUserAgent,
|
||||
|
@ -34,6 +34,12 @@ class TrackSourcesNotifier
|
||||
return await prev.swapWithSibling(sibling) ?? prev;
|
||||
});
|
||||
}
|
||||
|
||||
Future<SourcedTrack> swapWithNextSibling() async {
|
||||
return await update((prev) async {
|
||||
return await prev.swapWithSibling(prev.siblings.first) as SourcedTrack;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
final trackSourcesProvider = AsyncNotifierProviderFamily<TrackSourcesNotifier,
|
||||
|
@ -141,7 +141,7 @@ abstract class SourcedTrack extends BasicSourcedTrack {
|
||||
}
|
||||
|
||||
Future<SourcedTrack> refreshStream();
|
||||
String get url {
|
||||
String? get url {
|
||||
final preferences = ref.read(userPreferencesProvider);
|
||||
|
||||
final codec = preferences.audioSource == AudioSource.jiosaavn
|
||||
@ -157,7 +157,7 @@ abstract class SourcedTrack extends BasicSourcedTrack {
|
||||
///
|
||||
/// If no sources match the codec, it will return the first or last source
|
||||
/// based on the user's audio quality preference.
|
||||
String getUrlOfCodec(SourceCodecs codec) {
|
||||
String? getUrlOfCodec(SourceCodecs codec) {
|
||||
final preferences = ref.read(userPreferencesProvider);
|
||||
|
||||
final exactMatch = sources.firstWhereOrNull(
|
||||
@ -191,8 +191,8 @@ abstract class SourcedTrack extends BasicSourcedTrack {
|
||||
});
|
||||
|
||||
return preferences.audioQuality != SourceQualities.low
|
||||
? fallbackSource.first.url
|
||||
: fallbackSource.last.url;
|
||||
? fallbackSource.firstOrNull?.url
|
||||
: fallbackSource.lastOrNull?.url;
|
||||
}
|
||||
|
||||
SourceCodecs get codec {
|
||||
|
@ -204,6 +204,8 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
||||
AppLogger.log
|
||||
.d("${track.title} ISRC $isrc Total ${searchedVideos.length}");
|
||||
|
||||
final stringBuffer = StringBuffer();
|
||||
|
||||
final filteredMatches = searchedVideos
|
||||
.map<YoutubeVideoInfo>(YoutubeVideoInfo.fromVideo)
|
||||
.map((YoutubeVideoInfo videoInfo) {
|
||||
@ -224,6 +226,10 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
||||
.abs()
|
||||
.inMilliseconds <=
|
||||
3000) {
|
||||
stringBuffer.writeln(
|
||||
"ISRC MATCH: ${videoInfo.id} ${videoInfo.title} by ${videoInfo.channelName} ${videoInfo.duration}",
|
||||
);
|
||||
|
||||
return videoInfo;
|
||||
}
|
||||
return null;
|
||||
@ -231,11 +237,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
||||
.nonNulls
|
||||
.toList();
|
||||
|
||||
for (final match in filteredMatches) {
|
||||
AppLogger.log.d(
|
||||
"ISRC MATCH: ${match.id} ${match.title} by ${match.channelName} ${match.duration}",
|
||||
);
|
||||
}
|
||||
AppLogger.log.d(stringBuffer.toString());
|
||||
|
||||
isrcResults.addAll(filteredMatches);
|
||||
}
|
||||
@ -262,9 +264,16 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
||||
|
||||
final links = await SongLinkService.links(query.id);
|
||||
|
||||
for (final link in links) {
|
||||
AppLogger.log.d("SongLink ${query.id} ${link.platform} ${link.url}");
|
||||
}
|
||||
final stringBuffer = links.fold(
|
||||
StringBuffer(),
|
||||
(previousValue, element) {
|
||||
previousValue.writeln(
|
||||
"SongLink ${query.id} ${element.platform} ${element.url}");
|
||||
return previousValue;
|
||||
},
|
||||
);
|
||||
|
||||
AppLogger.log.d(stringBuffer.toString());
|
||||
|
||||
final ytLink = links.firstWhereOrNull(
|
||||
(link) => link.platform == "youtube",
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:spotube/services/dio/dio.dart';
|
||||
import 'package:spotube/services/logger/logger.dart';
|
||||
import 'package:spotube/services/youtube_engine/youtube_engine.dart';
|
||||
@ -60,6 +61,7 @@ class IsolatedYoutubeExplode {
|
||||
static void _isolateEntry(SendPort mainSendPort) {
|
||||
final receivePort = ReceivePort();
|
||||
final youtubeExplode = YoutubeExplode();
|
||||
final stopWatch = kDebugMode ? Stopwatch() : null;
|
||||
|
||||
/// Send the main port to the main isolate
|
||||
mainSendPort.send(receivePort.sendPort);
|
||||
@ -69,6 +71,19 @@ class IsolatedYoutubeExplode {
|
||||
final String methodName = message[1];
|
||||
final List<dynamic> arguments = message[2];
|
||||
|
||||
if (stopWatch != null) {
|
||||
if (stopWatch.isRunning) {
|
||||
stopWatch.stop();
|
||||
final symbol = stopWatch.elapsedMilliseconds < 1000 ? "⚠️" : "⏱️";
|
||||
debugPrint(
|
||||
"$symbol YoutubeExplode operation gap ${stopWatch.elapsedMilliseconds} ms",
|
||||
);
|
||||
stopWatch.reset();
|
||||
} else {
|
||||
stopWatch.start();
|
||||
}
|
||||
}
|
||||
|
||||
// Run the requested method on YoutubeExplode
|
||||
var result = switch (methodName) {
|
||||
"search" => youtubeExplode.search
|
||||
@ -156,6 +171,7 @@ class YouTubeExplodeEngine implements YouTubeEngine {
|
||||
);
|
||||
|
||||
final accessibleStreams = <AudioOnlyStreamInfo>[];
|
||||
final stringBuffer = StringBuffer();
|
||||
|
||||
for (final stream in streamManifest.audioOnly) {
|
||||
// Call dio head request to check if the stream is accessible
|
||||
@ -169,7 +185,7 @@ class YouTubeExplodeEngine implements YouTubeEngine {
|
||||
),
|
||||
);
|
||||
|
||||
AppLogger.log.d(
|
||||
stringBuffer.writeln(
|
||||
"Stream $videoId Status ${response.statusCode} Codec ${stream.audioCodec} "
|
||||
"Bitrate ${stream.bitrate} Container ${stream.container}",
|
||||
);
|
||||
@ -199,6 +215,8 @@ class YouTubeExplodeEngine implements YouTubeEngine {
|
||||
}
|
||||
}
|
||||
|
||||
AppLogger.log.d(stringBuffer.toString());
|
||||
|
||||
return StreamManifest(accessibleStreams);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user