mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
fix: youtube video unplayable issue and use more ytClients
This commit is contained in:
parent
4fead5f504
commit
2411f46877
@ -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<bool> get isConnected async {
|
||||
final connected = await _isConnected();
|
||||
|
@ -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>(R Function() body) {
|
||||
return runZonedGuarded<R>(
|
||||
() {
|
||||
@ -46,6 +78,8 @@ class AppLogger {
|
||||
);
|
||||
}
|
||||
|
||||
_initInternalPackageLoggers();
|
||||
|
||||
getLogsPath().then((value) => logFile = value);
|
||||
|
||||
return body();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1423,7 +1423,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.5.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: logging
|
||||
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user