diff --git a/lib/services/connectivity_adapter.dart b/lib/services/connectivity_adapter.dart index 478890df..f6b760c8 100644 --- a/lib/services/connectivity_adapter.dart +++ b/lib/services/connectivity_adapter.dart @@ -20,6 +20,7 @@ class ConnectionCheckerService with WidgetsBindingObserver { onConnectivityChanged.listen((connected) { try { if (!connected && timer == null) { + // check every 30 seconds if we are connected when we are not connected timer = Timer.periodic(const Duration(seconds: 30), (timer) async { if (WidgetsBinding.instance.lifecycleState == AppLifecycleState.paused) { @@ -111,7 +112,7 @@ class ConnectionCheckerService with WidgetsBindingObserver { await isVpnActive(); // when VPN is active that means we are connected } - bool isConnectedSync = false; + bool isConnectedSync = true; Future get isConnected async { final connected = await _isConnected(); diff --git a/lib/services/logger/logger.dart b/lib/services/logger/logger.dart index 1df7b5aa..46fc6de5 100644 --- a/lib/services/logger/logger.dart +++ b/lib/services/logger/logger.dart @@ -9,6 +9,20 @@ import 'package:logger/logger.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; import 'package:spotube/utils/platform.dart'; +import 'package:logging/logging.dart' as logging; + +final _loggingToLoggerLevel = { + logging.Level.ALL: Level.all, + logging.Level.FINEST: Level.trace, + logging.Level.FINER: Level.debug, + logging.Level.FINE: Level.info, + logging.Level.CONFIG: Level.info, + logging.Level.INFO: Level.info, + logging.Level.WARNING: Level.warning, + logging.Level.SEVERE: Level.error, + logging.Level.SHOUT: Level.fatal, + logging.Level.OFF: Level.off, +}; class AppLogger { static late final Logger log; @@ -20,6 +34,24 @@ class AppLogger { ); } + static void _initInternalPackageLoggers() { + if (!kDebugMode) return; + logging.hierarchicalLoggingEnabled = true; + logging.Logger('YoutubeExplode.StreamsClient') + ..level = logging.Level.ALL + ..onRecord.listen( + (record) { + log.log( + _loggingToLoggerLevel[record.level] ?? Level.info, + record.message, + error: record.error, + stackTrace: record.stackTrace, + time: record.time, + ); + }, + ); + } + static R? runZoned(R Function() body) { return runZonedGuarded( () { @@ -46,6 +78,8 @@ class AppLogger { ); } + _initInternalPackageLoggers(); + getLogsPath().then((value) => logFile = value); return body(); diff --git a/lib/services/sourced_track/sources/youtube.dart b/lib/services/sourced_track/sources/youtube.dart index 1bafb705..fa13a25d 100644 --- a/lib/services/sourced_track/sources/youtube.dart +++ b/lib/services/sourced_track/sources/youtube.dart @@ -85,7 +85,13 @@ class YoutubeSourcedTrack extends SourcedTrack { final manifest = await youtubeClient.videos.streamsClient.getManifest( cachedSource.sourceId, requireWatchPage: false, - ytClients: [YoutubeApiClient.tv], + ytClients: [ + YoutubeApiClient.mediaConnect, + YoutubeApiClient.ios, + YoutubeApiClient.android, + YoutubeApiClient.mweb, + YoutubeApiClient.tv, + ], ); return YoutubeSourcedTrack( ref: ref, @@ -138,11 +144,17 @@ class YoutubeSourcedTrack extends SourcedTrack { ) async { SourceMap? sourceMap; if (index == 0) { - final manifest = - await youtubeClient.videos.streamsClient.getManifest(item.id).timeout( - const Duration(seconds: 5), - onTimeout: () => throw ClientException("Timeout"), - ); + final manifest = await youtubeClient.videos.streamsClient.getManifest( + item.id, + requireWatchPage: false, + ytClients: [ + YoutubeApiClient.mediaConnect, + YoutubeApiClient.ios, + YoutubeApiClient.android, + YoutubeApiClient.mweb, + YoutubeApiClient.tv, + ], + ); sourceMap = toSourceMap(manifest); } diff --git a/pubspec.lock b/pubspec.lock index 09bc1361..1a35f9c9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1423,7 +1423,7 @@ packages: source: hosted version: "2.5.0" logging: - dependency: transitive + dependency: "direct main" description: name: logging sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 diff --git a/pubspec.yaml b/pubspec.yaml index b9e44021..ed0d7ce5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -86,6 +86,7 @@ dependencies: json_annotation: ^4.8.1 local_notifier: ^0.1.6 logger: ^2.0.2 + logging: ^1.3.0 lrc: ^1.0.2 media_kit: ^1.1.10+1 media_kit_libs_audio: ^1.0.4