mirror of
https://github.com/austinried/subtracks.git
synced 2026-03-30 00:52:44 +02:00
Compare commits
1 Commits
v2.0.0-alp
...
1a35a69581
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a35a69581 |
@@ -127,8 +127,31 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
"de": [
|
"de": [
|
||||||
|
"actionsDownloadDelete",
|
||||||
|
"actionsOk",
|
||||||
|
"resourcesAlbumCount",
|
||||||
|
"resourcesArtistCount",
|
||||||
|
"resourcesFilterAlbum",
|
||||||
|
"resourcesFilterArtist",
|
||||||
|
"resourcesFilterOwner",
|
||||||
|
"resourcesFilterYear",
|
||||||
|
"resourcesPlaylistCount",
|
||||||
|
"resourcesSongCount",
|
||||||
|
"resourcesSongListDeleteAllContent",
|
||||||
|
"resourcesSongListDeleteAllTitle",
|
||||||
|
"resourcesSortByAlbum",
|
||||||
|
"resourcesSortByAlbumCount",
|
||||||
|
"resourcesSortByTitle",
|
||||||
|
"resourcesSortByUpdated",
|
||||||
|
"settingsAboutActionsSupport",
|
||||||
"settingsAboutShareLogs",
|
"settingsAboutShareLogs",
|
||||||
"settingsAboutChooseLog"
|
"settingsAboutChooseLog",
|
||||||
|
"settingsNetworkOptionsOfflineMode",
|
||||||
|
"settingsNetworkOptionsOfflineModeOff",
|
||||||
|
"settingsNetworkOptionsOfflineModeOn",
|
||||||
|
"settingsNetworkOptionsStreamFormat",
|
||||||
|
"settingsNetworkOptionsStreamFormatServerDefault",
|
||||||
|
"settingsServersFieldsName"
|
||||||
],
|
],
|
||||||
|
|
||||||
"es": [
|
"es": [
|
||||||
@@ -190,6 +213,11 @@
|
|||||||
"settingsServersFieldsName"
|
"settingsServersFieldsName"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"gl": [
|
||||||
|
"settingsAboutShareLogs",
|
||||||
|
"settingsAboutChooseLog"
|
||||||
|
],
|
||||||
|
|
||||||
"it": [
|
"it": [
|
||||||
"actionsCancel",
|
"actionsCancel",
|
||||||
"actionsDelete",
|
"actionsDelete",
|
||||||
@@ -416,6 +444,39 @@
|
|||||||
"settingsServersFieldsName"
|
"settingsServersFieldsName"
|
||||||
],
|
],
|
||||||
|
|
||||||
|
"ru": [
|
||||||
|
"actionsCancel",
|
||||||
|
"actionsDelete",
|
||||||
|
"actionsDownload",
|
||||||
|
"actionsDownloadCancel",
|
||||||
|
"actionsDownloadDelete",
|
||||||
|
"actionsOk",
|
||||||
|
"controlsShuffle",
|
||||||
|
"resourcesAlbumCount",
|
||||||
|
"resourcesArtistCount",
|
||||||
|
"resourcesFilterAlbum",
|
||||||
|
"resourcesFilterArtist",
|
||||||
|
"resourcesFilterOwner",
|
||||||
|
"resourcesFilterYear",
|
||||||
|
"resourcesPlaylistCount",
|
||||||
|
"resourcesSongCount",
|
||||||
|
"resourcesSongListDeleteAllContent",
|
||||||
|
"resourcesSongListDeleteAllTitle",
|
||||||
|
"resourcesSortByAlbum",
|
||||||
|
"resourcesSortByAlbumCount",
|
||||||
|
"resourcesSortByTitle",
|
||||||
|
"resourcesSortByUpdated",
|
||||||
|
"settingsAboutActionsSupport",
|
||||||
|
"settingsAboutShareLogs",
|
||||||
|
"settingsAboutChooseLog",
|
||||||
|
"settingsNetworkOptionsOfflineMode",
|
||||||
|
"settingsNetworkOptionsOfflineModeOff",
|
||||||
|
"settingsNetworkOptionsOfflineModeOn",
|
||||||
|
"settingsNetworkOptionsStreamFormat",
|
||||||
|
"settingsNetworkOptionsStreamFormatServerDefault",
|
||||||
|
"settingsServersFieldsName"
|
||||||
|
],
|
||||||
|
|
||||||
"tr": [
|
"tr": [
|
||||||
"actionsCancel",
|
"actionsCancel",
|
||||||
"actionsDelete",
|
"actionsDelete",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
|||||||
|
|
||||||
import '../services/sync_service.dart';
|
import '../services/sync_service.dart';
|
||||||
import 'items.dart';
|
import 'items.dart';
|
||||||
import 'snackbars.dart';
|
|
||||||
|
|
||||||
class PagedListQueryView<T> extends HookConsumerWidget {
|
class PagedListQueryView<T> extends HookConsumerWidget {
|
||||||
final PagingController<int, T> pagingController;
|
final PagingController<int, T> pagingController;
|
||||||
@@ -123,13 +122,7 @@ class SyncAllRefresh extends HookConsumerWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () => ref.read(syncServiceProvider.notifier).syncAll(),
|
||||||
try {
|
|
||||||
await ref.read(syncServiceProvider.notifier).syncAll();
|
|
||||||
} catch (e) {
|
|
||||||
showErrorSnackbar(context, e.toString());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class SourcePage extends HookConsumerWidget {
|
|||||||
autofillHints: const [AutofillHints.url],
|
autofillHints: const [AutofillHints.url],
|
||||||
required: true,
|
required: true,
|
||||||
validator: (value, label) {
|
validator: (value, label) {
|
||||||
if (!value!.contains(RegExp(r'https?:\/\/'))) {
|
if (Uri.tryParse(value!) == null) {
|
||||||
return '$label must be a valid URL';
|
return '$label must be a valid URL';
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -164,6 +164,7 @@ class SourcePage extends HookConsumerWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e, st) {
|
} catch (e, st) {
|
||||||
|
// TOOD: toast the error or whatever
|
||||||
showErrorSnackbar(context, e.toString());
|
showErrorSnackbar(context, e.toString());
|
||||||
log.severe('Saving source', e, st);
|
log.severe('Saving source', e, st);
|
||||||
error = true;
|
error = true;
|
||||||
|
|||||||
@@ -15,17 +15,26 @@ class SubtracksHttpClient extends BaseClient {
|
|||||||
@override
|
@override
|
||||||
Future<StreamedResponse> send(BaseRequest request) {
|
Future<StreamedResponse> send(BaseRequest request) {
|
||||||
request.headers.addAll(subtracksHeaders);
|
request.headers.addAll(subtracksHeaders);
|
||||||
log.info('${request.method} ${request.url}');
|
log.info('${request.method} ${_redactUri(request.url)}');
|
||||||
|
|
||||||
try {
|
|
||||||
return request.send();
|
return request.send();
|
||||||
} catch (e, st) {
|
|
||||||
log.severe('HTTP client: ${request.method} ${request.url}', e, st);
|
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _redactUri(Uri uri) {
|
||||||
|
var redacted = uri.toString();
|
||||||
|
redacted = _redactParam(redacted, 'u');
|
||||||
|
redacted = _redactParam(redacted, 'p');
|
||||||
|
redacted = _redactParam(redacted, 's');
|
||||||
|
redacted = _redactParam(redacted, 't');
|
||||||
|
|
||||||
|
return redacted.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
RegExp _queryReplace(String key) => RegExp('$key=([^&|\\n|\\t\\s]+)');
|
||||||
|
|
||||||
|
String _redactParam(String url, String key) =>
|
||||||
|
url.replaceFirst(_queryReplace(key), '$key=REDACTED');
|
||||||
|
|
||||||
@Riverpod(keepAlive: true)
|
@Riverpod(keepAlive: true)
|
||||||
BaseClient httpClient(HttpClientRef ref) {
|
BaseClient httpClient(HttpClientRef ref) {
|
||||||
return SubtracksHttpClient();
|
return SubtracksHttpClient();
|
||||||
|
|||||||
@@ -202,75 +202,5 @@
|
|||||||
"controlsShuffle": "Zufall",
|
"controlsShuffle": "Zufall",
|
||||||
"@controlsShuffle": {},
|
"@controlsShuffle": {},
|
||||||
"actionsCancel": "Abbrechen",
|
"actionsCancel": "Abbrechen",
|
||||||
"@actionsCancel": {},
|
"@actionsCancel": {}
|
||||||
"actionsDownloadDelete": "Heruntergeladene Inhalte löschen",
|
|
||||||
"@actionsDownloadDelete": {},
|
|
||||||
"actionsOk": "OK",
|
|
||||||
"@actionsOk": {},
|
|
||||||
"resourcesAlbumCount": "{count,plural, =1{{count} Album} other{{count} Alben}}",
|
|
||||||
"@resourcesAlbumCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesFilterAlbum": "Album",
|
|
||||||
"@resourcesFilterAlbum": {},
|
|
||||||
"resourcesArtistCount": "{count,plural, =1{{count} Künstler} other{{count} Künstler}}",
|
|
||||||
"@resourcesArtistCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesFilterArtist": "Künstler",
|
|
||||||
"@resourcesFilterArtist": {},
|
|
||||||
"resourcesFilterOwner": "Besitzer",
|
|
||||||
"@resourcesFilterOwner": {},
|
|
||||||
"resourcesFilterYear": "Jahr",
|
|
||||||
"@resourcesFilterYear": {},
|
|
||||||
"resourcesPlaylistCount": "{count,plural, =1{{count} Playlist} other{{count} Playlists}}",
|
|
||||||
"@resourcesPlaylistCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesSongCount": "{count,plural, =1{{count} Song} other{{count} Songs}}",
|
|
||||||
"@resourcesSongCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesSongListDeleteAllContent": "Hierdurch werden alle heruntergeladenen Inhalte entfernt.",
|
|
||||||
"@resourcesSongListDeleteAllContent": {},
|
|
||||||
"resourcesSortByAlbum": "Album",
|
|
||||||
"@resourcesSortByAlbum": {},
|
|
||||||
"resourcesSortByAlbumCount": "Albenanzahl",
|
|
||||||
"@resourcesSortByAlbumCount": {},
|
|
||||||
"resourcesSortByTitle": "Titel",
|
|
||||||
"@resourcesSortByTitle": {},
|
|
||||||
"resourcesSortByUpdated": "Kürzlich hinzugefügt",
|
|
||||||
"@resourcesSortByUpdated": {},
|
|
||||||
"settingsAboutActionsSupport": "Den Entwickler unterstützen",
|
|
||||||
"@settingsAboutActionsSupport": {},
|
|
||||||
"settingsNetworkOptionsOfflineMode": "Offline Modus",
|
|
||||||
"@settingsNetworkOptionsOfflineMode": {},
|
|
||||||
"settingsNetworkOptionsOfflineModeOff": "Nutze das Internet um Musik zu synchronisieren.",
|
|
||||||
"@settingsNetworkOptionsOfflineModeOff": {},
|
|
||||||
"settingsNetworkOptionsOfflineModeOn": "Nutze nicht das Internet um Musik zu synchronisieren.",
|
|
||||||
"@settingsNetworkOptionsOfflineModeOn": {},
|
|
||||||
"settingsNetworkOptionsStreamFormat": "Bevorzugtes Streaming-Format",
|
|
||||||
"@settingsNetworkOptionsStreamFormat": {},
|
|
||||||
"settingsServersFieldsName": "Name",
|
|
||||||
"@settingsServersFieldsName": {},
|
|
||||||
"resourcesSongListDeleteAllTitle": "Downloads löschen?",
|
|
||||||
"@resourcesSongListDeleteAllTitle": {},
|
|
||||||
"settingsNetworkOptionsStreamFormatServerDefault": "Server-Standard verwenden",
|
|
||||||
"@settingsNetworkOptionsStreamFormatServerDefault": {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -272,9 +272,5 @@
|
|||||||
"resourcesSortByTitle": "Título",
|
"resourcesSortByTitle": "Título",
|
||||||
"@resourcesSortByTitle": {},
|
"@resourcesSortByTitle": {},
|
||||||
"resourcesSortByUpdated": "Actualizado recentemente",
|
"resourcesSortByUpdated": "Actualizado recentemente",
|
||||||
"@resourcesSortByUpdated": {},
|
"@resourcesSortByUpdated": {}
|
||||||
"settingsAboutShareLogs": "Compartir rexistros",
|
|
||||||
"@settingsAboutShareLogs": {},
|
|
||||||
"settingsAboutChooseLog": "Escolle un ficheiro de rexistro",
|
|
||||||
"@settingsAboutChooseLog": {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
},
|
},
|
||||||
"resourcesSortByAdded": "Недавно добавленные",
|
"resourcesSortByAdded": "Недавно добавленные",
|
||||||
"@resourcesSortByAdded": {},
|
"@resourcesSortByAdded": {},
|
||||||
"resourcesSortByArtist": "По исполнителям",
|
"resourcesSortByArtist": "По исполнителю",
|
||||||
"@resourcesSortByArtist": {},
|
"@resourcesSortByArtist": {},
|
||||||
"resourcesSortByFrequentlyPlayed": "Часто проигрываемые",
|
"resourcesSortByFrequentlyPlayed": "Часто проигрываемые",
|
||||||
"@resourcesSortByFrequentlyPlayed": {},
|
"@resourcesSortByFrequentlyPlayed": {},
|
||||||
@@ -192,89 +192,5 @@
|
|||||||
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Отправить пароль в виде текста (устарело, убедитесь, что ваше соединение безопасно!)",
|
"settingsServersOptionsForcePlaintextPasswordDescriptionOn": "Отправить пароль в виде текста (устарело, убедитесь, что ваше соединение безопасно!)",
|
||||||
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
|
"@settingsServersOptionsForcePlaintextPasswordDescriptionOn": {},
|
||||||
"settingsServersOptionsForcePlaintextPasswordTitle": "Принудительно использовать текстовой пароль",
|
"settingsServersOptionsForcePlaintextPasswordTitle": "Принудительно использовать текстовой пароль",
|
||||||
"@settingsServersOptionsForcePlaintextPasswordTitle": {},
|
"@settingsServersOptionsForcePlaintextPasswordTitle": {}
|
||||||
"settingsAboutShareLogs": "Поделиться журналами",
|
|
||||||
"@settingsAboutShareLogs": {},
|
|
||||||
"settingsAboutChooseLog": "Выбрать файл журнала",
|
|
||||||
"@settingsAboutChooseLog": {},
|
|
||||||
"settingsNetworkOptionsStreamFormatServerDefault": "Использовать сервер по умолчанию",
|
|
||||||
"@settingsNetworkOptionsStreamFormatServerDefault": {},
|
|
||||||
"actionsDownload": "Скачать",
|
|
||||||
"@actionsDownload": {},
|
|
||||||
"actionsDownloadCancel": "Отменить загрузку",
|
|
||||||
"@actionsDownloadCancel": {},
|
|
||||||
"actionsCancel": "Отменить",
|
|
||||||
"@actionsCancel": {},
|
|
||||||
"resourcesSongCount": "{count,plural, =1{{count} трек} other{{count} треки}}",
|
|
||||||
"@resourcesSongCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesSortByAlbum": "По альбомам",
|
|
||||||
"@resourcesSortByAlbum": {},
|
|
||||||
"resourcesSortByTitle": "По заголовку",
|
|
||||||
"@resourcesSortByTitle": {},
|
|
||||||
"resourcesSortByUpdated": "По недавно обновленному",
|
|
||||||
"@resourcesSortByUpdated": {},
|
|
||||||
"resourcesSortByAlbumCount": "По количеству альбомов",
|
|
||||||
"@resourcesSortByAlbumCount": {},
|
|
||||||
"settingsNetworkOptionsOfflineMode": "Автономный режим",
|
|
||||||
"@settingsNetworkOptionsOfflineMode": {},
|
|
||||||
"settingsNetworkOptionsOfflineModeOff": "Использовать интернет для синхронизации музыки.",
|
|
||||||
"@settingsNetworkOptionsOfflineModeOff": {},
|
|
||||||
"settingsServersFieldsName": "Имя",
|
|
||||||
"@settingsServersFieldsName": {},
|
|
||||||
"actionsDelete": "Удалить",
|
|
||||||
"@actionsDelete": {},
|
|
||||||
"actionsDownloadDelete": "Удалить загруженное",
|
|
||||||
"@actionsDownloadDelete": {},
|
|
||||||
"actionsOk": "ОК",
|
|
||||||
"@actionsOk": {},
|
|
||||||
"controlsShuffle": "Перемешать",
|
|
||||||
"@controlsShuffle": {},
|
|
||||||
"resourcesFilterArtist": "По исполнителю",
|
|
||||||
"@resourcesFilterArtist": {},
|
|
||||||
"resourcesFilterAlbum": "По альбомам",
|
|
||||||
"@resourcesFilterAlbum": {},
|
|
||||||
"resourcesFilterYear": "По годам",
|
|
||||||
"@resourcesFilterYear": {},
|
|
||||||
"resourcesFilterOwner": "По владельцу",
|
|
||||||
"@resourcesFilterOwner": {},
|
|
||||||
"resourcesSongListDeleteAllContent": "Это удалит все загруженные файлы песен.",
|
|
||||||
"@resourcesSongListDeleteAllContent": {},
|
|
||||||
"settingsNetworkOptionsStreamFormat": "Предпочтительный формат потока",
|
|
||||||
"@settingsNetworkOptionsStreamFormat": {},
|
|
||||||
"resourcesSongListDeleteAllTitle": "Удалить загрузки?",
|
|
||||||
"@resourcesSongListDeleteAllTitle": {},
|
|
||||||
"settingsNetworkOptionsOfflineModeOn": "Не использовать интернет для синхронизации или воспроизведения музыки.",
|
|
||||||
"@settingsNetworkOptionsOfflineModeOn": {},
|
|
||||||
"settingsAboutActionsSupport": "Поддержать разработчика",
|
|
||||||
"@settingsAboutActionsSupport": {},
|
|
||||||
"resourcesArtistCount": "{count,plural, =1{{count} исполнитель} other{{count} исполнители}}",
|
|
||||||
"@resourcesArtistCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesPlaylistCount": "{count,plural, =1{{count} плейлист} other{{count} плейлисты}}",
|
|
||||||
"@resourcesPlaylistCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"resourcesAlbumCount": "{count,plural, =1{{count} альбом} other{{count} альбомы}}",
|
|
||||||
"@resourcesAlbumCount": {
|
|
||||||
"placeholders": {
|
|
||||||
"count": {
|
|
||||||
"type": "int"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
68
lib/log.dart
68
lib/log.dart
@@ -88,7 +88,6 @@ String _format(
|
|||||||
bool color = false,
|
bool color = false,
|
||||||
bool time = true,
|
bool time = true,
|
||||||
bool level = true,
|
bool level = true,
|
||||||
bool redact = true,
|
|
||||||
}) {
|
}) {
|
||||||
var message = '';
|
var message = '';
|
||||||
if (time) message += '${event.time.toIso8601String()} ';
|
if (time) message += '${event.time.toIso8601String()} ';
|
||||||
@@ -108,11 +107,6 @@ String _format(
|
|||||||
if (event.error != null) {
|
if (event.error != null) {
|
||||||
message += '\n${event.error}';
|
message += '\n${event.error}';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redact) {
|
|
||||||
message = _redactUrl(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.stackTrace != null) {
|
if (event.stackTrace != null) {
|
||||||
message += '\n${event.stackTrace}';
|
message += '\n${event.stackTrace}';
|
||||||
}
|
}
|
||||||
@@ -122,24 +116,17 @@ String _format(
|
|||||||
: message;
|
: message;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _redactUrl(String message) {
|
Future<void> _printFile(String event, String dir) async {
|
||||||
if (!_queryReplace('u').hasMatch(message)) {
|
final now = DateTime.now();
|
||||||
return message;
|
final file = File(p.join(dir, '${now.year}-${now.month}-${now.day}.txt'));
|
||||||
|
|
||||||
|
if (!event.endsWith('\n')) {
|
||||||
|
event += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
message = _redactParam(message, 'u');
|
await file.writeAsString(event, mode: FileMode.writeOnlyAppend, flush: true);
|
||||||
message = _redactParam(message, 'p');
|
|
||||||
message = _redactParam(message, 's');
|
|
||||||
message = _redactParam(message, 't');
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegExp _queryReplace(String key) => RegExp('$key=([^&|\\n|\\t\\s]+)');
|
|
||||||
|
|
||||||
String _redactParam(String url, String key) =>
|
|
||||||
url.replaceAll(_queryReplace(key), '$key=REDACTED');
|
|
||||||
|
|
||||||
Future<Directory> logDirectory() async {
|
Future<Directory> logDirectory() async {
|
||||||
return Directory(
|
return Directory(
|
||||||
p.join((await getApplicationDocumentsDirectory()).path, 'logs'),
|
p.join((await getApplicationDocumentsDirectory()).path, 'logs'),
|
||||||
@@ -154,43 +141,11 @@ Future<List<File>> logFiles() async {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
File _currentLogFile(String logDir) {
|
|
||||||
final now = DateTime.now();
|
|
||||||
return File(p.join(logDir, '${now.year}-${now.month}-${now.day}.txt'));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _printFile(String event, String logDir) async {
|
|
||||||
final file = _currentLogFile(logDir);
|
|
||||||
|
|
||||||
if (!event.endsWith('\n')) {
|
|
||||||
event += '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
await file.writeAsString(event, mode: FileMode.writeOnlyAppend, flush: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _printDebug(LogRecord event) {
|
|
||||||
// ignore: avoid_print
|
|
||||||
print(_format(event, color: true, time: false, level: false, redact: false));
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _printRelease(LogRecord event, String logDir) async {
|
|
||||||
await _printFile(
|
|
||||||
_format(event, color: false, time: true, level: true, redact: true),
|
|
||||||
logDir,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final log = Logger('default');
|
final log = Logger('default');
|
||||||
|
|
||||||
Future<void> initLogging() async {
|
Future<void> initLogging() async {
|
||||||
final dir = (await logDirectory())..create();
|
final dir = (await logDirectory())..create();
|
||||||
|
|
||||||
final file = _currentLogFile(dir.path);
|
|
||||||
if (!(await file.exists())) {
|
|
||||||
await file.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
final files = await logFiles();
|
final files = await logFiles();
|
||||||
if (files.length > 7) {
|
if (files.length > 7) {
|
||||||
for (var file in files.slice(7)) {
|
for (var file in files.slice(7)) {
|
||||||
@@ -201,9 +156,14 @@ Future<void> initLogging() async {
|
|||||||
Logger.root.level = kDebugMode ? Level.ALL : Level.INFO;
|
Logger.root.level = kDebugMode ? Level.ALL : Level.INFO;
|
||||||
Logger.root.onRecord.asyncMap((event) async {
|
Logger.root.onRecord.asyncMap((event) async {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
_printDebug(event);
|
print(_format(event, color: true, time: false, level: false));
|
||||||
} else {
|
} else {
|
||||||
await _printRelease(event, dir.path);
|
await _printFile(
|
||||||
|
_format(event, color: false, time: true, level: true),
|
||||||
|
dir.path,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}).listen((_) {}, cancelOnError: false);
|
}).listen((_) {}, cancelOnError: false);
|
||||||
|
|
||||||
|
log.info('start');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
|
|||||||
int get _sourceId => _ref.read(sourceIdProvider);
|
int get _sourceId => _ref.read(sourceIdProvider);
|
||||||
|
|
||||||
AudioControl(this._player, this._ref) {
|
AudioControl(this._player, this._ref) {
|
||||||
_player.playbackEventStream.listen((PlaybackEvent event) {
|
_player.playbackEventStream.listen(
|
||||||
|
(PlaybackEvent event) {
|
||||||
final playing = _player.playing;
|
final playing = _player.playing;
|
||||||
playbackState.add(playbackState.value.copyWith(
|
playbackState.add(playbackState.value.copyWith(
|
||||||
controls: [
|
controls: [
|
||||||
@@ -120,11 +121,10 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler {
|
|||||||
bufferedPosition: _player.bufferedPosition,
|
bufferedPosition: _player.bufferedPosition,
|
||||||
queueIndex: event.currentIndex,
|
queueIndex: event.currentIndex,
|
||||||
));
|
));
|
||||||
});
|
},
|
||||||
|
onError: (e, st) => log.warning('Audio playback error', e, st),
|
||||||
_player.playbackEventStream.doOnError((e, st) async {
|
cancelOnError: false,
|
||||||
log.warning('playbackEventStream', e, st);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
shuffleIndicies.listen((value) {
|
shuffleIndicies.listen((value) {
|
||||||
playbackState.add(playbackState.value.copyWith(
|
playbackState.add(playbackState.value.copyWith(
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
import 'package:rxdart/rxdart.dart';
|
|
||||||
|
|
||||||
import '../database/database.dart';
|
import '../database/database.dart';
|
||||||
import '../log.dart';
|
|
||||||
import '../state/settings.dart';
|
import '../state/settings.dart';
|
||||||
|
|
||||||
abstract class BaseMusicSource {
|
abstract class BaseMusicSource {
|
||||||
@@ -42,33 +40,25 @@ class MusicSource implements BaseMusicSource {
|
|||||||
@override
|
@override
|
||||||
Stream<Iterable<AlbumsCompanion>> allAlbums() {
|
Stream<Iterable<AlbumsCompanion>> allAlbums() {
|
||||||
_testOnline();
|
_testOnline();
|
||||||
return _source
|
return _source.allAlbums();
|
||||||
.allAlbums()
|
|
||||||
.doOnError((e, st) => log.severe('allAlbums', e, st));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<Iterable<ArtistsCompanion>> allArtists() {
|
Stream<Iterable<ArtistsCompanion>> allArtists() {
|
||||||
_testOnline();
|
_testOnline();
|
||||||
return _source
|
return _source.allArtists();
|
||||||
.allArtists()
|
|
||||||
.doOnError((e, st) => log.severe('allArtists', e, st));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<Iterable<PlaylistWithSongsCompanion>> allPlaylists() {
|
Stream<Iterable<PlaylistWithSongsCompanion>> allPlaylists() {
|
||||||
_testOnline();
|
_testOnline();
|
||||||
return _source
|
return _source.allPlaylists();
|
||||||
.allPlaylists()
|
|
||||||
.doOnError((e, st) => log.severe('allPlaylists', e, st));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<Iterable<SongsCompanion>> allSongs() {
|
Stream<Iterable<SongsCompanion>> allSongs() {
|
||||||
_testOnline();
|
_testOnline();
|
||||||
return _source
|
return _source.allSongs();
|
||||||
.allSongs()
|
|
||||||
.doOnError((e, st) => log.severe('allSongs', e, st));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ homepage: https://github.com/austinried/subtracks
|
|||||||
repository: https://github.com/austinried/subtracks
|
repository: https://github.com/austinried/subtracks
|
||||||
issue_tracker: https://github.com/austinried/subtracks/issues
|
issue_tracker: https://github.com/austinried/subtracks/issues
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 2.0.0-alpha.3+12
|
version: 2.0.0-alpha.2+11
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.19.2 <3.0.0'
|
sdk: '>=2.19.2 <3.0.0'
|
||||||
|
|||||||
Reference in New Issue
Block a user