Compare commits
No commits in common. "master" and "1.0.0+8" have entirely different histories.
13
README.md
13
README.md
@ -5,23 +5,13 @@ Yet another spotify third-party client. Support multi-platform because built wit
|
|||||||
This project is inspired by and taken supported by [spotube](https://spotube.krtirtho.dev).
|
This project is inspired by and taken supported by [spotube](https://spotube.krtirtho.dev).
|
||||||
Their original app is good enough. But I just want to redesign the user interface and make it ready add to more features and more backend support.
|
Their original app is good enough. But I just want to redesign the user interface and make it ready add to more features and more backend support.
|
||||||
|
|
||||||
## Highlight
|
|
||||||
|
|
||||||
Compare to original spotube. This project added more audio source e.g. netease cloud music, kugou and provide the ability to use in China Mainland.
|
|
||||||
|
|
||||||
At the same time, this project also focus on playing experience of VOCALOID songs.
|
|
||||||
We improve the search and rank algorithm to make the querying will less pick the cover version instead of original ones.
|
|
||||||
|
|
||||||
Due to the end service of jiosaavn in Asian region (maybe other regions also affected). We removed the jiosaavn audio source.
|
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
- [x] Playing music
|
- [x] Playing music
|
||||||
- [x] Add netease music as source
|
- [x] Add netease music as source
|
||||||
- [ ] Add bilibili as source
|
- [ ] Add bilibili as source
|
||||||
- [ ] Add kuwo music as source
|
- [ ] Add kuwo music as source
|
||||||
- [x] Add kugou music as source
|
- [ ] Add kugo music as source
|
||||||
- [x] Optimize fallback strategy
|
|
||||||
- [x] Re-design user interface
|
- [x] Re-design user interface
|
||||||
- [x] Simplified UI and UX
|
- [x] Simplified UI and UX
|
||||||
- [x] Support for large screen device
|
- [x] Support for large screen device
|
||||||
@ -31,4 +21,3 @@ Due to the end service of jiosaavn in Asian region (maybe other regions also aff
|
|||||||
This project is open-sourced under APGLv3 license. The original spotube project is open-sourced under license BSD-Clause4 and copyright by Kingkor Roy Tirtho.
|
This project is open-sourced under APGLv3 license. The original spotube project is open-sourced under license BSD-Clause4 and copyright by Kingkor Roy Tirtho.
|
||||||
|
|
||||||
This project is all rights reversed by LittleSheep and Solsynth LLC.
|
This project is all rights reversed by LittleSheep and Solsynth LLC.
|
||||||
|
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
|
||||||
<false/>
|
|
||||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
@ -57,5 +55,5 @@
|
|||||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -9,23 +9,15 @@ import 'package:rhythm_box/providers/database.dart';
|
|||||||
import 'package:rhythm_box/services/database/database.dart';
|
import 'package:rhythm_box/services/database/database.dart';
|
||||||
|
|
||||||
extension ExpirationAuthenticationTableData on AuthenticationTableData {
|
extension ExpirationAuthenticationTableData on AuthenticationTableData {
|
||||||
bool get isExpired => DateTime.now().isAfter(spotifyExpiration);
|
bool get isExpired => DateTime.now().isAfter(expiration);
|
||||||
|
|
||||||
String? getCookie(String key) => spotifyCookie.value
|
String? getCookie(String key) => cookie.value
|
||||||
.split('; ')
|
.split('; ')
|
||||||
.firstWhereOrNull((c) => c.trim().startsWith('$key='))
|
.firstWhereOrNull((c) => c.trim().startsWith('$key='))
|
||||||
?.trim()
|
?.trim()
|
||||||
.split('=')
|
.split('=')
|
||||||
.last
|
.last
|
||||||
.replaceAll(';', '');
|
.replaceAll(';', '');
|
||||||
|
|
||||||
String? getNeteaseCookie(String key) => neteaseCookie?.value
|
|
||||||
.split(';')
|
|
||||||
.firstWhereOrNull((c) => c.trim().startsWith('$key='))
|
|
||||||
?.trim()
|
|
||||||
.split('=')
|
|
||||||
.last
|
|
||||||
.replaceAll(';', '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthenticationProvider extends GetxController {
|
class AuthenticationProvider extends GetxController {
|
||||||
@ -63,18 +55,18 @@ class AuthenticationProvider extends GetxController {
|
|||||||
void _setRefreshTimer() {
|
void _setRefreshTimer() {
|
||||||
refreshTimer?.cancel();
|
refreshTimer?.cancel();
|
||||||
if (auth.value != null && auth.value!.isExpired) {
|
if (auth.value != null && auth.value!.isExpired) {
|
||||||
refreshSpotifyCredentials();
|
refreshCredentials();
|
||||||
}
|
}
|
||||||
refreshTimer = Timer(
|
refreshTimer = Timer(
|
||||||
auth.value!.spotifyExpiration.difference(DateTime.now()),
|
auth.value!.expiration.difference(DateTime.now()),
|
||||||
() => refreshSpotifyCredentials(),
|
() => refreshCredentials(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refreshSpotifyCredentials() async {
|
Future<void> refreshCredentials() async {
|
||||||
final database = Get.find<DatabaseProvider>().database;
|
final database = Get.find<DatabaseProvider>().database;
|
||||||
final refreshedCredentials =
|
final refreshedCredentials =
|
||||||
await credentialsFromCookie(auth.value!.spotifyCookie.value);
|
await credentialsFromCookie(auth.value!.cookie.value);
|
||||||
|
|
||||||
await database
|
await database
|
||||||
.update(database.authenticationTable)
|
.update(database.authenticationTable)
|
||||||
@ -120,10 +112,9 @@ class AuthenticationProvider extends GetxController {
|
|||||||
|
|
||||||
return AuthenticationTableCompanion.insert(
|
return AuthenticationTableCompanion.insert(
|
||||||
id: const Value(0),
|
id: const Value(0),
|
||||||
spotifyCookie:
|
cookie: DecryptedText("${res.headers["set-cookie"]?.join(";")}; $spDc"),
|
||||||
DecryptedText("${res.headers["set-cookie"]?.join(";")}; $spDc"),
|
accessToken: DecryptedText(body['accessToken']),
|
||||||
spotifyAccessToken: DecryptedText(body['accessToken']),
|
expiration: DateTime.fromMillisecondsSinceEpoch(
|
||||||
spotifyExpiration: DateTime.fromMillisecondsSinceEpoch(
|
|
||||||
body['accessTokenExpirationTimestampMs']),
|
body['accessTokenExpirationTimestampMs']),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -132,21 +123,6 @@ class AuthenticationProvider extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setNeteaseCredentials(String cookie) async {
|
|
||||||
final database = Get.find<DatabaseProvider>().database;
|
|
||||||
await database.update(database.authenticationTable).replace(
|
|
||||||
AuthenticationTableCompanion.insert(
|
|
||||||
id: const Value(0),
|
|
||||||
spotifyCookie: auth.value!.spotifyCookie,
|
|
||||||
spotifyAccessToken: auth.value!.spotifyAccessToken,
|
|
||||||
spotifyExpiration: auth.value!.spotifyExpiration,
|
|
||||||
neteaseCookie: Value(DecryptedText(cookie)),
|
|
||||||
neteaseExpiration: const Value(null),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await loadAuthenticationData();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> logout() async {
|
Future<void> logout() async {
|
||||||
auth.value = null;
|
auth.value = null;
|
||||||
final database = Get.find<DatabaseProvider>().database;
|
final database = Get.find<DatabaseProvider>().database;
|
||||||
@ -156,21 +132,6 @@ class AuthenticationProvider extends GetxController {
|
|||||||
// Additional cleanup if necessary
|
// Additional cleanup if necessary
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> logoutNetease() async {
|
|
||||||
final database = Get.find<DatabaseProvider>().database;
|
|
||||||
await database.update(database.authenticationTable).replace(
|
|
||||||
AuthenticationTableCompanion.insert(
|
|
||||||
id: const Value(0),
|
|
||||||
spotifyCookie: auth.value!.spotifyCookie,
|
|
||||||
spotifyAccessToken: auth.value!.spotifyAccessToken,
|
|
||||||
spotifyExpiration: auth.value!.spotifyExpiration,
|
|
||||||
neteaseCookie: const Value(null),
|
|
||||||
neteaseExpiration: const Value(null),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
await loadAuthenticationData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
refreshTimer?.cancel();
|
refreshTimer?.cancel();
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -7,16 +6,12 @@ import 'package:get/get.dart';
|
|||||||
class ErrorNotifier extends GetxController {
|
class ErrorNotifier extends GetxController {
|
||||||
Rx<MaterialBanner?> showing = Rx(null);
|
Rx<MaterialBanner?> showing = Rx(null);
|
||||||
|
|
||||||
Timer? _autoDismissTimer;
|
|
||||||
|
|
||||||
void logError(String msg, {StackTrace? trace}) {
|
void logError(String msg, {StackTrace? trace}) {
|
||||||
log('$msg${trace != null ? '\nTrace:\n$trace' : ''}');
|
log('$msg${trace != null ? '\nTrace:\n$trace' : ''}');
|
||||||
showError(msg);
|
showError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showError(String msg) {
|
void showError(String msg) {
|
||||||
_autoDismissTimer?.cancel();
|
|
||||||
|
|
||||||
showing.value = MaterialBanner(
|
showing.value = MaterialBanner(
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
leading: const Icon(Icons.error),
|
leading: const Icon(Icons.error),
|
||||||
@ -39,9 +34,5 @@ class ErrorNotifier extends GetxController {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
_autoDismissTimer = Timer(const Duration(seconds: 3), () {
|
|
||||||
showing.value = null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class SpotifyProvider extends GetxController {
|
|||||||
log('[SpotifyApi] Using user credentials...');
|
log('[SpotifyApi] Using user credentials...');
|
||||||
final AuthenticationProvider authenticate = Get.find();
|
final AuthenticationProvider authenticate = Get.find();
|
||||||
return SpotifyApi.withAccessToken(
|
return SpotifyApi.withAccessToken(
|
||||||
authenticate.auth.value!.spotifyAccessToken.value);
|
authenticate.auth.value!.accessToken.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -178,8 +178,4 @@ class UserPreferencesProvider extends GetxController {
|
|||||||
setData(PreferencesTableCompanion(playerWakelock: Value(wakelock)));
|
setData(PreferencesTableCompanion(playerWakelock: Value(wakelock)));
|
||||||
WakelockPlus.toggle(enable: wakelock);
|
WakelockPlus.toggle(enable: wakelock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOverrideCacheProvider(bool override) {
|
|
||||||
setData(PreferencesTableCompanion(overrideCacheProvider: Value(override)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:rhythm_box/screens/about.dart';
|
import 'package:rhythm_box/screens/about.dart';
|
||||||
import 'package:rhythm_box/screens/album/view.dart';
|
import 'package:rhythm_box/screens/album/view.dart';
|
||||||
import 'package:rhythm_box/screens/auth/login_netease.dart';
|
|
||||||
import 'package:rhythm_box/screens/auth/mobile_login.dart';
|
import 'package:rhythm_box/screens/auth/mobile_login.dart';
|
||||||
import 'package:rhythm_box/screens/explore.dart';
|
import 'package:rhythm_box/screens/explore.dart';
|
||||||
import 'package:rhythm_box/screens/library/view.dart';
|
import 'package:rhythm_box/screens/library/view.dart';
|
||||||
@ -105,11 +104,6 @@ final router = GoRouter(routes: [
|
|||||||
name: 'authMobileLogin',
|
name: 'authMobileLogin',
|
||||||
builder: (context, state) => const MobileLogin(),
|
builder: (context, state) => const MobileLogin(),
|
||||||
),
|
),
|
||||||
GoRoute(
|
|
||||||
path: '/auth/netease/login',
|
|
||||||
name: 'authMobileLoginNetease',
|
|
||||||
builder: (context, state) => const LoginNeteaseScreen(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
@ -1,156 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:gap/gap.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:rhythm_box/providers/auth.dart';
|
|
||||||
import 'package:rhythm_box/providers/error_notifier.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
|
||||||
import 'package:rhythm_box/widgets/sized_container.dart';
|
|
||||||
|
|
||||||
class LoginNeteaseScreen extends StatefulWidget {
|
|
||||||
const LoginNeteaseScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<LoginNeteaseScreen> createState() => _LoginNeteaseScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _LoginNeteaseScreenState extends State<LoginNeteaseScreen> {
|
|
||||||
final TextEditingController _phoneController = TextEditingController();
|
|
||||||
final TextEditingController _phoneRegionController = TextEditingController();
|
|
||||||
final TextEditingController _passwordController = TextEditingController();
|
|
||||||
|
|
||||||
late final AuthenticationProvider _auth = Get.find();
|
|
||||||
|
|
||||||
bool _isLogging = false;
|
|
||||||
|
|
||||||
Future<void> _sentCaptcha() async {
|
|
||||||
setState(() => _isLogging = true);
|
|
||||||
|
|
||||||
final phone = _phoneController.text;
|
|
||||||
var region = _phoneRegionController.text;
|
|
||||||
if (region.isEmpty) region = '86';
|
|
||||||
final client = NeteaseSourcedTrack.getClient();
|
|
||||||
final resp = await client.get(
|
|
||||||
'/captcha/sent?phone=$phone&ctcode=$region×tamp=${DateTime.now().millisecondsSinceEpoch}',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (resp.statusCode != 200 || resp.body?['code'] != 200) {
|
|
||||||
Get.find<ErrorNotifier>().showError(
|
|
||||||
resp.bodyString ?? resp.status.toString(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() => _isLogging = false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _performLogin() async {
|
|
||||||
setState(() => _isLogging = true);
|
|
||||||
|
|
||||||
final phone = _phoneController.text;
|
|
||||||
final password = _passwordController.text;
|
|
||||||
var region = _phoneRegionController.text;
|
|
||||||
if (region.isEmpty) region = '86';
|
|
||||||
final client = NeteaseSourcedTrack.getClient();
|
|
||||||
final resp = await client.get(
|
|
||||||
'/login/cellphone?phone=$phone&captcha=$password&countrycode=$region×tamp=${DateTime.now().millisecondsSinceEpoch}',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (resp.statusCode != 200 || resp.body?['code'] != 200) {
|
|
||||||
Get.find<ErrorNotifier>().showError(
|
|
||||||
resp.bodyString ?? resp.status.toString(),
|
|
||||||
);
|
|
||||||
setState(() => _isLogging = false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _auth.setNeteaseCredentials(resp.body['cookie']);
|
|
||||||
|
|
||||||
setState(() => _isLogging = false);
|
|
||||||
|
|
||||||
GoRouter.of(context).goNamed('settings');
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
_phoneController.dispose();
|
|
||||||
_phoneRegionController.dispose();
|
|
||||||
_passwordController.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
title: const Text('Connect with Netease Cloud Music'),
|
|
||||||
),
|
|
||||||
body: CenteredContainer(
|
|
||||||
maxWidth: 320,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 64,
|
|
||||||
child: TextField(
|
|
||||||
controller: _phoneRegionController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
hintText: '86',
|
|
||||||
isDense: true,
|
|
||||||
),
|
|
||||||
onTapOutside: (_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: _phoneController,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
label: Text('Phone Number'),
|
|
||||||
isDense: true,
|
|
||||||
),
|
|
||||||
onTapOutside: (_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: _passwordController,
|
|
||||||
obscureText: true,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
label: Text('Captcha Code'),
|
|
||||||
isDense: true,
|
|
||||||
),
|
|
||||||
onTapOutside: (_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
IconButton(
|
|
||||||
onPressed: _isLogging ? null : () => _sentCaptcha(),
|
|
||||||
icon: const Icon(Icons.sms),
|
|
||||||
tooltip: 'Get Captcha',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const Gap(8),
|
|
||||||
TextButton(
|
|
||||||
onPressed: _isLogging ? null : () => _performLogin(),
|
|
||||||
child: const Text('Login'),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -72,8 +72,8 @@ class _ExploreScreenState extends State<ExploreScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_auth.auth.value != null) {
|
if (_auth.auth.value != null) {
|
||||||
final customEndpoint = CustomSpotifyEndpoints(
|
final customEndpoint =
|
||||||
_auth.auth.value?.spotifyAccessToken.value ?? '');
|
CustomSpotifyEndpoints(_auth.auth.value?.accessToken.value ?? '');
|
||||||
final forYouView = await customEndpoint.getView(
|
final forYouView = await customEndpoint.getView(
|
||||||
'made-for-x-hub',
|
'made-for-x-hub',
|
||||||
market: market,
|
market: market,
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
|
||||||
import 'package:rhythm_box/widgets/player/track_source_details.dart';
|
import 'package:rhythm_box/widgets/player/track_source_details.dart';
|
||||||
|
|
||||||
class SourceDetailsPopup extends StatelessWidget {
|
class SourceDetailsPopup extends StatelessWidget {
|
||||||
const SourceDetailsPopup({super.key});
|
const SourceDetailsPopup({super.key});
|
||||||
|
|
||||||
Future<SourcedTrack?> _pullActiveTrack() async {
|
|
||||||
final ActiveSourcedTrackProvider activeSourcedTrack = Get.find();
|
|
||||||
return activeSourcedTrack.state.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final ActiveSourcedTrackProvider activeTrack = Get.find();
|
||||||
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -24,19 +20,8 @@ class SourceDetailsPopup extends StatelessWidget {
|
|||||||
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
|
).paddingOnly(left: 24, right: 24, top: 32, bottom: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Obx(
|
child: Obx(
|
||||||
() => FutureBuilder(
|
() => TrackSourceDetails(
|
||||||
future: _pullActiveTrack(),
|
track: activeTrack.state.value!,
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
return TrackSourceDetails(
|
|
||||||
track: snapshot.data!,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return const Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).paddingSymmetric(horizontal: 24),
|
).paddingSymmetric(horizontal: 24),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -82,8 +82,7 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||||
children: [
|
children: [
|
||||||
Obx(
|
Obx(
|
||||||
() => Center(
|
() => LimitedBox(
|
||||||
child: LimitedBox(
|
|
||||||
maxHeight: maxAlbumSize,
|
maxHeight: maxAlbumSize,
|
||||||
maxWidth: maxAlbumSize,
|
maxWidth: maxAlbumSize,
|
||||||
child: Hero(
|
child: Hero(
|
||||||
@ -91,15 +90,13 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(
|
borderRadius:
|
||||||
Radius.circular(16),
|
const BorderRadius.all(Radius.circular(16)),
|
||||||
),
|
|
||||||
child: _albumArt != null
|
child: _albumArt != null
|
||||||
? AutoCacheImage(
|
? AutoCacheImage(
|
||||||
_albumArt!,
|
_albumArt!,
|
||||||
width: albumSize,
|
width: albumSize,
|
||||||
height: albumSize,
|
height: albumSize,
|
||||||
fit: BoxFit.cover,
|
|
||||||
)
|
)
|
||||||
: Container(
|
: Container(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
@ -116,7 +113,6 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const Gap(24),
|
const Gap(24),
|
||||||
Obx(
|
Obx(
|
||||||
() => Row(
|
() => Row(
|
||||||
@ -313,12 +309,10 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Gap(20),
|
const Gap(20),
|
||||||
Center(
|
SizedBox(
|
||||||
child: SizedBox(
|
|
||||||
height: 40,
|
height: 40,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
shrinkWrap: true,
|
|
||||||
children: [
|
children: [
|
||||||
TextButton.icon(
|
TextButton.icon(
|
||||||
icon: const Icon(Icons.queue_music),
|
icon: const Icon(Icons.queue_music),
|
||||||
@ -397,7 +391,6 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -7,7 +7,6 @@ import 'package:rhythm_box/providers/spotify.dart';
|
|||||||
import 'package:rhythm_box/providers/user_preferences.dart';
|
import 'package:rhythm_box/providers/user_preferences.dart';
|
||||||
import 'package:rhythm_box/screens/auth/login.dart';
|
import 'package:rhythm_box/screens/auth/login.dart';
|
||||||
import 'package:rhythm_box/services/database/database.dart';
|
import 'package:rhythm_box/services/database/database.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
|
||||||
import 'package:rhythm_box/widgets/auto_cache_image.dart';
|
import 'package:rhythm_box/widgets/auto_cache_image.dart';
|
||||||
import 'package:rhythm_box/widgets/sized_container.dart';
|
import 'package:rhythm_box/widgets/sized_container.dart';
|
||||||
|
|
||||||
@ -87,75 +86,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
Obx(() {
|
|
||||||
if (_authenticate.auth.value == null) {
|
|
||||||
return const SizedBox();
|
|
||||||
}
|
|
||||||
if (_authenticate.auth.value?.neteaseCookie == null) {
|
|
||||||
return ListTile(
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
leading: const Icon(Icons.cloud_outlined),
|
|
||||||
title: const Text('Connect with Netease Cloud Music'),
|
|
||||||
subtitle: const Text(
|
|
||||||
'Make us able to play more music from Netease Cloud Music'),
|
|
||||||
trailing: const Icon(Icons.chevron_right),
|
|
||||||
enabled: !_isLoggingIn,
|
|
||||||
onTap: () async {
|
|
||||||
setState(() => _isLoggingIn = true);
|
|
||||||
await GoRouter.of(context)
|
|
||||||
.pushNamed('authMobileLoginNetease');
|
|
||||||
setState(() => _isLoggingIn = false);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FutureBuilder(
|
|
||||||
future: NeteaseSourcedTrack.getClient().get('/user/account'),
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (!snapshot.hasData) {
|
|
||||||
return ListTile(
|
|
||||||
contentPadding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
leading: const SizedBox(
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
strokeWidth: 3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: const Text('Loading...'),
|
|
||||||
trailing: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
_authenticate.logoutNetease();
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.link_off),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ListTile(
|
|
||||||
leading:
|
|
||||||
snapshot.data!.body['profile']['avatarUrl'] != null
|
|
||||||
? CircleAvatar(
|
|
||||||
backgroundImage: AutoCacheImage.provider(
|
|
||||||
snapshot.data!.body['profile']['avatarUrl'],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: const Icon(Icons.account_circle),
|
|
||||||
title: Text(snapshot.data!.body['profile']['nickname']),
|
|
||||||
subtitle: const Text(
|
|
||||||
'Connected with your Netease Cloud Music account',
|
|
||||||
),
|
|
||||||
trailing: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
_authenticate.logoutNetease();
|
|
||||||
},
|
|
||||||
icon: const Icon(Icons.link_off),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (_authenticate.auth.value == null) {
|
if (_authenticate.auth.value == null) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
@ -165,7 +95,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
leading: const Icon(Icons.logout),
|
leading: const Icon(Icons.logout),
|
||||||
title: const Text('Log out'),
|
title: const Text('Log out'),
|
||||||
subtitle: const Text('Disconnect with every account'),
|
subtitle: const Text('Disconnect with this Spotify account'),
|
||||||
trailing: const Icon(Icons.chevron_right),
|
trailing: const Icon(Icons.chevron_right),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
_authenticate.logout();
|
_authenticate.logout();
|
||||||
@ -220,44 +150,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(thickness: 0.3, height: 1),
|
const Divider(thickness: 0.3, height: 1),
|
||||||
Obx(
|
|
||||||
() => CheckboxListTile(
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
secondary: const Icon(Icons.update),
|
|
||||||
title: const Text('Override Cache Provider'),
|
|
||||||
subtitle: const Text(
|
|
||||||
'Decide whether use original cached source or query a new one from current audio provider'),
|
|
||||||
value: _preferences.state.value.overrideCacheProvider,
|
|
||||||
onChanged: (value) =>
|
|
||||||
_preferences.setOverrideCacheProvider(value ?? false),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Obx(
|
|
||||||
() => Column(
|
|
||||||
children: [
|
|
||||||
const ListTile(
|
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
leading: Icon(Icons.cloud),
|
|
||||||
title: Text('Netease Cloud Music API'),
|
|
||||||
subtitle: Text(
|
|
||||||
'Use your own endpoint to prevent IP throttling and more'),
|
|
||||||
),
|
|
||||||
TextFormField(
|
|
||||||
initialValue: _preferences.state.value.neteaseApiInstance,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'Endpoint URL',
|
|
||||||
isDense: true,
|
|
||||||
),
|
|
||||||
onChanged: (value) {
|
|
||||||
_preferences.setNeteaseApiInstance(value);
|
|
||||||
},
|
|
||||||
onTapOutside: (_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
).paddingOnly(left: 24, right: 24, bottom: 12),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(thickness: 0.3, height: 1),
|
|
||||||
Obx(
|
Obx(
|
||||||
() => SwitchListTile(
|
() => SwitchListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
@ -65,10 +65,7 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
},
|
},
|
||||||
onUpgrade: (Migrator m, int from, int to) async {
|
onUpgrade: (Migrator m, int from, int to) async {
|
||||||
if (from < 2) {
|
if (from < 2) {
|
||||||
await m.addColumn(
|
await m.addColumn(preferencesTable, preferencesTable.playerWakelock);
|
||||||
preferencesTable,
|
|
||||||
preferencesTable.overrideCacheProvider,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -18,54 +18,29 @@ class $AuthenticationTableTable extends AuthenticationTable
|
|||||||
requiredDuringInsert: false,
|
requiredDuringInsert: false,
|
||||||
defaultConstraints:
|
defaultConstraints:
|
||||||
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
||||||
static const VerificationMeta _spotifyCookieMeta =
|
static const VerificationMeta _cookieMeta = const VerificationMeta('cookie');
|
||||||
const VerificationMeta('spotifyCookie');
|
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumnWithTypeConverter<DecryptedText, String>
|
late final GeneratedColumnWithTypeConverter<DecryptedText, String> cookie =
|
||||||
spotifyCookie = GeneratedColumn<String>(
|
GeneratedColumn<String>('cookie', aliasedName, false,
|
||||||
'spotify_cookie', aliasedName, false,
|
|
||||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||||
.withConverter<DecryptedText>(
|
.withConverter<DecryptedText>(
|
||||||
$AuthenticationTableTable.$converterspotifyCookie);
|
$AuthenticationTableTable.$convertercookie);
|
||||||
static const VerificationMeta _spotifyAccessTokenMeta =
|
static const VerificationMeta _accessTokenMeta =
|
||||||
const VerificationMeta('spotifyAccessToken');
|
const VerificationMeta('accessToken');
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumnWithTypeConverter<DecryptedText, String>
|
late final GeneratedColumnWithTypeConverter<DecryptedText, String>
|
||||||
spotifyAccessToken = GeneratedColumn<String>(
|
accessToken = GeneratedColumn<String>('access_token', aliasedName, false,
|
||||||
'spotify_access_token', aliasedName, false,
|
|
||||||
type: DriftSqlType.string, requiredDuringInsert: true)
|
type: DriftSqlType.string, requiredDuringInsert: true)
|
||||||
.withConverter<DecryptedText>(
|
.withConverter<DecryptedText>(
|
||||||
$AuthenticationTableTable.$converterspotifyAccessToken);
|
$AuthenticationTableTable.$converteraccessToken);
|
||||||
static const VerificationMeta _spotifyExpirationMeta =
|
static const VerificationMeta _expirationMeta =
|
||||||
const VerificationMeta('spotifyExpiration');
|
const VerificationMeta('expiration');
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumn<DateTime> spotifyExpiration =
|
late final GeneratedColumn<DateTime> expiration = GeneratedColumn<DateTime>(
|
||||||
GeneratedColumn<DateTime>('spotify_expiration', aliasedName, false,
|
'expiration', aliasedName, false,
|
||||||
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
||||||
static const VerificationMeta _neteaseCookieMeta =
|
|
||||||
const VerificationMeta('neteaseCookie');
|
|
||||||
@override
|
@override
|
||||||
late final GeneratedColumnWithTypeConverter<DecryptedText?, String>
|
List<GeneratedColumn> get $columns => [id, cookie, accessToken, expiration];
|
||||||
neteaseCookie = GeneratedColumn<String>(
|
|
||||||
'netease_cookie', aliasedName, true,
|
|
||||||
type: DriftSqlType.string, requiredDuringInsert: false)
|
|
||||||
.withConverter<DecryptedText?>(
|
|
||||||
$AuthenticationTableTable.$converterneteaseCookien);
|
|
||||||
static const VerificationMeta _neteaseExpirationMeta =
|
|
||||||
const VerificationMeta('neteaseExpiration');
|
|
||||||
@override
|
|
||||||
late final GeneratedColumn<DateTime> neteaseExpiration =
|
|
||||||
GeneratedColumn<DateTime>('netease_expiration', aliasedName, true,
|
|
||||||
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
||||||
@override
|
|
||||||
List<GeneratedColumn> get $columns => [
|
|
||||||
id,
|
|
||||||
spotifyCookie,
|
|
||||||
spotifyAccessToken,
|
|
||||||
spotifyExpiration,
|
|
||||||
neteaseCookie,
|
|
||||||
neteaseExpiration
|
|
||||||
];
|
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@override
|
@override
|
||||||
@ -80,22 +55,15 @@ class $AuthenticationTableTable extends AuthenticationTable
|
|||||||
if (data.containsKey('id')) {
|
if (data.containsKey('id')) {
|
||||||
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
||||||
}
|
}
|
||||||
context.handle(_spotifyCookieMeta, const VerificationResult.success());
|
context.handle(_cookieMeta, const VerificationResult.success());
|
||||||
context.handle(_spotifyAccessTokenMeta, const VerificationResult.success());
|
context.handle(_accessTokenMeta, const VerificationResult.success());
|
||||||
if (data.containsKey('spotify_expiration')) {
|
if (data.containsKey('expiration')) {
|
||||||
context.handle(
|
context.handle(
|
||||||
_spotifyExpirationMeta,
|
_expirationMeta,
|
||||||
spotifyExpiration.isAcceptableOrUnknown(
|
expiration.isAcceptableOrUnknown(
|
||||||
data['spotify_expiration']!, _spotifyExpirationMeta));
|
data['expiration']!, _expirationMeta));
|
||||||
} else if (isInserting) {
|
} else if (isInserting) {
|
||||||
context.missing(_spotifyExpirationMeta);
|
context.missing(_expirationMeta);
|
||||||
}
|
|
||||||
context.handle(_neteaseCookieMeta, const VerificationResult.success());
|
|
||||||
if (data.containsKey('netease_expiration')) {
|
|
||||||
context.handle(
|
|
||||||
_neteaseExpirationMeta,
|
|
||||||
neteaseExpiration.isAcceptableOrUnknown(
|
|
||||||
data['netease_expiration']!, _neteaseExpirationMeta));
|
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
@ -109,19 +77,14 @@ class $AuthenticationTableTable extends AuthenticationTable
|
|||||||
return AuthenticationTableData(
|
return AuthenticationTableData(
|
||||||
id: attachedDatabase.typeMapping
|
id: attachedDatabase.typeMapping
|
||||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||||
spotifyCookie: $AuthenticationTableTable.$converterspotifyCookie.fromSql(
|
cookie: $AuthenticationTableTable.$convertercookie.fromSql(
|
||||||
|
attachedDatabase.typeMapping
|
||||||
|
.read(DriftSqlType.string, data['${effectivePrefix}cookie'])!),
|
||||||
|
accessToken: $AuthenticationTableTable.$converteraccessToken.fromSql(
|
||||||
attachedDatabase.typeMapping.read(
|
attachedDatabase.typeMapping.read(
|
||||||
DriftSqlType.string, data['${effectivePrefix}spotify_cookie'])!),
|
DriftSqlType.string, data['${effectivePrefix}access_token'])!),
|
||||||
spotifyAccessToken: $AuthenticationTableTable.$converterspotifyAccessToken
|
expiration: attachedDatabase.typeMapping
|
||||||
.fromSql(attachedDatabase.typeMapping.read(DriftSqlType.string,
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}expiration'])!,
|
||||||
data['${effectivePrefix}spotify_access_token'])!),
|
|
||||||
spotifyExpiration: attachedDatabase.typeMapping.read(
|
|
||||||
DriftSqlType.dateTime, data['${effectivePrefix}spotify_expiration'])!,
|
|
||||||
neteaseCookie: $AuthenticationTableTable.$converterneteaseCookien.fromSql(
|
|
||||||
attachedDatabase.typeMapping.read(
|
|
||||||
DriftSqlType.string, data['${effectivePrefix}netease_cookie'])),
|
|
||||||
neteaseExpiration: attachedDatabase.typeMapping.read(
|
|
||||||
DriftSqlType.dateTime, data['${effectivePrefix}netease_expiration']),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,69 +93,45 @@ class $AuthenticationTableTable extends AuthenticationTable
|
|||||||
return $AuthenticationTableTable(attachedDatabase, alias);
|
return $AuthenticationTableTable(attachedDatabase, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
static TypeConverter<DecryptedText, String> $converterspotifyCookie =
|
static TypeConverter<DecryptedText, String> $convertercookie =
|
||||||
EncryptedTextConverter();
|
EncryptedTextConverter();
|
||||||
static TypeConverter<DecryptedText, String> $converterspotifyAccessToken =
|
static TypeConverter<DecryptedText, String> $converteraccessToken =
|
||||||
EncryptedTextConverter();
|
EncryptedTextConverter();
|
||||||
static TypeConverter<DecryptedText, String> $converterneteaseCookie =
|
|
||||||
EncryptedTextConverter();
|
|
||||||
static TypeConverter<DecryptedText?, String?> $converterneteaseCookien =
|
|
||||||
NullAwareTypeConverter.wrap($converterneteaseCookie);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthenticationTableData extends DataClass
|
class AuthenticationTableData extends DataClass
|
||||||
implements Insertable<AuthenticationTableData> {
|
implements Insertable<AuthenticationTableData> {
|
||||||
final int id;
|
final int id;
|
||||||
final DecryptedText spotifyCookie;
|
final DecryptedText cookie;
|
||||||
final DecryptedText spotifyAccessToken;
|
final DecryptedText accessToken;
|
||||||
final DateTime spotifyExpiration;
|
final DateTime expiration;
|
||||||
final DecryptedText? neteaseCookie;
|
|
||||||
final DateTime? neteaseExpiration;
|
|
||||||
const AuthenticationTableData(
|
const AuthenticationTableData(
|
||||||
{required this.id,
|
{required this.id,
|
||||||
required this.spotifyCookie,
|
required this.cookie,
|
||||||
required this.spotifyAccessToken,
|
required this.accessToken,
|
||||||
required this.spotifyExpiration,
|
required this.expiration});
|
||||||
this.neteaseCookie,
|
|
||||||
this.neteaseExpiration});
|
|
||||||
@override
|
@override
|
||||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
final map = <String, Expression>{};
|
final map = <String, Expression>{};
|
||||||
map['id'] = Variable<int>(id);
|
map['id'] = Variable<int>(id);
|
||||||
{
|
{
|
||||||
map['spotify_cookie'] = Variable<String>($AuthenticationTableTable
|
map['cookie'] = Variable<String>(
|
||||||
.$converterspotifyCookie
|
$AuthenticationTableTable.$convertercookie.toSql(cookie));
|
||||||
.toSql(spotifyCookie));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
map['spotify_access_token'] = Variable<String>($AuthenticationTableTable
|
map['access_token'] = Variable<String>(
|
||||||
.$converterspotifyAccessToken
|
$AuthenticationTableTable.$converteraccessToken.toSql(accessToken));
|
||||||
.toSql(spotifyAccessToken));
|
|
||||||
}
|
|
||||||
map['spotify_expiration'] = Variable<DateTime>(spotifyExpiration);
|
|
||||||
if (!nullToAbsent || neteaseCookie != null) {
|
|
||||||
map['netease_cookie'] = Variable<String>($AuthenticationTableTable
|
|
||||||
.$converterneteaseCookien
|
|
||||||
.toSql(neteaseCookie));
|
|
||||||
}
|
|
||||||
if (!nullToAbsent || neteaseExpiration != null) {
|
|
||||||
map['netease_expiration'] = Variable<DateTime>(neteaseExpiration);
|
|
||||||
}
|
}
|
||||||
|
map['expiration'] = Variable<DateTime>(expiration);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationTableCompanion toCompanion(bool nullToAbsent) {
|
AuthenticationTableCompanion toCompanion(bool nullToAbsent) {
|
||||||
return AuthenticationTableCompanion(
|
return AuthenticationTableCompanion(
|
||||||
id: Value(id),
|
id: Value(id),
|
||||||
spotifyCookie: Value(spotifyCookie),
|
cookie: Value(cookie),
|
||||||
spotifyAccessToken: Value(spotifyAccessToken),
|
accessToken: Value(accessToken),
|
||||||
spotifyExpiration: Value(spotifyExpiration),
|
expiration: Value(expiration),
|
||||||
neteaseCookie: neteaseCookie == null && nullToAbsent
|
|
||||||
? const Value.absent()
|
|
||||||
: Value(neteaseCookie),
|
|
||||||
neteaseExpiration: neteaseExpiration == null && nullToAbsent
|
|
||||||
? const Value.absent()
|
|
||||||
: Value(neteaseExpiration),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,14 +140,9 @@ class AuthenticationTableData extends DataClass
|
|||||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
return AuthenticationTableData(
|
return AuthenticationTableData(
|
||||||
id: serializer.fromJson<int>(json['id']),
|
id: serializer.fromJson<int>(json['id']),
|
||||||
spotifyCookie: serializer.fromJson<DecryptedText>(json['spotifyCookie']),
|
cookie: serializer.fromJson<DecryptedText>(json['cookie']),
|
||||||
spotifyAccessToken:
|
accessToken: serializer.fromJson<DecryptedText>(json['accessToken']),
|
||||||
serializer.fromJson<DecryptedText>(json['spotifyAccessToken']),
|
expiration: serializer.fromJson<DateTime>(json['expiration']),
|
||||||
spotifyExpiration:
|
|
||||||
serializer.fromJson<DateTime>(json['spotifyExpiration']),
|
|
||||||
neteaseCookie: serializer.fromJson<DecryptedText?>(json['neteaseCookie']),
|
|
||||||
neteaseExpiration:
|
|
||||||
serializer.fromJson<DateTime?>(json['neteaseExpiration']),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@ -216,51 +150,31 @@ class AuthenticationTableData extends DataClass
|
|||||||
serializer ??= driftRuntimeOptions.defaultSerializer;
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
||||||
return <String, dynamic>{
|
return <String, dynamic>{
|
||||||
'id': serializer.toJson<int>(id),
|
'id': serializer.toJson<int>(id),
|
||||||
'spotifyCookie': serializer.toJson<DecryptedText>(spotifyCookie),
|
'cookie': serializer.toJson<DecryptedText>(cookie),
|
||||||
'spotifyAccessToken':
|
'accessToken': serializer.toJson<DecryptedText>(accessToken),
|
||||||
serializer.toJson<DecryptedText>(spotifyAccessToken),
|
'expiration': serializer.toJson<DateTime>(expiration),
|
||||||
'spotifyExpiration': serializer.toJson<DateTime>(spotifyExpiration),
|
|
||||||
'neteaseCookie': serializer.toJson<DecryptedText?>(neteaseCookie),
|
|
||||||
'neteaseExpiration': serializer.toJson<DateTime?>(neteaseExpiration),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationTableData copyWith(
|
AuthenticationTableData copyWith(
|
||||||
{int? id,
|
{int? id,
|
||||||
DecryptedText? spotifyCookie,
|
DecryptedText? cookie,
|
||||||
DecryptedText? spotifyAccessToken,
|
DecryptedText? accessToken,
|
||||||
DateTime? spotifyExpiration,
|
DateTime? expiration}) =>
|
||||||
Value<DecryptedText?> neteaseCookie = const Value.absent(),
|
|
||||||
Value<DateTime?> neteaseExpiration = const Value.absent()}) =>
|
|
||||||
AuthenticationTableData(
|
AuthenticationTableData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
spotifyCookie: spotifyCookie ?? this.spotifyCookie,
|
cookie: cookie ?? this.cookie,
|
||||||
spotifyAccessToken: spotifyAccessToken ?? this.spotifyAccessToken,
|
accessToken: accessToken ?? this.accessToken,
|
||||||
spotifyExpiration: spotifyExpiration ?? this.spotifyExpiration,
|
expiration: expiration ?? this.expiration,
|
||||||
neteaseCookie:
|
|
||||||
neteaseCookie.present ? neteaseCookie.value : this.neteaseCookie,
|
|
||||||
neteaseExpiration: neteaseExpiration.present
|
|
||||||
? neteaseExpiration.value
|
|
||||||
: this.neteaseExpiration,
|
|
||||||
);
|
);
|
||||||
AuthenticationTableData copyWithCompanion(AuthenticationTableCompanion data) {
|
AuthenticationTableData copyWithCompanion(AuthenticationTableCompanion data) {
|
||||||
return AuthenticationTableData(
|
return AuthenticationTableData(
|
||||||
id: data.id.present ? data.id.value : this.id,
|
id: data.id.present ? data.id.value : this.id,
|
||||||
spotifyCookie: data.spotifyCookie.present
|
cookie: data.cookie.present ? data.cookie.value : this.cookie,
|
||||||
? data.spotifyCookie.value
|
accessToken:
|
||||||
: this.spotifyCookie,
|
data.accessToken.present ? data.accessToken.value : this.accessToken,
|
||||||
spotifyAccessToken: data.spotifyAccessToken.present
|
expiration:
|
||||||
? data.spotifyAccessToken.value
|
data.expiration.present ? data.expiration.value : this.expiration,
|
||||||
: this.spotifyAccessToken,
|
|
||||||
spotifyExpiration: data.spotifyExpiration.present
|
|
||||||
? data.spotifyExpiration.value
|
|
||||||
: this.spotifyExpiration,
|
|
||||||
neteaseCookie: data.neteaseCookie.present
|
|
||||||
? data.neteaseCookie.value
|
|
||||||
: this.neteaseCookie,
|
|
||||||
neteaseExpiration: data.neteaseExpiration.present
|
|
||||||
? data.neteaseExpiration.value
|
|
||||||
: this.neteaseExpiration,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,89 +182,69 @@ class AuthenticationTableData extends DataClass
|
|||||||
String toString() {
|
String toString() {
|
||||||
return (StringBuffer('AuthenticationTableData(')
|
return (StringBuffer('AuthenticationTableData(')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('spotifyCookie: $spotifyCookie, ')
|
..write('cookie: $cookie, ')
|
||||||
..write('spotifyAccessToken: $spotifyAccessToken, ')
|
..write('accessToken: $accessToken, ')
|
||||||
..write('spotifyExpiration: $spotifyExpiration, ')
|
..write('expiration: $expiration')
|
||||||
..write('neteaseCookie: $neteaseCookie, ')
|
|
||||||
..write('neteaseExpiration: $neteaseExpiration')
|
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => Object.hash(id, spotifyCookie, spotifyAccessToken,
|
int get hashCode => Object.hash(id, cookie, accessToken, expiration);
|
||||||
spotifyExpiration, neteaseCookie, neteaseExpiration);
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
identical(this, other) ||
|
identical(this, other) ||
|
||||||
(other is AuthenticationTableData &&
|
(other is AuthenticationTableData &&
|
||||||
other.id == this.id &&
|
other.id == this.id &&
|
||||||
other.spotifyCookie == this.spotifyCookie &&
|
other.cookie == this.cookie &&
|
||||||
other.spotifyAccessToken == this.spotifyAccessToken &&
|
other.accessToken == this.accessToken &&
|
||||||
other.spotifyExpiration == this.spotifyExpiration &&
|
other.expiration == this.expiration);
|
||||||
other.neteaseCookie == this.neteaseCookie &&
|
|
||||||
other.neteaseExpiration == this.neteaseExpiration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AuthenticationTableCompanion
|
class AuthenticationTableCompanion
|
||||||
extends UpdateCompanion<AuthenticationTableData> {
|
extends UpdateCompanion<AuthenticationTableData> {
|
||||||
final Value<int> id;
|
final Value<int> id;
|
||||||
final Value<DecryptedText> spotifyCookie;
|
final Value<DecryptedText> cookie;
|
||||||
final Value<DecryptedText> spotifyAccessToken;
|
final Value<DecryptedText> accessToken;
|
||||||
final Value<DateTime> spotifyExpiration;
|
final Value<DateTime> expiration;
|
||||||
final Value<DecryptedText?> neteaseCookie;
|
|
||||||
final Value<DateTime?> neteaseExpiration;
|
|
||||||
const AuthenticationTableCompanion({
|
const AuthenticationTableCompanion({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
this.spotifyCookie = const Value.absent(),
|
this.cookie = const Value.absent(),
|
||||||
this.spotifyAccessToken = const Value.absent(),
|
this.accessToken = const Value.absent(),
|
||||||
this.spotifyExpiration = const Value.absent(),
|
this.expiration = const Value.absent(),
|
||||||
this.neteaseCookie = const Value.absent(),
|
|
||||||
this.neteaseExpiration = const Value.absent(),
|
|
||||||
});
|
});
|
||||||
AuthenticationTableCompanion.insert({
|
AuthenticationTableCompanion.insert({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
required DecryptedText spotifyCookie,
|
required DecryptedText cookie,
|
||||||
required DecryptedText spotifyAccessToken,
|
required DecryptedText accessToken,
|
||||||
required DateTime spotifyExpiration,
|
required DateTime expiration,
|
||||||
this.neteaseCookie = const Value.absent(),
|
}) : cookie = Value(cookie),
|
||||||
this.neteaseExpiration = const Value.absent(),
|
accessToken = Value(accessToken),
|
||||||
}) : spotifyCookie = Value(spotifyCookie),
|
expiration = Value(expiration);
|
||||||
spotifyAccessToken = Value(spotifyAccessToken),
|
|
||||||
spotifyExpiration = Value(spotifyExpiration);
|
|
||||||
static Insertable<AuthenticationTableData> custom({
|
static Insertable<AuthenticationTableData> custom({
|
||||||
Expression<int>? id,
|
Expression<int>? id,
|
||||||
Expression<String>? spotifyCookie,
|
Expression<String>? cookie,
|
||||||
Expression<String>? spotifyAccessToken,
|
Expression<String>? accessToken,
|
||||||
Expression<DateTime>? spotifyExpiration,
|
Expression<DateTime>? expiration,
|
||||||
Expression<String>? neteaseCookie,
|
|
||||||
Expression<DateTime>? neteaseExpiration,
|
|
||||||
}) {
|
}) {
|
||||||
return RawValuesInsertable({
|
return RawValuesInsertable({
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
if (spotifyCookie != null) 'spotify_cookie': spotifyCookie,
|
if (cookie != null) 'cookie': cookie,
|
||||||
if (spotifyAccessToken != null)
|
if (accessToken != null) 'access_token': accessToken,
|
||||||
'spotify_access_token': spotifyAccessToken,
|
if (expiration != null) 'expiration': expiration,
|
||||||
if (spotifyExpiration != null) 'spotify_expiration': spotifyExpiration,
|
|
||||||
if (neteaseCookie != null) 'netease_cookie': neteaseCookie,
|
|
||||||
if (neteaseExpiration != null) 'netease_expiration': neteaseExpiration,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationTableCompanion copyWith(
|
AuthenticationTableCompanion copyWith(
|
||||||
{Value<int>? id,
|
{Value<int>? id,
|
||||||
Value<DecryptedText>? spotifyCookie,
|
Value<DecryptedText>? cookie,
|
||||||
Value<DecryptedText>? spotifyAccessToken,
|
Value<DecryptedText>? accessToken,
|
||||||
Value<DateTime>? spotifyExpiration,
|
Value<DateTime>? expiration}) {
|
||||||
Value<DecryptedText?>? neteaseCookie,
|
|
||||||
Value<DateTime?>? neteaseExpiration}) {
|
|
||||||
return AuthenticationTableCompanion(
|
return AuthenticationTableCompanion(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
spotifyCookie: spotifyCookie ?? this.spotifyCookie,
|
cookie: cookie ?? this.cookie,
|
||||||
spotifyAccessToken: spotifyAccessToken ?? this.spotifyAccessToken,
|
accessToken: accessToken ?? this.accessToken,
|
||||||
spotifyExpiration: spotifyExpiration ?? this.spotifyExpiration,
|
expiration: expiration ?? this.expiration,
|
||||||
neteaseCookie: neteaseCookie ?? this.neteaseCookie,
|
|
||||||
neteaseExpiration: neteaseExpiration ?? this.neteaseExpiration,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,26 +254,17 @@ class AuthenticationTableCompanion
|
|||||||
if (id.present) {
|
if (id.present) {
|
||||||
map['id'] = Variable<int>(id.value);
|
map['id'] = Variable<int>(id.value);
|
||||||
}
|
}
|
||||||
if (spotifyCookie.present) {
|
if (cookie.present) {
|
||||||
map['spotify_cookie'] = Variable<String>($AuthenticationTableTable
|
map['cookie'] = Variable<String>(
|
||||||
.$converterspotifyCookie
|
$AuthenticationTableTable.$convertercookie.toSql(cookie.value));
|
||||||
.toSql(spotifyCookie.value));
|
|
||||||
}
|
}
|
||||||
if (spotifyAccessToken.present) {
|
if (accessToken.present) {
|
||||||
map['spotify_access_token'] = Variable<String>($AuthenticationTableTable
|
map['access_token'] = Variable<String>($AuthenticationTableTable
|
||||||
.$converterspotifyAccessToken
|
.$converteraccessToken
|
||||||
.toSql(spotifyAccessToken.value));
|
.toSql(accessToken.value));
|
||||||
}
|
}
|
||||||
if (spotifyExpiration.present) {
|
if (expiration.present) {
|
||||||
map['spotify_expiration'] = Variable<DateTime>(spotifyExpiration.value);
|
map['expiration'] = Variable<DateTime>(expiration.value);
|
||||||
}
|
|
||||||
if (neteaseCookie.present) {
|
|
||||||
map['netease_cookie'] = Variable<String>($AuthenticationTableTable
|
|
||||||
.$converterneteaseCookien
|
|
||||||
.toSql(neteaseCookie.value));
|
|
||||||
}
|
|
||||||
if (neteaseExpiration.present) {
|
|
||||||
map['netease_expiration'] = Variable<DateTime>(neteaseExpiration.value);
|
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@ -388,11 +273,9 @@ class AuthenticationTableCompanion
|
|||||||
String toString() {
|
String toString() {
|
||||||
return (StringBuffer('AuthenticationTableCompanion(')
|
return (StringBuffer('AuthenticationTableCompanion(')
|
||||||
..write('id: $id, ')
|
..write('id: $id, ')
|
||||||
..write('spotifyCookie: $spotifyCookie, ')
|
..write('cookie: $cookie, ')
|
||||||
..write('spotifyAccessToken: $spotifyAccessToken, ')
|
..write('accessToken: $accessToken, ')
|
||||||
..write('spotifyExpiration: $spotifyExpiration, ')
|
..write('expiration: $expiration')
|
||||||
..write('neteaseCookie: $neteaseCookie, ')
|
|
||||||
..write('neteaseExpiration: $neteaseExpiration')
|
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
@ -640,16 +523,6 @@ class $PreferencesTableTable extends PreferencesTable
|
|||||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
||||||
'CHECK ("player_wakelock" IN (0, 1))'),
|
'CHECK ("player_wakelock" IN (0, 1))'),
|
||||||
defaultValue: const Constant(true));
|
defaultValue: const Constant(true));
|
||||||
static const VerificationMeta _overrideCacheProviderMeta =
|
|
||||||
const VerificationMeta('overrideCacheProvider');
|
|
||||||
@override
|
|
||||||
late final GeneratedColumn<bool> overrideCacheProvider =
|
|
||||||
GeneratedColumn<bool>('override_cache_provider', aliasedName, false,
|
|
||||||
type: DriftSqlType.bool,
|
|
||||||
requiredDuringInsert: false,
|
|
||||||
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
||||||
'CHECK ("override_cache_provider" IN (0, 1))'),
|
|
||||||
defaultValue: const Constant(true));
|
|
||||||
@override
|
@override
|
||||||
List<GeneratedColumn> get $columns => [
|
List<GeneratedColumn> get $columns => [
|
||||||
id,
|
id,
|
||||||
@ -675,8 +548,7 @@ class $PreferencesTableTable extends PreferencesTable
|
|||||||
streamMusicCodec,
|
streamMusicCodec,
|
||||||
downloadMusicCodec,
|
downloadMusicCodec,
|
||||||
endlessPlayback,
|
endlessPlayback,
|
||||||
playerWakelock,
|
playerWakelock
|
||||||
overrideCacheProvider
|
|
||||||
];
|
];
|
||||||
@override
|
@override
|
||||||
String get aliasedName => _alias ?? actualTableName;
|
String get aliasedName => _alias ?? actualTableName;
|
||||||
@ -771,12 +643,6 @@ class $PreferencesTableTable extends PreferencesTable
|
|||||||
playerWakelock.isAcceptableOrUnknown(
|
playerWakelock.isAcceptableOrUnknown(
|
||||||
data['player_wakelock']!, _playerWakelockMeta));
|
data['player_wakelock']!, _playerWakelockMeta));
|
||||||
}
|
}
|
||||||
if (data.containsKey('override_cache_provider')) {
|
|
||||||
context.handle(
|
|
||||||
_overrideCacheProviderMeta,
|
|
||||||
overrideCacheProvider.isAcceptableOrUnknown(
|
|
||||||
data['override_cache_provider']!, _overrideCacheProviderMeta));
|
|
||||||
}
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -847,9 +713,6 @@ class $PreferencesTableTable extends PreferencesTable
|
|||||||
.read(DriftSqlType.bool, data['${effectivePrefix}endless_playback'])!,
|
.read(DriftSqlType.bool, data['${effectivePrefix}endless_playback'])!,
|
||||||
playerWakelock: attachedDatabase.typeMapping
|
playerWakelock: attachedDatabase.typeMapping
|
||||||
.read(DriftSqlType.bool, data['${effectivePrefix}player_wakelock'])!,
|
.read(DriftSqlType.bool, data['${effectivePrefix}player_wakelock'])!,
|
||||||
overrideCacheProvider: attachedDatabase.typeMapping.read(
|
|
||||||
DriftSqlType.bool,
|
|
||||||
data['${effectivePrefix}override_cache_provider'])!,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,7 +777,6 @@ class PreferencesTableData extends DataClass
|
|||||||
final SourceCodecs downloadMusicCodec;
|
final SourceCodecs downloadMusicCodec;
|
||||||
final bool endlessPlayback;
|
final bool endlessPlayback;
|
||||||
final bool playerWakelock;
|
final bool playerWakelock;
|
||||||
final bool overrideCacheProvider;
|
|
||||||
const PreferencesTableData(
|
const PreferencesTableData(
|
||||||
{required this.id,
|
{required this.id,
|
||||||
required this.audioQuality,
|
required this.audioQuality,
|
||||||
@ -939,8 +801,7 @@ class PreferencesTableData extends DataClass
|
|||||||
required this.streamMusicCodec,
|
required this.streamMusicCodec,
|
||||||
required this.downloadMusicCodec,
|
required this.downloadMusicCodec,
|
||||||
required this.endlessPlayback,
|
required this.endlessPlayback,
|
||||||
required this.playerWakelock,
|
required this.playerWakelock});
|
||||||
required this.overrideCacheProvider});
|
|
||||||
@override
|
@override
|
||||||
Map<String, Expression> toColumns(bool nullToAbsent) {
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
||||||
final map = <String, Expression>{};
|
final map = <String, Expression>{};
|
||||||
@ -1008,7 +869,6 @@ class PreferencesTableData extends DataClass
|
|||||||
}
|
}
|
||||||
map['endless_playback'] = Variable<bool>(endlessPlayback);
|
map['endless_playback'] = Variable<bool>(endlessPlayback);
|
||||||
map['player_wakelock'] = Variable<bool>(playerWakelock);
|
map['player_wakelock'] = Variable<bool>(playerWakelock);
|
||||||
map['override_cache_provider'] = Variable<bool>(overrideCacheProvider);
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1038,7 +898,6 @@ class PreferencesTableData extends DataClass
|
|||||||
downloadMusicCodec: Value(downloadMusicCodec),
|
downloadMusicCodec: Value(downloadMusicCodec),
|
||||||
endlessPlayback: Value(endlessPlayback),
|
endlessPlayback: Value(endlessPlayback),
|
||||||
playerWakelock: Value(playerWakelock),
|
playerWakelock: Value(playerWakelock),
|
||||||
overrideCacheProvider: Value(overrideCacheProvider),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,8 +941,6 @@ class PreferencesTableData extends DataClass
|
|||||||
.fromJson(serializer.fromJson<String>(json['downloadMusicCodec'])),
|
.fromJson(serializer.fromJson<String>(json['downloadMusicCodec'])),
|
||||||
endlessPlayback: serializer.fromJson<bool>(json['endlessPlayback']),
|
endlessPlayback: serializer.fromJson<bool>(json['endlessPlayback']),
|
||||||
playerWakelock: serializer.fromJson<bool>(json['playerWakelock']),
|
playerWakelock: serializer.fromJson<bool>(json['playerWakelock']),
|
||||||
overrideCacheProvider:
|
|
||||||
serializer.fromJson<bool>(json['overrideCacheProvider']),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
@ -1126,7 +983,6 @@ class PreferencesTableData extends DataClass
|
|||||||
.toJson(downloadMusicCodec)),
|
.toJson(downloadMusicCodec)),
|
||||||
'endlessPlayback': serializer.toJson<bool>(endlessPlayback),
|
'endlessPlayback': serializer.toJson<bool>(endlessPlayback),
|
||||||
'playerWakelock': serializer.toJson<bool>(playerWakelock),
|
'playerWakelock': serializer.toJson<bool>(playerWakelock),
|
||||||
'overrideCacheProvider': serializer.toJson<bool>(overrideCacheProvider),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1154,8 +1010,7 @@ class PreferencesTableData extends DataClass
|
|||||||
SourceCodecs? streamMusicCodec,
|
SourceCodecs? streamMusicCodec,
|
||||||
SourceCodecs? downloadMusicCodec,
|
SourceCodecs? downloadMusicCodec,
|
||||||
bool? endlessPlayback,
|
bool? endlessPlayback,
|
||||||
bool? playerWakelock,
|
bool? playerWakelock}) =>
|
||||||
bool? overrideCacheProvider}) =>
|
|
||||||
PreferencesTableData(
|
PreferencesTableData(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
audioQuality: audioQuality ?? this.audioQuality,
|
audioQuality: audioQuality ?? this.audioQuality,
|
||||||
@ -1181,8 +1036,6 @@ class PreferencesTableData extends DataClass
|
|||||||
downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec,
|
downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec,
|
||||||
endlessPlayback: endlessPlayback ?? this.endlessPlayback,
|
endlessPlayback: endlessPlayback ?? this.endlessPlayback,
|
||||||
playerWakelock: playerWakelock ?? this.playerWakelock,
|
playerWakelock: playerWakelock ?? this.playerWakelock,
|
||||||
overrideCacheProvider:
|
|
||||||
overrideCacheProvider ?? this.overrideCacheProvider,
|
|
||||||
);
|
);
|
||||||
PreferencesTableData copyWithCompanion(PreferencesTableCompanion data) {
|
PreferencesTableData copyWithCompanion(PreferencesTableCompanion data) {
|
||||||
return PreferencesTableData(
|
return PreferencesTableData(
|
||||||
@ -1246,9 +1099,6 @@ class PreferencesTableData extends DataClass
|
|||||||
playerWakelock: data.playerWakelock.present
|
playerWakelock: data.playerWakelock.present
|
||||||
? data.playerWakelock.value
|
? data.playerWakelock.value
|
||||||
: this.playerWakelock,
|
: this.playerWakelock,
|
||||||
overrideCacheProvider: data.overrideCacheProvider.present
|
|
||||||
? data.overrideCacheProvider.value
|
|
||||||
: this.overrideCacheProvider,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1278,8 +1128,7 @@ class PreferencesTableData extends DataClass
|
|||||||
..write('streamMusicCodec: $streamMusicCodec, ')
|
..write('streamMusicCodec: $streamMusicCodec, ')
|
||||||
..write('downloadMusicCodec: $downloadMusicCodec, ')
|
..write('downloadMusicCodec: $downloadMusicCodec, ')
|
||||||
..write('endlessPlayback: $endlessPlayback, ')
|
..write('endlessPlayback: $endlessPlayback, ')
|
||||||
..write('playerWakelock: $playerWakelock, ')
|
..write('playerWakelock: $playerWakelock')
|
||||||
..write('overrideCacheProvider: $overrideCacheProvider')
|
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
@ -1309,8 +1158,7 @@ class PreferencesTableData extends DataClass
|
|||||||
streamMusicCodec,
|
streamMusicCodec,
|
||||||
downloadMusicCodec,
|
downloadMusicCodec,
|
||||||
endlessPlayback,
|
endlessPlayback,
|
||||||
playerWakelock,
|
playerWakelock
|
||||||
overrideCacheProvider
|
|
||||||
]);
|
]);
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
@ -1339,8 +1187,7 @@ class PreferencesTableData extends DataClass
|
|||||||
other.streamMusicCodec == this.streamMusicCodec &&
|
other.streamMusicCodec == this.streamMusicCodec &&
|
||||||
other.downloadMusicCodec == this.downloadMusicCodec &&
|
other.downloadMusicCodec == this.downloadMusicCodec &&
|
||||||
other.endlessPlayback == this.endlessPlayback &&
|
other.endlessPlayback == this.endlessPlayback &&
|
||||||
other.playerWakelock == this.playerWakelock &&
|
other.playerWakelock == this.playerWakelock);
|
||||||
other.overrideCacheProvider == this.overrideCacheProvider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
||||||
@ -1368,7 +1215,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
final Value<SourceCodecs> downloadMusicCodec;
|
final Value<SourceCodecs> downloadMusicCodec;
|
||||||
final Value<bool> endlessPlayback;
|
final Value<bool> endlessPlayback;
|
||||||
final Value<bool> playerWakelock;
|
final Value<bool> playerWakelock;
|
||||||
final Value<bool> overrideCacheProvider;
|
|
||||||
const PreferencesTableCompanion({
|
const PreferencesTableCompanion({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
this.audioQuality = const Value.absent(),
|
this.audioQuality = const Value.absent(),
|
||||||
@ -1394,7 +1240,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
this.downloadMusicCodec = const Value.absent(),
|
this.downloadMusicCodec = const Value.absent(),
|
||||||
this.endlessPlayback = const Value.absent(),
|
this.endlessPlayback = const Value.absent(),
|
||||||
this.playerWakelock = const Value.absent(),
|
this.playerWakelock = const Value.absent(),
|
||||||
this.overrideCacheProvider = const Value.absent(),
|
|
||||||
});
|
});
|
||||||
PreferencesTableCompanion.insert({
|
PreferencesTableCompanion.insert({
|
||||||
this.id = const Value.absent(),
|
this.id = const Value.absent(),
|
||||||
@ -1421,7 +1266,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
this.downloadMusicCodec = const Value.absent(),
|
this.downloadMusicCodec = const Value.absent(),
|
||||||
this.endlessPlayback = const Value.absent(),
|
this.endlessPlayback = const Value.absent(),
|
||||||
this.playerWakelock = const Value.absent(),
|
this.playerWakelock = const Value.absent(),
|
||||||
this.overrideCacheProvider = const Value.absent(),
|
|
||||||
});
|
});
|
||||||
static Insertable<PreferencesTableData> custom({
|
static Insertable<PreferencesTableData> custom({
|
||||||
Expression<int>? id,
|
Expression<int>? id,
|
||||||
@ -1448,7 +1292,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
Expression<String>? downloadMusicCodec,
|
Expression<String>? downloadMusicCodec,
|
||||||
Expression<bool>? endlessPlayback,
|
Expression<bool>? endlessPlayback,
|
||||||
Expression<bool>? playerWakelock,
|
Expression<bool>? playerWakelock,
|
||||||
Expression<bool>? overrideCacheProvider,
|
|
||||||
}) {
|
}) {
|
||||||
return RawValuesInsertable({
|
return RawValuesInsertable({
|
||||||
if (id != null) 'id': id,
|
if (id != null) 'id': id,
|
||||||
@ -1479,8 +1322,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
'download_music_codec': downloadMusicCodec,
|
'download_music_codec': downloadMusicCodec,
|
||||||
if (endlessPlayback != null) 'endless_playback': endlessPlayback,
|
if (endlessPlayback != null) 'endless_playback': endlessPlayback,
|
||||||
if (playerWakelock != null) 'player_wakelock': playerWakelock,
|
if (playerWakelock != null) 'player_wakelock': playerWakelock,
|
||||||
if (overrideCacheProvider != null)
|
|
||||||
'override_cache_provider': overrideCacheProvider,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1508,8 +1349,7 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
Value<SourceCodecs>? streamMusicCodec,
|
Value<SourceCodecs>? streamMusicCodec,
|
||||||
Value<SourceCodecs>? downloadMusicCodec,
|
Value<SourceCodecs>? downloadMusicCodec,
|
||||||
Value<bool>? endlessPlayback,
|
Value<bool>? endlessPlayback,
|
||||||
Value<bool>? playerWakelock,
|
Value<bool>? playerWakelock}) {
|
||||||
Value<bool>? overrideCacheProvider}) {
|
|
||||||
return PreferencesTableCompanion(
|
return PreferencesTableCompanion(
|
||||||
id: id ?? this.id,
|
id: id ?? this.id,
|
||||||
audioQuality: audioQuality ?? this.audioQuality,
|
audioQuality: audioQuality ?? this.audioQuality,
|
||||||
@ -1535,8 +1375,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec,
|
downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec,
|
||||||
endlessPlayback: endlessPlayback ?? this.endlessPlayback,
|
endlessPlayback: endlessPlayback ?? this.endlessPlayback,
|
||||||
playerWakelock: playerWakelock ?? this.playerWakelock,
|
playerWakelock: playerWakelock ?? this.playerWakelock,
|
||||||
overrideCacheProvider:
|
|
||||||
overrideCacheProvider ?? this.overrideCacheProvider,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1634,10 +1472,6 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
if (playerWakelock.present) {
|
if (playerWakelock.present) {
|
||||||
map['player_wakelock'] = Variable<bool>(playerWakelock.value);
|
map['player_wakelock'] = Variable<bool>(playerWakelock.value);
|
||||||
}
|
}
|
||||||
if (overrideCacheProvider.present) {
|
|
||||||
map['override_cache_provider'] =
|
|
||||||
Variable<bool>(overrideCacheProvider.value);
|
|
||||||
}
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1667,8 +1501,7 @@ class PreferencesTableCompanion extends UpdateCompanion<PreferencesTableData> {
|
|||||||
..write('streamMusicCodec: $streamMusicCodec, ')
|
..write('streamMusicCodec: $streamMusicCodec, ')
|
||||||
..write('downloadMusicCodec: $downloadMusicCodec, ')
|
..write('downloadMusicCodec: $downloadMusicCodec, ')
|
||||||
..write('endlessPlayback: $endlessPlayback, ')
|
..write('endlessPlayback: $endlessPlayback, ')
|
||||||
..write('playerWakelock: $playerWakelock, ')
|
..write('playerWakelock: $playerWakelock')
|
||||||
..write('overrideCacheProvider: $overrideCacheProvider')
|
|
||||||
..write(')'))
|
..write(')'))
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
@ -3991,20 +3824,16 @@ abstract class _$AppDatabase extends GeneratedDatabase {
|
|||||||
typedef $$AuthenticationTableTableCreateCompanionBuilder
|
typedef $$AuthenticationTableTableCreateCompanionBuilder
|
||||||
= AuthenticationTableCompanion Function({
|
= AuthenticationTableCompanion Function({
|
||||||
Value<int> id,
|
Value<int> id,
|
||||||
required DecryptedText spotifyCookie,
|
required DecryptedText cookie,
|
||||||
required DecryptedText spotifyAccessToken,
|
required DecryptedText accessToken,
|
||||||
required DateTime spotifyExpiration,
|
required DateTime expiration,
|
||||||
Value<DecryptedText?> neteaseCookie,
|
|
||||||
Value<DateTime?> neteaseExpiration,
|
|
||||||
});
|
});
|
||||||
typedef $$AuthenticationTableTableUpdateCompanionBuilder
|
typedef $$AuthenticationTableTableUpdateCompanionBuilder
|
||||||
= AuthenticationTableCompanion Function({
|
= AuthenticationTableCompanion Function({
|
||||||
Value<int> id,
|
Value<int> id,
|
||||||
Value<DecryptedText> spotifyCookie,
|
Value<DecryptedText> cookie,
|
||||||
Value<DecryptedText> spotifyAccessToken,
|
Value<DecryptedText> accessToken,
|
||||||
Value<DateTime> spotifyExpiration,
|
Value<DateTime> expiration,
|
||||||
Value<DecryptedText?> neteaseCookie,
|
|
||||||
Value<DateTime?> neteaseExpiration,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
class $$AuthenticationTableTableTableManager extends RootTableManager<
|
class $$AuthenticationTableTableTableManager extends RootTableManager<
|
||||||
@ -4026,35 +3855,27 @@ class $$AuthenticationTableTableTableManager extends RootTableManager<
|
|||||||
ComposerState(db, table)),
|
ComposerState(db, table)),
|
||||||
updateCompanionCallback: ({
|
updateCompanionCallback: ({
|
||||||
Value<int> id = const Value.absent(),
|
Value<int> id = const Value.absent(),
|
||||||
Value<DecryptedText> spotifyCookie = const Value.absent(),
|
Value<DecryptedText> cookie = const Value.absent(),
|
||||||
Value<DecryptedText> spotifyAccessToken = const Value.absent(),
|
Value<DecryptedText> accessToken = const Value.absent(),
|
||||||
Value<DateTime> spotifyExpiration = const Value.absent(),
|
Value<DateTime> expiration = const Value.absent(),
|
||||||
Value<DecryptedText?> neteaseCookie = const Value.absent(),
|
|
||||||
Value<DateTime?> neteaseExpiration = const Value.absent(),
|
|
||||||
}) =>
|
}) =>
|
||||||
AuthenticationTableCompanion(
|
AuthenticationTableCompanion(
|
||||||
id: id,
|
id: id,
|
||||||
spotifyCookie: spotifyCookie,
|
cookie: cookie,
|
||||||
spotifyAccessToken: spotifyAccessToken,
|
accessToken: accessToken,
|
||||||
spotifyExpiration: spotifyExpiration,
|
expiration: expiration,
|
||||||
neteaseCookie: neteaseCookie,
|
|
||||||
neteaseExpiration: neteaseExpiration,
|
|
||||||
),
|
),
|
||||||
createCompanionCallback: ({
|
createCompanionCallback: ({
|
||||||
Value<int> id = const Value.absent(),
|
Value<int> id = const Value.absent(),
|
||||||
required DecryptedText spotifyCookie,
|
required DecryptedText cookie,
|
||||||
required DecryptedText spotifyAccessToken,
|
required DecryptedText accessToken,
|
||||||
required DateTime spotifyExpiration,
|
required DateTime expiration,
|
||||||
Value<DecryptedText?> neteaseCookie = const Value.absent(),
|
|
||||||
Value<DateTime?> neteaseExpiration = const Value.absent(),
|
|
||||||
}) =>
|
}) =>
|
||||||
AuthenticationTableCompanion.insert(
|
AuthenticationTableCompanion.insert(
|
||||||
id: id,
|
id: id,
|
||||||
spotifyCookie: spotifyCookie,
|
cookie: cookie,
|
||||||
spotifyAccessToken: spotifyAccessToken,
|
accessToken: accessToken,
|
||||||
spotifyExpiration: spotifyExpiration,
|
expiration: expiration,
|
||||||
neteaseCookie: neteaseCookie,
|
|
||||||
neteaseExpiration: neteaseExpiration,
|
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -4068,33 +3889,21 @@ class $$AuthenticationTableTableFilterComposer
|
|||||||
ColumnFilters(column, joinBuilders: joinBuilders));
|
ColumnFilters(column, joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnWithTypeConverterFilters<DecryptedText, DecryptedText, String>
|
ColumnWithTypeConverterFilters<DecryptedText, DecryptedText, String>
|
||||||
get spotifyCookie => $state.composableBuilder(
|
get cookie => $state.composableBuilder(
|
||||||
column: $state.table.spotifyCookie,
|
column: $state.table.cookie,
|
||||||
builder: (column, joinBuilders) => ColumnWithTypeConverterFilters(
|
builder: (column, joinBuilders) => ColumnWithTypeConverterFilters(
|
||||||
column,
|
column,
|
||||||
joinBuilders: joinBuilders));
|
joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnWithTypeConverterFilters<DecryptedText, DecryptedText, String>
|
ColumnWithTypeConverterFilters<DecryptedText, DecryptedText, String>
|
||||||
get spotifyAccessToken => $state.composableBuilder(
|
get accessToken => $state.composableBuilder(
|
||||||
column: $state.table.spotifyAccessToken,
|
column: $state.table.accessToken,
|
||||||
builder: (column, joinBuilders) => ColumnWithTypeConverterFilters(
|
builder: (column, joinBuilders) => ColumnWithTypeConverterFilters(
|
||||||
column,
|
column,
|
||||||
joinBuilders: joinBuilders));
|
joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnFilters<DateTime> get spotifyExpiration => $state.composableBuilder(
|
ColumnFilters<DateTime> get expiration => $state.composableBuilder(
|
||||||
column: $state.table.spotifyExpiration,
|
column: $state.table.expiration,
|
||||||
builder: (column, joinBuilders) =>
|
|
||||||
ColumnFilters(column, joinBuilders: joinBuilders));
|
|
||||||
|
|
||||||
ColumnWithTypeConverterFilters<DecryptedText?, DecryptedText, String>
|
|
||||||
get neteaseCookie => $state.composableBuilder(
|
|
||||||
column: $state.table.neteaseCookie,
|
|
||||||
builder: (column, joinBuilders) => ColumnWithTypeConverterFilters(
|
|
||||||
column,
|
|
||||||
joinBuilders: joinBuilders));
|
|
||||||
|
|
||||||
ColumnFilters<DateTime> get neteaseExpiration => $state.composableBuilder(
|
|
||||||
column: $state.table.neteaseExpiration,
|
|
||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnFilters(column, joinBuilders: joinBuilders));
|
ColumnFilters(column, joinBuilders: joinBuilders));
|
||||||
}
|
}
|
||||||
@ -4107,28 +3916,18 @@ class $$AuthenticationTableTableOrderingComposer
|
|||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
ColumnOrderings(column, joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnOrderings<String> get spotifyCookie => $state.composableBuilder(
|
ColumnOrderings<String> get cookie => $state.composableBuilder(
|
||||||
column: $state.table.spotifyCookie,
|
column: $state.table.cookie,
|
||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
ColumnOrderings(column, joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnOrderings<String> get spotifyAccessToken => $state.composableBuilder(
|
ColumnOrderings<String> get accessToken => $state.composableBuilder(
|
||||||
column: $state.table.spotifyAccessToken,
|
column: $state.table.accessToken,
|
||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
ColumnOrderings(column, joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnOrderings<DateTime> get spotifyExpiration => $state.composableBuilder(
|
ColumnOrderings<DateTime> get expiration => $state.composableBuilder(
|
||||||
column: $state.table.spotifyExpiration,
|
column: $state.table.expiration,
|
||||||
builder: (column, joinBuilders) =>
|
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
|
||||||
|
|
||||||
ColumnOrderings<String> get neteaseCookie => $state.composableBuilder(
|
|
||||||
column: $state.table.neteaseCookie,
|
|
||||||
builder: (column, joinBuilders) =>
|
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
|
||||||
|
|
||||||
ColumnOrderings<DateTime> get neteaseExpiration => $state.composableBuilder(
|
|
||||||
column: $state.table.neteaseExpiration,
|
|
||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
ColumnOrderings(column, joinBuilders: joinBuilders));
|
||||||
}
|
}
|
||||||
@ -4159,7 +3958,6 @@ typedef $$PreferencesTableTableCreateCompanionBuilder
|
|||||||
Value<SourceCodecs> downloadMusicCodec,
|
Value<SourceCodecs> downloadMusicCodec,
|
||||||
Value<bool> endlessPlayback,
|
Value<bool> endlessPlayback,
|
||||||
Value<bool> playerWakelock,
|
Value<bool> playerWakelock,
|
||||||
Value<bool> overrideCacheProvider,
|
|
||||||
});
|
});
|
||||||
typedef $$PreferencesTableTableUpdateCompanionBuilder
|
typedef $$PreferencesTableTableUpdateCompanionBuilder
|
||||||
= PreferencesTableCompanion Function({
|
= PreferencesTableCompanion Function({
|
||||||
@ -4187,7 +3985,6 @@ typedef $$PreferencesTableTableUpdateCompanionBuilder
|
|||||||
Value<SourceCodecs> downloadMusicCodec,
|
Value<SourceCodecs> downloadMusicCodec,
|
||||||
Value<bool> endlessPlayback,
|
Value<bool> endlessPlayback,
|
||||||
Value<bool> playerWakelock,
|
Value<bool> playerWakelock,
|
||||||
Value<bool> overrideCacheProvider,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
class $$PreferencesTableTableTableManager extends RootTableManager<
|
class $$PreferencesTableTableTableManager extends RootTableManager<
|
||||||
@ -4232,7 +4029,6 @@ class $$PreferencesTableTableTableManager extends RootTableManager<
|
|||||||
Value<SourceCodecs> downloadMusicCodec = const Value.absent(),
|
Value<SourceCodecs> downloadMusicCodec = const Value.absent(),
|
||||||
Value<bool> endlessPlayback = const Value.absent(),
|
Value<bool> endlessPlayback = const Value.absent(),
|
||||||
Value<bool> playerWakelock = const Value.absent(),
|
Value<bool> playerWakelock = const Value.absent(),
|
||||||
Value<bool> overrideCacheProvider = const Value.absent(),
|
|
||||||
}) =>
|
}) =>
|
||||||
PreferencesTableCompanion(
|
PreferencesTableCompanion(
|
||||||
id: id,
|
id: id,
|
||||||
@ -4259,7 +4055,6 @@ class $$PreferencesTableTableTableManager extends RootTableManager<
|
|||||||
downloadMusicCodec: downloadMusicCodec,
|
downloadMusicCodec: downloadMusicCodec,
|
||||||
endlessPlayback: endlessPlayback,
|
endlessPlayback: endlessPlayback,
|
||||||
playerWakelock: playerWakelock,
|
playerWakelock: playerWakelock,
|
||||||
overrideCacheProvider: overrideCacheProvider,
|
|
||||||
),
|
),
|
||||||
createCompanionCallback: ({
|
createCompanionCallback: ({
|
||||||
Value<int> id = const Value.absent(),
|
Value<int> id = const Value.absent(),
|
||||||
@ -4286,7 +4081,6 @@ class $$PreferencesTableTableTableManager extends RootTableManager<
|
|||||||
Value<SourceCodecs> downloadMusicCodec = const Value.absent(),
|
Value<SourceCodecs> downloadMusicCodec = const Value.absent(),
|
||||||
Value<bool> endlessPlayback = const Value.absent(),
|
Value<bool> endlessPlayback = const Value.absent(),
|
||||||
Value<bool> playerWakelock = const Value.absent(),
|
Value<bool> playerWakelock = const Value.absent(),
|
||||||
Value<bool> overrideCacheProvider = const Value.absent(),
|
|
||||||
}) =>
|
}) =>
|
||||||
PreferencesTableCompanion.insert(
|
PreferencesTableCompanion.insert(
|
||||||
id: id,
|
id: id,
|
||||||
@ -4313,7 +4107,6 @@ class $$PreferencesTableTableTableManager extends RootTableManager<
|
|||||||
downloadMusicCodec: downloadMusicCodec,
|
downloadMusicCodec: downloadMusicCodec,
|
||||||
endlessPlayback: endlessPlayback,
|
endlessPlayback: endlessPlayback,
|
||||||
playerWakelock: playerWakelock,
|
playerWakelock: playerWakelock,
|
||||||
overrideCacheProvider: overrideCacheProvider,
|
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -4464,11 +4257,6 @@ class $$PreferencesTableTableFilterComposer
|
|||||||
column: $state.table.playerWakelock,
|
column: $state.table.playerWakelock,
|
||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnFilters(column, joinBuilders: joinBuilders));
|
ColumnFilters(column, joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnFilters<bool> get overrideCacheProvider => $state.composableBuilder(
|
|
||||||
column: $state.table.overrideCacheProvider,
|
|
||||||
builder: (column, joinBuilders) =>
|
|
||||||
ColumnFilters(column, joinBuilders: joinBuilders));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class $$PreferencesTableTableOrderingComposer
|
class $$PreferencesTableTableOrderingComposer
|
||||||
@ -4593,11 +4381,6 @@ class $$PreferencesTableTableOrderingComposer
|
|||||||
column: $state.table.playerWakelock,
|
column: $state.table.playerWakelock,
|
||||||
builder: (column, joinBuilders) =>
|
builder: (column, joinBuilders) =>
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
ColumnOrderings(column, joinBuilders: joinBuilders));
|
||||||
|
|
||||||
ColumnOrderings<bool> get overrideCacheProvider => $state.composableBuilder(
|
|
||||||
column: $state.table.overrideCacheProvider,
|
|
||||||
builder: (column, joinBuilders) =>
|
|
||||||
ColumnOrderings(column, joinBuilders: joinBuilders));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef $$ScrobblerTableTableCreateCompanionBuilder = ScrobblerTableCompanion
|
typedef $$ScrobblerTableTableCreateCompanionBuilder = ScrobblerTableCompanion
|
||||||
|
@ -2,10 +2,7 @@ part of '../database.dart';
|
|||||||
|
|
||||||
class AuthenticationTable extends Table {
|
class AuthenticationTable extends Table {
|
||||||
IntColumn get id => integer().autoIncrement()();
|
IntColumn get id => integer().autoIncrement()();
|
||||||
TextColumn get spotifyCookie => text().map(EncryptedTextConverter())();
|
TextColumn get cookie => text().map(EncryptedTextConverter())();
|
||||||
TextColumn get spotifyAccessToken => text().map(EncryptedTextConverter())();
|
TextColumn get accessToken => text().map(EncryptedTextConverter())();
|
||||||
DateTimeColumn get spotifyExpiration => dateTime()();
|
DateTimeColumn get expiration => dateTime()();
|
||||||
TextColumn get neteaseCookie =>
|
|
||||||
text().map(EncryptedTextConverter()).nullable()();
|
|
||||||
DateTimeColumn get neteaseExpiration => dateTime().nullable()();
|
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ enum CloseBehavior {
|
|||||||
enum AudioSource {
|
enum AudioSource {
|
||||||
youtube,
|
youtube,
|
||||||
piped,
|
piped,
|
||||||
netease,
|
netease;
|
||||||
kugou;
|
|
||||||
|
|
||||||
String get label => name[0].toUpperCase() + name.substring(1);
|
String get label => name[0].toUpperCase() + name.substring(1);
|
||||||
}
|
}
|
||||||
@ -90,8 +89,6 @@ class PreferencesTable extends Table {
|
|||||||
boolean().withDefault(const Constant(true))();
|
boolean().withDefault(const Constant(true))();
|
||||||
BoolColumn get playerWakelock =>
|
BoolColumn get playerWakelock =>
|
||||||
boolean().withDefault(const Constant(true))();
|
boolean().withDefault(const Constant(true))();
|
||||||
BoolColumn get overrideCacheProvider =>
|
|
||||||
boolean().withDefault(const Constant(true))();
|
|
||||||
|
|
||||||
// Default values as PreferencesTableData
|
// Default values as PreferencesTableData
|
||||||
static PreferencesTableData defaults() {
|
static PreferencesTableData defaults() {
|
||||||
@ -120,7 +117,6 @@ class PreferencesTable extends Table {
|
|||||||
downloadMusicCodec: SourceCodecs.m4a,
|
downloadMusicCodec: SourceCodecs.m4a,
|
||||||
endlessPlayback: true,
|
endlessPlayback: true,
|
||||||
playerWakelock: true,
|
playerWakelock: true,
|
||||||
overrideCacheProvider: true,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,7 @@ part of '../database.dart';
|
|||||||
enum SourceType {
|
enum SourceType {
|
||||||
youtube._('YouTube'),
|
youtube._('YouTube'),
|
||||||
youtubeMusic._('YouTube Music'),
|
youtubeMusic._('YouTube Music'),
|
||||||
netease._('Netease Music'),
|
netease._('Netease Music');
|
||||||
kugou._('Kugou Music');
|
|
||||||
|
|
||||||
final String label;
|
final String label;
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:dio/dio.dart' hide Response;
|
import 'package:dio/dio.dart' hide Response;
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:get/get.dart' hide Response;
|
import 'package:get/get.dart' hide Response;
|
||||||
@ -9,7 +6,6 @@ import 'package:rhythm_box/providers/error_notifier.dart';
|
|||||||
import 'package:rhythm_box/services/audio_player/audio_player.dart';
|
import 'package:rhythm_box/services/audio_player/audio_player.dart';
|
||||||
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
||||||
import 'package:rhythm_box/services/server/sourced_track.dart';
|
import 'package:rhythm_box/services/server/sourced_track.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/kugou.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
||||||
import 'package:shelf/shelf.dart';
|
import 'package:shelf/shelf.dart';
|
||||||
|
|
||||||
@ -38,22 +34,6 @@ class ServerPlaybackRoutesProvider {
|
|||||||
);
|
);
|
||||||
final realUrl = resp.body['data'][0]['url'];
|
final realUrl = resp.body['data'][0]['url'];
|
||||||
url = realUrl;
|
url = realUrl;
|
||||||
} else if (sourcedTrack is KugouSourcedTrack) {
|
|
||||||
// Special processing for kugou to get real assets url
|
|
||||||
final resp = await GetConnect(timeout: const Duration(seconds: 30))
|
|
||||||
.get(sourcedTrack.url);
|
|
||||||
final urls = jsonDecode(resp.body)['url'];
|
|
||||||
if (urls?.isEmpty ?? true) {
|
|
||||||
Get.find<ErrorNotifier>().showError(
|
|
||||||
'[PlaybackServer] Unable get audio source via Kugou, probably cause by paid needed resources.',
|
|
||||||
);
|
|
||||||
return Response(
|
|
||||||
HttpStatus.notFound,
|
|
||||||
body: 'Unable get audio source via Kugou',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final realUrl = KugouSourcedTrack.unescapeUrl(urls.first);
|
|
||||||
url = realUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final res = await Dio().get(
|
final res = await Dio().get(
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:rhythm_box/providers/database.dart';
|
|
||||||
import 'package:rhythm_box/providers/error_notifier.dart';
|
|
||||||
import 'package:rhythm_box/providers/user_preferences.dart';
|
import 'package:rhythm_box/providers/user_preferences.dart';
|
||||||
import 'package:rhythm_box/services/database/database.dart';
|
import 'package:rhythm_box/services/database/database.dart';
|
||||||
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/kugou.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
||||||
import 'package:rhythm_box/services/utils.dart';
|
import 'package:rhythm_box/services/utils.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
@ -82,33 +77,6 @@ abstract class SourcedTrack extends Track {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<SourcedTrack?> reRoutineFetchFromTrack(
|
|
||||||
Track track, SourceMatchTableData cachedSource) {
|
|
||||||
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
|
||||||
final ytOrPiped = preferences.audioSource == AudioSource.piped
|
|
||||||
? PipedSourcedTrack.fetchFromTrack
|
|
||||||
: YoutubeSourcedTrack.fetchFromTrack;
|
|
||||||
final sourceInfoTrackMap = {
|
|
||||||
SourceType.youtube: ytOrPiped,
|
|
||||||
SourceType.youtubeMusic: ytOrPiped,
|
|
||||||
SourceType.netease: NeteaseSourcedTrack.fetchFromTrack,
|
|
||||||
SourceType.kugou: KugouSourcedTrack.fetchFromTrack,
|
|
||||||
};
|
|
||||||
return sourceInfoTrackMap[cachedSource.sourceType]!(track: track);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<SourcedTrack?> reRoutineSwapSiblings(SourceInfo info) {
|
|
||||||
final sourceInfoTrackMap = {
|
|
||||||
YoutubeSourceInfo: YoutubeSourcedTrack.fetchFromTrack,
|
|
||||||
PipedSourceInfo: PipedSourcedTrack.fetchFromTrack,
|
|
||||||
NeteaseSourceInfo: NeteaseSourcedTrack.fetchFromTrack,
|
|
||||||
KugouSourceInfo: KugouSourcedTrack.fetchFromTrack,
|
|
||||||
};
|
|
||||||
return sourceInfoTrackMap[info.runtimeType]!(
|
|
||||||
track: Get.find<ActiveSourcedTrackProvider>().state.value!,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getSearchTerm(Track track) {
|
static String getSearchTerm(Track track) {
|
||||||
final artists = (track.artists ?? [])
|
final artists = (track.artists ?? [])
|
||||||
.map((ar) => ar.name)
|
.map((ar) => ar.name)
|
||||||
@ -127,72 +95,25 @@ abstract class SourcedTrack extends Track {
|
|||||||
|
|
||||||
static Future<SourcedTrack> fetchFromTrack({
|
static Future<SourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
AudioSource? fallbackTo,
|
|
||||||
}) async {
|
}) async {
|
||||||
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
||||||
var audioSource = preferences.audioSource;
|
final audioSource = preferences.audioSource;
|
||||||
|
|
||||||
if (!preferences.overrideCacheProvider && fallbackTo == null) {
|
|
||||||
final DatabaseProvider db = Get.find();
|
|
||||||
final cachedSource =
|
|
||||||
await (db.database.select(db.database.sourceMatchTable)
|
|
||||||
..where((s) => s.trackId.equals(track.id!))
|
|
||||||
..limit(1)
|
|
||||||
..orderBy([
|
|
||||||
(s) => OrderingTerm(
|
|
||||||
expression: s.createdAt, mode: OrderingMode.desc),
|
|
||||||
]))
|
|
||||||
.get()
|
|
||||||
.then((s) => s.firstOrNull);
|
|
||||||
|
|
||||||
final ytOrPiped = preferences.audioSource == AudioSource.youtube
|
|
||||||
? AudioSource.youtube
|
|
||||||
: AudioSource.piped;
|
|
||||||
final sourceTypeTrackMap = {
|
|
||||||
SourceType.youtube: ytOrPiped,
|
|
||||||
SourceType.youtubeMusic: ytOrPiped,
|
|
||||||
SourceType.netease: AudioSource.netease,
|
|
||||||
SourceType.kugou: AudioSource.kugou,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (cachedSource != null) {
|
|
||||||
final cachedAudioSource = sourceTypeTrackMap[cachedSource.sourceType]!;
|
|
||||||
audioSource = cachedAudioSource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fallbackTo != null) {
|
|
||||||
audioSource = fallbackTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return switch (audioSource) {
|
return switch (audioSource) {
|
||||||
AudioSource.netease =>
|
AudioSource.netease =>
|
||||||
await NeteaseSourcedTrack.fetchFromTrack(track: track),
|
await NeteaseSourcedTrack.fetchFromTrack(track: track),
|
||||||
AudioSource.kugou =>
|
|
||||||
await KugouSourcedTrack.fetchFromTrack(track: track),
|
|
||||||
AudioSource.piped =>
|
AudioSource.piped =>
|
||||||
await PipedSourcedTrack.fetchFromTrack(track: track),
|
await PipedSourcedTrack.fetchFromTrack(track: track),
|
||||||
_ => await YoutubeSourcedTrack.fetchFromTrack(track: track),
|
_ => await YoutubeSourcedTrack.fetchFromTrack(track: track),
|
||||||
};
|
};
|
||||||
} on TrackNotFoundError catch (err) {
|
} on TrackNotFoundError catch (_) {
|
||||||
Get.find<ErrorNotifier>().showError(
|
return switch (preferences.audioSource) {
|
||||||
'${err.toString()} via ${preferences.audioSource.label}, querying in fallback sources...',
|
AudioSource.piped ||
|
||||||
);
|
AudioSource.youtube =>
|
||||||
|
await NeteaseSourcedTrack.fetchFromTrack(track: track),
|
||||||
if (fallbackTo != null) {
|
|
||||||
// Prevent infinite fallback
|
|
||||||
if (audioSource == AudioSource.youtube ||
|
|
||||||
audioSource == AudioSource.piped) rethrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
return switch (audioSource) {
|
|
||||||
AudioSource.netease =>
|
AudioSource.netease =>
|
||||||
await fetchFromTrack(track: track, fallbackTo: AudioSource.youtube),
|
await YoutubeSourcedTrack.fetchFromTrack(track: track),
|
||||||
AudioSource.kugou =>
|
|
||||||
await fetchFromTrack(track: track, fallbackTo: AudioSource.youtube),
|
|
||||||
_ =>
|
|
||||||
await fetchFromTrack(track: track, fallbackTo: AudioSource.netease),
|
|
||||||
};
|
};
|
||||||
} on HttpClientClosedException catch (_) {
|
} on HttpClientClosedException catch (_) {
|
||||||
return await PipedSourcedTrack.fetchFromTrack(track: track);
|
return await PipedSourcedTrack.fetchFromTrack(track: track);
|
||||||
|
@ -1,242 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
|
||||||
import 'package:drift/drift.dart';
|
|
||||||
import 'package:crypto/crypto.dart';
|
|
||||||
import 'package:get/get.dart' hide Value;
|
|
||||||
import 'package:rhythm_box/providers/database.dart';
|
|
||||||
import 'package:rhythm_box/services/database/database.dart';
|
|
||||||
import 'package:spotify/spotify.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/enums.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/exceptions.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/models/source_info.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/models/source_map.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
|
||||||
|
|
||||||
class KugouSourceInfo extends SourceInfo {
|
|
||||||
KugouSourceInfo({
|
|
||||||
required super.id,
|
|
||||||
required super.title,
|
|
||||||
required super.artist,
|
|
||||||
required super.thumbnail,
|
|
||||||
required super.pageUrl,
|
|
||||||
required super.duration,
|
|
||||||
required super.artistUrl,
|
|
||||||
required super.album,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class KugouSourcedTrack extends SourcedTrack {
|
|
||||||
KugouSourcedTrack({
|
|
||||||
required super.source,
|
|
||||||
required super.siblings,
|
|
||||||
required super.sourceInfo,
|
|
||||||
required super.track,
|
|
||||||
});
|
|
||||||
|
|
||||||
static String unescapeUrl(String src) {
|
|
||||||
return src.replaceAll('\\/', '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getBaseUrl() {
|
|
||||||
return 'http://mobilecdn.kugou.com';
|
|
||||||
}
|
|
||||||
|
|
||||||
static GetConnect getClient() {
|
|
||||||
final client = GetConnect(
|
|
||||||
withCredentials: true,
|
|
||||||
timeout: const Duration(seconds: 30),
|
|
||||||
);
|
|
||||||
client.baseUrl = getBaseUrl();
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<SourcedTrack> fetchFromTrack({
|
|
||||||
required Track track,
|
|
||||||
}) async {
|
|
||||||
final DatabaseProvider db = Get.find();
|
|
||||||
final cachedSource = await (db.database.select(db.database.sourceMatchTable)
|
|
||||||
..where((s) => s.trackId.equals(track.id!))
|
|
||||||
..limit(1)
|
|
||||||
..orderBy([
|
|
||||||
(s) =>
|
|
||||||
OrderingTerm(expression: s.createdAt, mode: OrderingMode.desc),
|
|
||||||
]))
|
|
||||||
.get()
|
|
||||||
.then((s) => s.firstOrNull);
|
|
||||||
|
|
||||||
if (cachedSource == null || cachedSource.sourceType != SourceType.kugou) {
|
|
||||||
final siblings = await fetchSiblings(track: track);
|
|
||||||
if (siblings.isEmpty) {
|
|
||||||
throw TrackNotFoundError(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
await db.database.into(db.database.sourceMatchTable).insert(
|
|
||||||
SourceMatchTableCompanion.insert(
|
|
||||||
trackId: track.id!,
|
|
||||||
sourceId: siblings.first.info.id,
|
|
||||||
sourceType: const Value(SourceType.kugou),
|
|
||||||
),
|
|
||||||
mode: InsertMode.insertOrReplace,
|
|
||||||
);
|
|
||||||
|
|
||||||
return KugouSourcedTrack(
|
|
||||||
siblings: siblings.map((s) => s.info).skip(1).toList(),
|
|
||||||
source: siblings.first.source as SourceMap,
|
|
||||||
sourceInfo: siblings.first.info,
|
|
||||||
track: track,
|
|
||||||
);
|
|
||||||
} else if (cachedSource.sourceType != SourceType.kugou) {
|
|
||||||
final out =
|
|
||||||
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource);
|
|
||||||
if (out == null) throw TrackNotFoundError(track);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
return KugouSourcedTrack(
|
|
||||||
siblings: [],
|
|
||||||
source: toSourceMap(cachedSource),
|
|
||||||
sourceInfo: KugouSourceInfo(
|
|
||||||
id: cachedSource.sourceId,
|
|
||||||
artist: 'unknown',
|
|
||||||
artistUrl: '#',
|
|
||||||
pageUrl: '#',
|
|
||||||
thumbnail: '#',
|
|
||||||
title: 'unknown',
|
|
||||||
duration: Duration.zero,
|
|
||||||
album: 'unknown',
|
|
||||||
),
|
|
||||||
track: track,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SourceMap toSourceMap(dynamic manifest) {
|
|
||||||
const baseUrl = 'http://trackercdn.kugou.com/i/v2';
|
|
||||||
|
|
||||||
final hash = manifest is SourceMatchTableData
|
|
||||||
? manifest.sourceId
|
|
||||||
: manifest is KugouSourceInfo
|
|
||||||
? manifest.id
|
|
||||||
: manifest?['hash'];
|
|
||||||
final key = md5.convert(utf8.encode('${hash}kgcloudv2')).toString();
|
|
||||||
final url =
|
|
||||||
'$baseUrl/song/url?key=$key&hash=$hash&appid=1005&pid=2&cmd=25&behavior=play';
|
|
||||||
|
|
||||||
return SourceMap(
|
|
||||||
m4a: SourceQualityMap(
|
|
||||||
high: url,
|
|
||||||
medium: url,
|
|
||||||
low: url,
|
|
||||||
),
|
|
||||||
weba: SourceQualityMap(
|
|
||||||
high: url,
|
|
||||||
medium: url,
|
|
||||||
low: url,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<List<SiblingType>> fetchSiblings({
|
|
||||||
required Track track,
|
|
||||||
}) async {
|
|
||||||
final query = SourcedTrack.getSearchTerm(track);
|
|
||||||
|
|
||||||
final client = getClient();
|
|
||||||
final resp = await client.get(
|
|
||||||
'/api/v3/search/song?keyword=${Uri.encodeComponent(query)}&page=1&pagesize=10',
|
|
||||||
);
|
|
||||||
final results = jsonDecode(resp.body)['data']['info'];
|
|
||||||
|
|
||||||
// We can just trust kugou music for now
|
|
||||||
// If we need to check is the result correct, refer to this code
|
|
||||||
// https://github.com/KRTirtho/spotube/blob/9b024120601c0d381edeab4460cb22f87149d0f8/lib/services/sourced_track/sources/jiosaavn.dart#L129
|
|
||||||
final matchedResults =
|
|
||||||
results.where((x) => x['pay_type'] == 0).map(toSiblingType).toList();
|
|
||||||
|
|
||||||
return matchedResults.cast<SiblingType>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<KugouSourcedTrack> copyWithSibling() async {
|
|
||||||
if (siblings.isNotEmpty) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
final fetchedSiblings = await fetchSiblings(track: this);
|
|
||||||
|
|
||||||
return KugouSourcedTrack(
|
|
||||||
siblings: fetchedSiblings
|
|
||||||
.where((s) => s.info.id != sourceInfo.id)
|
|
||||||
.map((s) => s.info)
|
|
||||||
.toList(),
|
|
||||||
source: source,
|
|
||||||
sourceInfo: sourceInfo,
|
|
||||||
track: this,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
|
||||||
if (sibling is! KugouSourceInfo) {
|
|
||||||
return reRoutineSwapSiblings(sibling);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// a sibling source that was fetched from the search results
|
|
||||||
final isStepSibling = siblings.none((s) => s.id == sibling.id);
|
|
||||||
|
|
||||||
final newSourceInfo = isStepSibling
|
|
||||||
? sibling
|
|
||||||
: siblings.firstWhere((s) => s.id == sibling.id);
|
|
||||||
final newSiblings = siblings.where((s) => s.id != sibling.id).toList()
|
|
||||||
..insert(0, sourceInfo);
|
|
||||||
|
|
||||||
final info = newSourceInfo as KugouSourceInfo;
|
|
||||||
final source = toSourceMap(newSourceInfo);
|
|
||||||
|
|
||||||
final db = Get.find<DatabaseProvider>();
|
|
||||||
await db.database.into(db.database.sourceMatchTable).insert(
|
|
||||||
SourceMatchTableCompanion.insert(
|
|
||||||
trackId: id!,
|
|
||||||
sourceId: info.id,
|
|
||||||
sourceType: const Value(SourceType.kugou),
|
|
||||||
// Because we're sorting by createdAt in the query
|
|
||||||
// we have to update it to indicate priority
|
|
||||||
createdAt: Value(DateTime.now()),
|
|
||||||
),
|
|
||||||
mode: InsertMode.replace,
|
|
||||||
);
|
|
||||||
|
|
||||||
return KugouSourcedTrack(
|
|
||||||
siblings: newSiblings,
|
|
||||||
source: source,
|
|
||||||
sourceInfo: info,
|
|
||||||
track: this,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static KugouSourceInfo toSourceInfo(dynamic item) {
|
|
||||||
return KugouSourceInfo(
|
|
||||||
id: item['hash'],
|
|
||||||
artist: item['singername'],
|
|
||||||
artistUrl: '#',
|
|
||||||
pageUrl: '#',
|
|
||||||
thumbnail: unescapeUrl(item['trans_param']['union_cover'])
|
|
||||||
.replaceFirst('/{size}', ''),
|
|
||||||
title: item['songname'],
|
|
||||||
duration: Duration(seconds: item['duration']),
|
|
||||||
album: item['album_name'],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SiblingType toSiblingType(dynamic item) {
|
|
||||||
final SiblingType sibling = (
|
|
||||||
info: toSourceInfo(item),
|
|
||||||
source: toSourceMap(item),
|
|
||||||
);
|
|
||||||
|
|
||||||
return sibling;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,6 @@
|
|||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:get/get.dart' hide Value;
|
import 'package:get/get.dart' hide Value;
|
||||||
import 'package:get/get_connect/http/src/request/request.dart';
|
|
||||||
import 'package:rhythm_box/providers/auth.dart';
|
|
||||||
import 'package:rhythm_box/providers/database.dart';
|
import 'package:rhythm_box/providers/database.dart';
|
||||||
import 'package:rhythm_box/providers/user_preferences.dart';
|
import 'package:rhythm_box/providers/user_preferences.dart';
|
||||||
import 'package:rhythm_box/services/database/database.dart';
|
import 'package:rhythm_box/services/database/database.dart';
|
||||||
@ -40,25 +38,9 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GetConnect getClient() {
|
static GetConnect getClient() {
|
||||||
final client = GetConnect(
|
final client = GetConnect();
|
||||||
withCredentials: true,
|
|
||||||
timeout: const Duration(seconds: 30),
|
|
||||||
);
|
|
||||||
client.baseUrl = getBaseUrl();
|
client.baseUrl = getBaseUrl();
|
||||||
client.httpClient.addRequestModifier((Request request) async {
|
client.timeout = const Duration(seconds: 30);
|
||||||
final AuthenticationProvider auth = Get.find();
|
|
||||||
if (auth.auth.value?.neteaseCookie != null) {
|
|
||||||
final cookie =
|
|
||||||
'MUSIC_U=${auth.auth.value!.getNeteaseCookie('MUSIC_U')}';
|
|
||||||
if (request.headers['Cookie'] == null) {
|
|
||||||
request.headers['Cookie'] = cookie;
|
|
||||||
} else {
|
|
||||||
request.headers['Cookie'] = request.headers['Cookie']! + cookie;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return request;
|
|
||||||
});
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +55,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
return _lookedUpRealIp!;
|
return _lookedUpRealIp!;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<SourcedTrack> fetchFromTrack({
|
static Future<NeteaseSourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
}) async {
|
}) async {
|
||||||
final DatabaseProvider db = Get.find();
|
final DatabaseProvider db = Get.find();
|
||||||
@ -87,25 +69,18 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
.get()
|
.get()
|
||||||
.then((s) => s.firstOrNull);
|
.then((s) => s.firstOrNull);
|
||||||
|
|
||||||
if (cachedSource == null || cachedSource.sourceType != SourceType.netease) {
|
if (cachedSource == null) {
|
||||||
final siblings = await fetchSiblings(track: track);
|
final siblings = await fetchSiblings(track: track);
|
||||||
if (siblings.isEmpty) {
|
if (siblings.isEmpty) {
|
||||||
throw TrackNotFoundError(track);
|
throw TrackNotFoundError(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
final client = getClient();
|
|
||||||
final checkResp = await client.get(
|
|
||||||
'/check/music?id=${siblings.first.info.id}&realIP=${await lookupRealIp()}',
|
|
||||||
);
|
|
||||||
if (checkResp.body['success'] != true) throw TrackNotFoundError(track);
|
|
||||||
|
|
||||||
await db.database.into(db.database.sourceMatchTable).insert(
|
await db.database.into(db.database.sourceMatchTable).insert(
|
||||||
SourceMatchTableCompanion.insert(
|
SourceMatchTableCompanion.insert(
|
||||||
trackId: track.id!,
|
trackId: track.id!,
|
||||||
sourceId: siblings.first.info.id,
|
sourceId: siblings.first.info.id,
|
||||||
sourceType: const Value(SourceType.netease),
|
sourceType: const Value(SourceType.netease),
|
||||||
),
|
),
|
||||||
mode: InsertMode.insertOrReplace,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return NeteaseSourcedTrack(
|
return NeteaseSourcedTrack(
|
||||||
@ -114,24 +89,11 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
sourceInfo: siblings.first.info,
|
sourceInfo: siblings.first.info,
|
||||||
track: track,
|
track: track,
|
||||||
);
|
);
|
||||||
} else if (cachedSource.sourceType != SourceType.netease) {
|
|
||||||
final out =
|
|
||||||
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource);
|
|
||||||
if (out == null) throw TrackNotFoundError(track);
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final client = getClient();
|
final client = getClient();
|
||||||
final resp = await client.get('/song/detail?ids=${cachedSource.sourceId}');
|
final resp = await client.get('/song/detail?ids=${cachedSource.sourceId}');
|
||||||
if (resp.body?['songs'] == null) throw TrackNotFoundError(track);
|
final item = resp.body['songs'][0];
|
||||||
final item = (resp.body['songs'] as List<dynamic>).firstOrNull;
|
|
||||||
|
|
||||||
if (item == null) throw TrackNotFoundError(track);
|
|
||||||
|
|
||||||
final checkResp = await client.get(
|
|
||||||
'/check/music?id=${item['id']}&realIP=${await lookupRealIp()}',
|
|
||||||
);
|
|
||||||
if (checkResp.body['success'] != true) throw TrackNotFoundError(track);
|
|
||||||
|
|
||||||
return NeteaseSourcedTrack(
|
return NeteaseSourcedTrack(
|
||||||
siblings: [],
|
siblings: [],
|
||||||
@ -174,10 +136,8 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
final query = SourcedTrack.getSearchTerm(track);
|
final query = SourcedTrack.getSearchTerm(track);
|
||||||
|
|
||||||
final client = getClient();
|
final client = getClient();
|
||||||
final resp = await client.get(
|
final resp =
|
||||||
'/search?keywords=${Uri.encodeComponent(query)}&realIP=${await NeteaseSourcedTrack.lookupRealIp()}',
|
await client.get('/search?keywords=${Uri.encodeComponent(query)}');
|
||||||
);
|
|
||||||
if (resp.body?['code'] == 405) throw TrackNotFoundError(track);
|
|
||||||
final results = resp.body['result']['songs'];
|
final results = resp.body['result']['songs'];
|
||||||
|
|
||||||
// We can just trust netease music for now
|
// We can just trust netease music for now
|
||||||
@ -207,11 +167,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<NeteaseSourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! NeteaseSourceInfo) {
|
|
||||||
return reRoutineSwapSiblings(sibling);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -227,7 +183,7 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
|
|
||||||
final client = getClient();
|
final client = getClient();
|
||||||
final resp = await client.get('/song/detail?ids=${newSourceInfo.id}');
|
final resp = await client.get('/song/detail?ids=${newSourceInfo.id}');
|
||||||
final item = (resp.body['songs'] as List<dynamic>).first;
|
final item = resp.body['songs'][0];
|
||||||
|
|
||||||
final (:info, :source) = toSiblingType(item);
|
final (:info, :source) = toSiblingType(item);
|
||||||
|
|
||||||
@ -252,10 +208,11 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NeteaseSourceInfo toSourceInfo(dynamic item) {
|
static SiblingType toSiblingType(dynamic item) {
|
||||||
final firstArtist = item['ar'] != null ? item['ar'][0] : item['artists'][0];
|
final firstArtist = item['ar'] != null ? item['ar'][0] : item['artists'][0];
|
||||||
|
|
||||||
return NeteaseSourceInfo(
|
final SiblingType sibling = (
|
||||||
|
info: NeteaseSourceInfo(
|
||||||
id: item['id'].toString(),
|
id: item['id'].toString(),
|
||||||
artist: item['ar'] != null
|
artist: item['ar'] != null
|
||||||
? item['ar'].map((x) => x['name']).join(',')
|
? item['ar'].map((x) => x['name']).join(',')
|
||||||
@ -267,14 +224,9 @@ class NeteaseSourcedTrack extends SourcedTrack {
|
|||||||
title: item['name'],
|
title: item['name'],
|
||||||
duration: item['dt'] != null
|
duration: item['dt'] != null
|
||||||
? Duration(milliseconds: item['dt'])
|
? Duration(milliseconds: item['dt'])
|
||||||
: Duration(milliseconds: item['duration']),
|
: Duration.zero,
|
||||||
album: item['al']?['name'],
|
album: item['al']?['name'],
|
||||||
);
|
),
|
||||||
}
|
|
||||||
|
|
||||||
static SiblingType toSiblingType(dynamic item) {
|
|
||||||
final SiblingType sibling = (
|
|
||||||
info: toSourceInfo(item),
|
|
||||||
source: toSourceMap(item),
|
source: toSourceMap(item),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -57,14 +57,6 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
|
|
||||||
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
||||||
|
|
||||||
if (cachedSource?.sourceType != SourceType.youtube &&
|
|
||||||
cachedSource?.sourceType != SourceType.youtubeMusic) {
|
|
||||||
final out =
|
|
||||||
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource!);
|
|
||||||
if (out == null) throw TrackNotFoundError(track);
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cachedSource == null) {
|
if (cachedSource == null) {
|
||||||
final siblings = await fetchSiblings(track: track);
|
final siblings = await fetchSiblings(track: track);
|
||||||
if (siblings.isEmpty) {
|
if (siblings.isEmpty) {
|
||||||
@ -81,7 +73,6 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
: SourceType.youtubeMusic,
|
: SourceType.youtubeMusic,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
mode: InsertMode.insertOrReplace,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return PipedSourcedTrack(
|
return PipedSourcedTrack(
|
||||||
@ -264,10 +255,6 @@ class PipedSourcedTrack extends SourcedTrack {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! PipedSourceInfo) {
|
|
||||||
return reRoutineSwapSiblings(sibling);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
required super.track,
|
required super.track,
|
||||||
});
|
});
|
||||||
|
|
||||||
static Future<SourcedTrack> fetchFromTrack({
|
static Future<YoutubeSourcedTrack> fetchFromTrack({
|
||||||
required Track track,
|
required Track track,
|
||||||
}) async {
|
}) async {
|
||||||
final DatabaseProvider db = Get.find();
|
final DatabaseProvider db = Get.find();
|
||||||
@ -69,7 +69,6 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
sourceId: siblings.first.info.id,
|
sourceId: siblings.first.info.id,
|
||||||
sourceType: const Value(SourceType.youtube),
|
sourceType: const Value(SourceType.youtube),
|
||||||
),
|
),
|
||||||
mode: InsertMode.insertOrReplace,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return YoutubeSourcedTrack(
|
return YoutubeSourcedTrack(
|
||||||
@ -78,11 +77,6 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
sourceInfo: siblings.first.info,
|
sourceInfo: siblings.first.info,
|
||||||
track: track,
|
track: track,
|
||||||
);
|
);
|
||||||
} else if (cachedSource.sourceType != SourceType.youtube) {
|
|
||||||
final out =
|
|
||||||
await SourcedTrack.reRoutineFetchFromTrack(track, cachedSource);
|
|
||||||
if (out == null) throw TrackNotFoundError(track);
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
final item = await youtubeClient.videos.get(cachedSource.sourceId);
|
||||||
@ -274,11 +268,7 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<SourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
Future<YoutubeSourcedTrack?> swapWithSibling(SourceInfo sibling) async {
|
||||||
if (sibling is! YoutubeSourceInfo) {
|
|
||||||
return reRoutineSwapSiblings(sibling);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sibling.id == sourceInfo.id) {
|
if (sibling.id == sourceInfo.id) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,8 @@ import 'package:rhythm_box/platform.dart';
|
|||||||
class AutoCacheImage extends StatelessWidget {
|
class AutoCacheImage extends StatelessWidget {
|
||||||
final String url;
|
final String url;
|
||||||
final double? width, height;
|
final double? width, height;
|
||||||
final BoxFit? fit;
|
|
||||||
|
|
||||||
const AutoCacheImage(this.url,
|
const AutoCacheImage(this.url, {super.key, this.width, this.height});
|
||||||
{super.key, this.width, this.height, this.fit});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -17,14 +15,12 @@ class AutoCacheImage extends StatelessWidget {
|
|||||||
imageUrl: url,
|
imageUrl: url,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Image.network(
|
return Image.network(
|
||||||
url,
|
url,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
fit: fit,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:rhythm_box/providers/audio_player.dart';
|
import 'package:rhythm_box/providers/audio_player.dart';
|
||||||
import 'package:rhythm_box/providers/error_notifier.dart';
|
|
||||||
import 'package:rhythm_box/providers/user_preferences.dart';
|
import 'package:rhythm_box/providers/user_preferences.dart';
|
||||||
import 'package:rhythm_box/services/database/database.dart';
|
import 'package:rhythm_box/services/database/database.dart';
|
||||||
import 'package:rhythm_box/services/duration.dart';
|
import 'package:rhythm_box/services/duration.dart';
|
||||||
@ -14,7 +12,6 @@ import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
|||||||
import 'package:rhythm_box/services/sourced_track/models/source_info.dart';
|
import 'package:rhythm_box/services/sourced_track/models/source_info.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/models/video_info.dart';
|
import 'package:rhythm_box/services/sourced_track/models/video_info.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/kugou.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/piped.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/piped.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/youtube.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/youtube.dart';
|
||||||
@ -47,7 +44,6 @@ class _SiblingTracksState extends State<SiblingTracks> {
|
|||||||
YoutubeSourceInfo: 'YouTube',
|
YoutubeSourceInfo: 'YouTube',
|
||||||
PipedSourceInfo: 'Piped',
|
PipedSourceInfo: 'Piped',
|
||||||
NeteaseSourceInfo: 'Netease',
|
NeteaseSourceInfo: 'Netease',
|
||||||
KugouSourceInfo: 'Kugou',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
List<StreamSubscription>? _subscriptions;
|
List<StreamSubscription>? _subscriptions;
|
||||||
@ -93,17 +89,13 @@ class _SiblingTracksState extends State<SiblingTracks> {
|
|||||||
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
final preferences = Get.find<UserPreferencesProvider>().state.value;
|
||||||
final searchTerm = _searchTermController.text.trim();
|
final searchTerm = _searchTermController.text.trim();
|
||||||
|
|
||||||
try {
|
|
||||||
if (preferences.audioSource == AudioSource.youtube ||
|
if (preferences.audioSource == AudioSource.youtube ||
|
||||||
preferences.audioSource == AudioSource.piped) {
|
preferences.audioSource == AudioSource.piped) {
|
||||||
final resultsYt = await youtubeClient.search.search(searchTerm.trim());
|
final resultsYt = await youtubeClient.search.search(searchTerm.trim());
|
||||||
|
|
||||||
final searchResults = await Future.wait(
|
final searchResults = await Future.wait(
|
||||||
resultsYt
|
resultsYt.map(YoutubeVideoInfo.fromVideo).mapIndexed((i, video) async {
|
||||||
.map(YoutubeVideoInfo.fromVideo)
|
final siblingType = await YoutubeSourcedTrack.toSiblingType(i, video);
|
||||||
.mapIndexed((i, video) async {
|
|
||||||
final siblingType =
|
|
||||||
await YoutubeSourcedTrack.toSiblingType(i, video);
|
|
||||||
return siblingType.info;
|
return siblingType.info;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -119,31 +111,11 @@ class _SiblingTracksState extends State<SiblingTracks> {
|
|||||||
);
|
);
|
||||||
} else if (preferences.audioSource == AudioSource.netease) {
|
} else if (preferences.audioSource == AudioSource.netease) {
|
||||||
final client = NeteaseSourcedTrack.getClient();
|
final client = NeteaseSourcedTrack.getClient();
|
||||||
final resp = await client.get(
|
final resp = await client
|
||||||
'/search?keywords=${Uri.encodeComponent(searchTerm)}&realIP=${await NeteaseSourcedTrack.lookupRealIp()}');
|
.get('/search?keywords=${Uri.encodeComponent(searchTerm)}');
|
||||||
final searchResults = resp.body['result']['songs']
|
final searchResults = resp.body['result']['songs']
|
||||||
.map(NeteaseSourcedTrack.toSourceInfo)
|
.map(NeteaseSourcedTrack.toSiblingType)
|
||||||
.toList();
|
.map((x) => x.info)
|
||||||
|
|
||||||
final activeSourceInfo = (_activeTrack! as SourcedTrack).sourceInfo;
|
|
||||||
_siblings = List.from(
|
|
||||||
searchResults
|
|
||||||
..removeWhere((element) => element.id == activeSourceInfo.id)
|
|
||||||
..insert(
|
|
||||||
0,
|
|
||||||
activeSourceInfo,
|
|
||||||
),
|
|
||||||
growable: true,
|
|
||||||
);
|
|
||||||
} else if (preferences.audioSource == AudioSource.kugou) {
|
|
||||||
final client = KugouSourcedTrack.getClient();
|
|
||||||
final resp = await client.get(
|
|
||||||
'/api/v3/search/song?keyword=${Uri.encodeComponent(searchTerm)}&page=1&pagesize=10',
|
|
||||||
);
|
|
||||||
final results = jsonDecode(resp.body)['data']['info'];
|
|
||||||
final searchResults = results
|
|
||||||
.where((x) => x['pay_type'] == 0)
|
|
||||||
.map(KugouSourcedTrack.toSourceInfo)
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
final activeSourceInfo = (_activeTrack! as SourcedTrack).sourceInfo;
|
final activeSourceInfo = (_activeTrack! as SourcedTrack).sourceInfo;
|
||||||
@ -157,12 +129,9 @@ class _SiblingTracksState extends State<SiblingTracks> {
|
|||||||
growable: true,
|
growable: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
Get.find<ErrorNotifier>().showError(err.toString());
|
|
||||||
} finally {
|
|
||||||
setState(() => _isSearching = false);
|
setState(() => _isSearching = false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:rhythm_box/services/duration.dart';
|
import 'package:rhythm_box/services/duration.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
import 'package:rhythm_box/services/sourced_track/sourced_track.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/kugou.dart';
|
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/netease.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/piped.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/piped.dart';
|
||||||
import 'package:rhythm_box/services/sourced_track/sources/youtube.dart';
|
import 'package:rhythm_box/services/sourced_track/sources/youtube.dart';
|
||||||
|
import 'package:spotify/spotify.dart';
|
||||||
|
|
||||||
class TrackSourceDetails extends StatelessWidget {
|
class TrackSourceDetails extends StatelessWidget {
|
||||||
final SourcedTrack track;
|
final Track track;
|
||||||
|
|
||||||
const TrackSourceDetails({super.key, required this.track});
|
const TrackSourceDetails({super.key, required this.track});
|
||||||
|
|
||||||
@ -15,7 +15,6 @@ class TrackSourceDetails extends StatelessWidget {
|
|||||||
YoutubeSourceInfo: 'YouTube',
|
YoutubeSourceInfo: 'YouTube',
|
||||||
PipedSourceInfo: 'Piped',
|
PipedSourceInfo: 'Piped',
|
||||||
NeteaseSourceInfo: 'Netease',
|
NeteaseSourceInfo: 'Netease',
|
||||||
KugouSourceInfo: 'Kugou',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -26,11 +25,14 @@ class TrackSourceDetails extends StatelessWidget {
|
|||||||
'Title': track.name!,
|
'Title': track.name!,
|
||||||
'Artist': track.artists?.map((x) => x.name).join(', '),
|
'Artist': track.artists?.map((x) => x.name).join(', '),
|
||||||
'Album': track.album!.name!,
|
'Album': track.album!.name!,
|
||||||
'Duration': track.sourceInfo.duration.toHumanReadableString(),
|
'Duration': (track is SourcedTrack
|
||||||
|
? (track as SourcedTrack).sourceInfo.duration
|
||||||
|
: track.duration!)
|
||||||
|
.toHumanReadableString(),
|
||||||
if (track.album!.releaseDate != null)
|
if (track.album!.releaseDate != null)
|
||||||
'Released': track.album!.releaseDate,
|
'Released': track.album!.releaseDate,
|
||||||
'Popularity': track.popularity?.toString() ?? '0',
|
'Popularity': track.popularity?.toString() ?? '0',
|
||||||
'Provider': sourceInfoToLabelMap[track.sourceInfo.runtimeType],
|
'Provider': sourceInfoToLabelMap[track.runtimeType],
|
||||||
};
|
};
|
||||||
|
|
||||||
return Table(
|
return Table(
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
<string>MainMenu</string>
|
<string>MainMenu</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.music</string>
|
<string>public.app-category.music</string>
|
||||||
<key>ITSAppUsesNonExemptEncryption</key>
|
|
||||||
<false/>
|
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
<string>NSApplication</string>
|
<string>NSApplication</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.0+18
|
version: 1.0.0+8
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.5.0
|
sdk: ^3.5.0
|
||||||
@ -180,3 +180,4 @@ flutter_native_splash:
|
|||||||
color: "#fef8f5"
|
color: "#fef8f5"
|
||||||
color_dark: "#18120d"
|
color_dark: "#18120d"
|
||||||
image: assets/icon-w-shadow.png
|
image: assets/icon-w-shadow.png
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user