mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55: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) {
|
onConnectivityChanged.listen((connected) {
|
||||||
try {
|
try {
|
||||||
if (!connected && timer == null) {
|
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 {
|
timer = Timer.periodic(const Duration(seconds: 30), (timer) async {
|
||||||
if (WidgetsBinding.instance.lifecycleState ==
|
if (WidgetsBinding.instance.lifecycleState ==
|
||||||
AppLifecycleState.paused) {
|
AppLifecycleState.paused) {
|
||||||
@ -111,7 +112,7 @@ class ConnectionCheckerService with WidgetsBindingObserver {
|
|||||||
await isVpnActive(); // when VPN is active that means we are connected
|
await isVpnActive(); // when VPN is active that means we are connected
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isConnectedSync = false;
|
bool isConnectedSync = true;
|
||||||
|
|
||||||
Future<bool> get isConnected async {
|
Future<bool> get isConnected async {
|
||||||
final connected = await _isConnected();
|
final connected = await _isConnected();
|
||||||
|
@ -9,6 +9,20 @@ import 'package:logger/logger.dart';
|
|||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:spotube/utils/platform.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 {
|
class AppLogger {
|
||||||
static late final Logger log;
|
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) {
|
static R? runZoned<R>(R Function() body) {
|
||||||
return runZonedGuarded<R>(
|
return runZonedGuarded<R>(
|
||||||
() {
|
() {
|
||||||
@ -46,6 +78,8 @@ class AppLogger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_initInternalPackageLoggers();
|
||||||
|
|
||||||
getLogsPath().then((value) => logFile = value);
|
getLogsPath().then((value) => logFile = value);
|
||||||
|
|
||||||
return body();
|
return body();
|
||||||
|
@ -85,7 +85,13 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
final manifest = await youtubeClient.videos.streamsClient.getManifest(
|
final manifest = await youtubeClient.videos.streamsClient.getManifest(
|
||||||
cachedSource.sourceId,
|
cachedSource.sourceId,
|
||||||
requireWatchPage: false,
|
requireWatchPage: false,
|
||||||
ytClients: [YoutubeApiClient.tv],
|
ytClients: [
|
||||||
|
YoutubeApiClient.mediaConnect,
|
||||||
|
YoutubeApiClient.ios,
|
||||||
|
YoutubeApiClient.android,
|
||||||
|
YoutubeApiClient.mweb,
|
||||||
|
YoutubeApiClient.tv,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
return YoutubeSourcedTrack(
|
return YoutubeSourcedTrack(
|
||||||
ref: ref,
|
ref: ref,
|
||||||
@ -138,11 +144,17 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
) async {
|
) async {
|
||||||
SourceMap? sourceMap;
|
SourceMap? sourceMap;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
final manifest =
|
final manifest = await youtubeClient.videos.streamsClient.getManifest(
|
||||||
await youtubeClient.videos.streamsClient.getManifest(item.id).timeout(
|
item.id,
|
||||||
const Duration(seconds: 5),
|
requireWatchPage: false,
|
||||||
onTimeout: () => throw ClientException("Timeout"),
|
ytClients: [
|
||||||
);
|
YoutubeApiClient.mediaConnect,
|
||||||
|
YoutubeApiClient.ios,
|
||||||
|
YoutubeApiClient.android,
|
||||||
|
YoutubeApiClient.mweb,
|
||||||
|
YoutubeApiClient.tv,
|
||||||
|
],
|
||||||
|
);
|
||||||
sourceMap = toSourceMap(manifest);
|
sourceMap = toSourceMap(manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1423,7 +1423,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0"
|
version: "2.5.0"
|
||||||
logging:
|
logging:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: logging
|
name: logging
|
||||||
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
|
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
|
||||||
|
@ -86,6 +86,7 @@ dependencies:
|
|||||||
json_annotation: ^4.8.1
|
json_annotation: ^4.8.1
|
||||||
local_notifier: ^0.1.6
|
local_notifier: ^0.1.6
|
||||||
logger: ^2.0.2
|
logger: ^2.0.2
|
||||||
|
logging: ^1.3.0
|
||||||
lrc: ^1.0.2
|
lrc: ^1.0.2
|
||||||
media_kit: ^1.1.10+1
|
media_kit: ^1.1.10+1
|
||||||
media_kit_libs_audio: ^1.0.4
|
media_kit_libs_audio: ^1.0.4
|
||||||
|
Loading…
Reference in New Issue
Block a user