mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-06 15:39:41 +00:00
Compare commits
7 Commits
aecf36d2f9
...
d35c521865
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d35c521865 | ||
|
|
8a7f5c4008 | ||
|
|
9d2ad1c626 | ||
|
|
b74c2eab8f | ||
|
|
2c4cc94985 | ||
|
|
9163f1abe0 | ||
|
|
227909787d |
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -9,6 +9,7 @@
|
||||
"fuzzywuzzy",
|
||||
"gapless",
|
||||
"instrumentalness",
|
||||
"isrc",
|
||||
"Mpris",
|
||||
"RGBO",
|
||||
"riverpod",
|
||||
|
||||
@ -94,6 +94,7 @@ abstract class FakeData {
|
||||
..trackNumber = 1
|
||||
..type = "type"
|
||||
..uri = "uri"
|
||||
..externalIds = externalIds
|
||||
..isPlayable = true
|
||||
..explicit = false
|
||||
..linkedFrom = trackLink;
|
||||
|
||||
@ -39,7 +39,7 @@ class AdaptivePopSheetList<T> extends StatelessWidget {
|
||||
|
||||
final Offset offset;
|
||||
|
||||
final ButtonVariance variance;
|
||||
final AbstractButtonStyle variance;
|
||||
|
||||
const AdaptivePopSheetList({
|
||||
super.key,
|
||||
@ -92,8 +92,10 @@ class AdaptivePopSheetList<T> extends StatelessWidget {
|
||||
// ),
|
||||
position: position,
|
||||
builder: (context) {
|
||||
return DropdownMenu(
|
||||
return WidgetStatesProvider.boundary(
|
||||
child: DropdownMenu(
|
||||
children: childrenModified(context),
|
||||
),
|
||||
);
|
||||
},
|
||||
).future;
|
||||
|
||||
@ -13,7 +13,7 @@ class HeartButton extends HookConsumerWidget {
|
||||
final IconData? icon;
|
||||
final Color? color;
|
||||
final String? tooltip;
|
||||
final ButtonVariance variance;
|
||||
final AbstractButtonStyle variance;
|
||||
final ButtonSize size;
|
||||
const HeartButton({
|
||||
required this.isLiked,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:spotube/extensions/button_variance.dart';
|
||||
|
||||
class ShadcnWindowButton extends StatelessWidget {
|
||||
final Widget icon;
|
||||
@ -22,7 +21,7 @@ class ShadcnWindowButton extends StatelessWidget {
|
||||
height: 32,
|
||||
child: IconButton(
|
||||
variance: ButtonVariance.ghost.copyWith(
|
||||
decoration: (context, states) {
|
||||
decoration: (context, states, value) {
|
||||
final decoration = ButtonVariance.ghost.decoration(context, states)
|
||||
as BoxDecoration;
|
||||
if (hoverBackgroundColor != null &&
|
||||
|
||||
@ -5,7 +5,7 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
@ -17,7 +17,6 @@ import 'package:spotube/components/links/link_text.dart';
|
||||
import 'package:spotube/components/track_tile/track_options.dart';
|
||||
import 'package:spotube/components/ui/button_tile.dart';
|
||||
import 'package:spotube/extensions/artist_simple.dart';
|
||||
import 'package:spotube/extensions/button_variance.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/duration.dart';
|
||||
import 'package:spotube/extensions/image.dart';
|
||||
@ -108,7 +107,7 @@ class TrackTile extends HookConsumerWidget {
|
||||
? ButtonVariance.destructive
|
||||
: ButtonVariance.ghost)
|
||||
.copyWith(
|
||||
padding: (context, states) =>
|
||||
padding: (context, states, value) =>
|
||||
const EdgeInsets.symmetric(vertical: 8, horizontal: 0),
|
||||
),
|
||||
leading: Row(
|
||||
@ -229,7 +228,8 @@ class TrackTile extends HookConsumerWidget {
|
||||
Flexible(
|
||||
child: Button(
|
||||
style: ButtonVariance.link.copyWith(
|
||||
padding: (context, states) => EdgeInsets.zero,
|
||||
padding: (context, states, value) =>
|
||||
EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
context
|
||||
|
||||
@ -9,7 +9,7 @@ class ButtonTile extends StatelessWidget {
|
||||
final VoidCallback? onPressed;
|
||||
final VoidCallback? onLongPress;
|
||||
final bool selected;
|
||||
final ButtonVariance style;
|
||||
final AbstractButtonStyle style;
|
||||
final EdgeInsets? padding;
|
||||
|
||||
const ButtonTile({
|
||||
|
||||
@ -4,7 +4,9 @@ import 'dart:typed_data';
|
||||
import 'package:metadata_god/metadata_god.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/provider/spotify/spotify.dart';
|
||||
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||
import 'package:spotube/services/logger/logger.dart';
|
||||
|
||||
extension TrackExtensions on Track {
|
||||
Track fromFile(
|
||||
@ -67,27 +69,40 @@ extension TrackExtensions on Track {
|
||||
}
|
||||
}
|
||||
|
||||
extension TrackSimpleExtensions on TrackSimple {
|
||||
Track asTrack(AlbumSimple album) {
|
||||
extension IterableTrackSimpleExtensions on Iterable<TrackSimple> {
|
||||
Future<List<Track>> asTracks(AlbumSimple album, ref) async {
|
||||
try {
|
||||
final spotify = ref.read(spotifyProvider);
|
||||
final tracks = await spotify.invoke(
|
||||
(api) => api.tracks.list(map((trackSimple) => trackSimple.id!).toList()));
|
||||
return tracks.toList();
|
||||
} catch (e, stack) {
|
||||
// Ignore errors and create the track locally
|
||||
AppLogger.reportError(e, stack);
|
||||
|
||||
List<Track> tracks = [];
|
||||
for (final trackSimple in this) {
|
||||
Track track = Track();
|
||||
track.name = name;
|
||||
track.album = album;
|
||||
track.artists = artists;
|
||||
track.availableMarkets = availableMarkets;
|
||||
track.discNumber = discNumber;
|
||||
track.durationMs = durationMs;
|
||||
track.explicit = explicit;
|
||||
track.externalUrls = externalUrls;
|
||||
track.href = href;
|
||||
track.id = id;
|
||||
track.isPlayable = isPlayable;
|
||||
track.linkedFrom = linkedFrom;
|
||||
track.name = name;
|
||||
track.previewUrl = previewUrl;
|
||||
track.trackNumber = trackNumber;
|
||||
track.type = type;
|
||||
track.uri = uri;
|
||||
return track;
|
||||
track.name = trackSimple.name;
|
||||
track.artists = trackSimple.artists;
|
||||
track.availableMarkets = trackSimple.availableMarkets;
|
||||
track.discNumber = trackSimple.discNumber;
|
||||
track.durationMs = trackSimple.durationMs;
|
||||
track.explicit = trackSimple.explicit;
|
||||
track.externalUrls = trackSimple.externalUrls;
|
||||
track.href = trackSimple.href;
|
||||
track.id = trackSimple.id;
|
||||
track.isPlayable = trackSimple.isPlayable;
|
||||
track.linkedFrom = trackSimple.linkedFrom;
|
||||
track.previewUrl = trackSimple.previewUrl;
|
||||
track.trackNumber = trackSimple.trackNumber;
|
||||
track.type = trackSimple.type;
|
||||
track.uri = trackSimple.uri;
|
||||
tracks.add(track);
|
||||
}
|
||||
return tracks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class AlbumCard extends HookConsumerWidget {
|
||||
|
||||
Future<List<Track>> fetchAllTrack() async {
|
||||
if (album.tracks != null && album.tracks!.isNotEmpty) {
|
||||
return album.tracks!.map((track) => track.asTrack(album)).toList();
|
||||
return album.tracks!.asTracks(album, ref);
|
||||
}
|
||||
await ref.read(albumTracksProvider(album).future);
|
||||
return ref.read(albumTracksProvider(album).notifier).fetchAll();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:spotify/spotify.dart' hide Image;
|
||||
import 'package:spotube/collections/env.dart';
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
@ -8,6 +8,7 @@ import 'package:spotube/components/image/universal_image.dart';
|
||||
import 'package:spotube/extensions/image.dart';
|
||||
import 'package:spotube/extensions/string.dart';
|
||||
import 'package:spotube/provider/spotify/spotify.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:stroke_text/stroke_text.dart';
|
||||
|
||||
class GenreSectionCardPlaylistCard extends HookConsumerWidget {
|
||||
@ -21,8 +22,10 @@ class GenreSectionCardPlaylistCard extends HookConsumerWidget {
|
||||
Widget build(BuildContext context, ref) {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
final w = kIsDesktop ? 20 : 0;
|
||||
|
||||
return Container(
|
||||
width: 115 * theme.scaling,
|
||||
width: (115 + w) * theme.scaling,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.background.withAlpha(75),
|
||||
borderRadius: theme.borderRadiusMd,
|
||||
@ -65,7 +68,7 @@ class GenreSectionCardPlaylistCard extends HookConsumerWidget {
|
||||
ref.watch(playlistImageProvider(playlist.id!));
|
||||
return SizedBox(
|
||||
height: 100 * theme.scaling,
|
||||
width: 100 * theme.scaling,
|
||||
width: (100 + w) * theme.scaling,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
@ -107,14 +110,14 @@ class GenreSectionCardPlaylistCard extends HookConsumerWidget {
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
height: 100 * theme.scaling,
|
||||
width: 100 * theme.scaling,
|
||||
width: (100 + w) * theme.scaling,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
playlist.name!,
|
||||
maxLines: 2,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
).semiBold().small(),
|
||||
).xSmall().bold(),
|
||||
if (playlist.description != null)
|
||||
Text(
|
||||
playlist.description?.unescapeHtml().cleanHtml() ?? "",
|
||||
|
||||
@ -99,22 +99,26 @@ class LocalFolderItem extends HookConsumerWidget {
|
||||
itemCount: tracks.length,
|
||||
itemBuilder: (context, index) {
|
||||
final track = tracks[index];
|
||||
return UniversalImage(
|
||||
return Expanded(
|
||||
child: UniversalImage(
|
||||
path: (track.album?.images).asUrlString(
|
||||
placeholder: ImagePlaceholder.albumArt,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
Stack(
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Center(
|
||||
child: Flexible(
|
||||
child: Text(
|
||||
isDownloadFolder
|
||||
? context.l10n.downloads
|
||||
@ -127,7 +131,9 @@ class LocalFolderItem extends HookConsumerWidget {
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Wrap(
|
||||
),
|
||||
Flexible(
|
||||
child: Wrap(
|
||||
spacing: 2,
|
||||
runSpacing: 2,
|
||||
children: [
|
||||
@ -137,13 +143,14 @@ class LocalFolderItem extends HookConsumerWidget {
|
||||
TextSpan(
|
||||
children: [
|
||||
if (index != 0) const TextSpan(text: "/ "),
|
||||
TextSpan(text: segment),
|
||||
TextSpan(text: segment)
|
||||
],
|
||||
),
|
||||
maxLines: 2,
|
||||
).xSmall().muted(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!isDownloadFolder && !isCacheFolder)
|
||||
@ -161,8 +168,8 @@ class LocalFolderItem extends HookConsumerWidget {
|
||||
MenuButton(
|
||||
leading: Icon(SpotubeIcons.folderRemove,
|
||||
color: colorScheme.destructive),
|
||||
child:
|
||||
Text(context.l10n.remove_library_location),
|
||||
child: Text(
|
||||
context.l10n.remove_library_location),
|
||||
onPressed: (context) {
|
||||
final libraryLocations = ref
|
||||
.read(userPreferencesProvider)
|
||||
@ -185,6 +192,7 @@ class LocalFolderItem extends HookConsumerWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
|
||||
@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:sliding_up_panel/sliding_up_panel.dart';
|
||||
|
||||
import 'package:spotube/collections/assets.gen.dart';
|
||||
|
||||
@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:palette_generator/palette_generator.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/collections/intents.dart';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:sliding_up_panel/sliding_up_panel.dart';
|
||||
import 'package:spotube/collections/intents.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:spotify/spotify.dart' hide Offset, Image;
|
||||
import 'package:spotube/collections/env.dart';
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||
|
||||
import 'package:spotube/collections/assets.gen.dart';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:skeletonizer/skeletonizer.dart';
|
||||
import 'package:spotube/collections/fake.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||
|
||||
import 'package:spotube/components/titlebar/titlebar.dart';
|
||||
|
||||
@ -2,7 +2,7 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:palette_generator/palette_generator.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:shadcn_flutter/shadcn_flutter_extension.dart';
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
|
||||
@ -125,28 +125,34 @@ class SearchPage extends HookConsumerWidget {
|
||||
child: TextField(
|
||||
autofocus: true,
|
||||
controller: controller,
|
||||
leading:
|
||||
const Icon(SpotubeIcons.search),
|
||||
textInputAction: TextInputAction.search,
|
||||
placeholder: Text(context.l10n.search),
|
||||
trailing: AnimatedCrossFade(
|
||||
duration:
|
||||
const Duration(milliseconds: 300),
|
||||
crossFadeState:
|
||||
controller.text.isNotEmpty
|
||||
features: [
|
||||
const InputFeature.leading(
|
||||
Icon(SpotubeIcons.search),
|
||||
),
|
||||
InputFeature.trailing(
|
||||
AnimatedCrossFade(
|
||||
duration: const Duration(
|
||||
milliseconds: 300),
|
||||
crossFadeState: controller
|
||||
.text.isNotEmpty
|
||||
? CrossFadeState.showFirst
|
||||
: CrossFadeState.showSecond,
|
||||
firstChild: IconButton.ghost(
|
||||
size: ButtonSize.small,
|
||||
icon:
|
||||
const Icon(SpotubeIcons.close),
|
||||
icon: const Icon(
|
||||
SpotubeIcons.close),
|
||||
onPressed: () {
|
||||
controller.clear();
|
||||
},
|
||||
),
|
||||
secondChild: const SizedBox.square(
|
||||
secondChild:
|
||||
const SizedBox.square(
|
||||
dimension: 28),
|
||||
),
|
||||
)
|
||||
],
|
||||
textInputAction: TextInputAction.search,
|
||||
placeholder: Text(context.l10n.search),
|
||||
onSubmitted: onSubmitted,
|
||||
),
|
||||
),
|
||||
|
||||
@ -11,7 +11,7 @@ import 'package:form_builder_validators/form_builder_validators.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:piped_client/piped_client.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' hide Consumer;
|
||||
import 'package:spotube/collections/routes.gr.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/components/form/text_form_field.dart';
|
||||
@ -106,7 +106,7 @@ class SettingsPlaybackSection extends HookConsumerWidget {
|
||||
Tooltip(
|
||||
tooltip: TooltipContainer(
|
||||
child: Text(context.l10n.add_custom_url),
|
||||
),
|
||||
).call,
|
||||
child: IconButton.outline(
|
||||
icon: const Icon(SpotubeIcons.edit),
|
||||
size: ButtonSize.small,
|
||||
@ -261,7 +261,7 @@ class SettingsPlaybackSection extends HookConsumerWidget {
|
||||
Tooltip(
|
||||
tooltip: TooltipContainer(
|
||||
child: Text(context.l10n.add_custom_url),
|
||||
),
|
||||
).call,
|
||||
child: IconButton.outline(
|
||||
icon: const Icon(SpotubeIcons.edit),
|
||||
size: ButtonSize.small,
|
||||
|
||||
@ -128,7 +128,10 @@ class ServerPlaybackRoutes {
|
||||
.read(sourcedTrackProvider(SpotubeMedia(track)).notifier)
|
||||
.refreshStreamingUrl();
|
||||
|
||||
if (playlist.activeTrack?.id == sourcedTrack?.id &&
|
||||
sourcedTrack != null) {
|
||||
ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack);
|
||||
}
|
||||
|
||||
return await dio.get<Uint8List>(
|
||||
sourcedTrack!.url,
|
||||
@ -199,7 +202,10 @@ class ServerPlaybackRoutes {
|
||||
? activeSourcedTrack
|
||||
: await ref.read(sourcedTrackProvider(SpotubeMedia(track)).future);
|
||||
|
||||
if (playlist.activeTrack?.id == sourcedTrack?.id &&
|
||||
sourcedTrack != null) {
|
||||
ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack);
|
||||
}
|
||||
|
||||
final (bytes: audioBytes, response: res) =
|
||||
await streamTrack(sourcedTrack!, request.headers);
|
||||
|
||||
@ -33,7 +33,7 @@ class AlbumTracksNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier<Track,
|
||||
final tracks = await spotify.invoke(
|
||||
(api) => api.albums.tracks(arg.id!).getPage(limit, offset),
|
||||
);
|
||||
final items = tracks.items?.map((e) => e.asTrack(arg)).toList() ?? [];
|
||||
final items = await tracks.items!.asTracks(arg, ref);
|
||||
|
||||
return (
|
||||
items: items,
|
||||
|
||||
@ -236,34 +236,78 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
||||
.toList();
|
||||
}
|
||||
|
||||
static Future<List<YoutubeVideoInfo>> fetchFromIsrc({
|
||||
required Track track,
|
||||
required Ref ref,
|
||||
}) async {
|
||||
final isrcResults = <YoutubeVideoInfo>[];
|
||||
final isrc = track.externalIds?.isrc;
|
||||
if (isrc != null && isrc.isNotEmpty) {
|
||||
final searchedVideos =
|
||||
await ref.read(youtubeEngineProvider).searchVideos(isrc.toString());
|
||||
if (searchedVideos.isNotEmpty) {
|
||||
isrcResults.addAll(searchedVideos
|
||||
.map<YoutubeVideoInfo>(YoutubeVideoInfo.fromVideo)
|
||||
.map((YoutubeVideoInfo videoInfo) {
|
||||
final ytWords = videoInfo.title
|
||||
.toLowerCase()
|
||||
.replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '')
|
||||
.split(RegExp(r'\s+'))
|
||||
.where((item) => item.isNotEmpty);
|
||||
final spWords = track.name!
|
||||
.toLowerCase()
|
||||
.replaceAll(RegExp(r'\((.*)\)'), '')
|
||||
.replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '')
|
||||
.split(RegExp(r'\s+'))
|
||||
.where((item) => item.isNotEmpty);
|
||||
// Word match to filter out unrelated results
|
||||
final matchCount =
|
||||
ytWords.where((word) => spWords.contains(word)).length;
|
||||
if (matchCount > spWords.length ~/ 2) {
|
||||
return videoInfo;
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.whereType<YoutubeVideoInfo>()
|
||||
.toList());
|
||||
}
|
||||
}
|
||||
return isrcResults;
|
||||
}
|
||||
|
||||
static Future<List<SiblingType>> fetchSiblings({
|
||||
required Track track,
|
||||
required Ref ref,
|
||||
}) async {
|
||||
final links = await SongLinkService.links(track.id!);
|
||||
final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube");
|
||||
final videoResults = <YoutubeVideoInfo>[];
|
||||
|
||||
if (ytLink?.url != null
|
||||
// allows to fetch siblings more results for already sourced track
|
||||
&&
|
||||
track is! SourcedTrack) {
|
||||
if (track is! SourcedTrack) {
|
||||
final isrcResults = await fetchFromIsrc(
|
||||
track: track,
|
||||
ref: ref,
|
||||
);
|
||||
|
||||
videoResults.addAll(isrcResults);
|
||||
|
||||
if (isrcResults.isEmpty) {
|
||||
final links = await SongLinkService.links(track.id!);
|
||||
final ytLink = links.firstWhereOrNull(
|
||||
(link) => link.platform == "youtube",
|
||||
);
|
||||
if (ytLink?.url != null) {
|
||||
try {
|
||||
return [
|
||||
await toSiblingType(
|
||||
0,
|
||||
YoutubeVideoInfo.fromVideo(
|
||||
await ref.read(youtubeEngineProvider).getVideo(
|
||||
Uri.parse(ytLink!.url!).queryParameters["v"]!,
|
||||
),
|
||||
),
|
||||
ref,
|
||||
)
|
||||
];
|
||||
videoResults.add(
|
||||
YoutubeVideoInfo.fromVideo(await ref
|
||||
.read(youtubeEngineProvider)
|
||||
.getVideo(Uri.parse(ytLink!.url!).queryParameters["v"]!)),
|
||||
);
|
||||
} on VideoUnplayableException catch (e, stack) {
|
||||
// Ignore this error and continue with the search
|
||||
AppLogger.reportError(e, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final query = SourcedTrack.getSearchTerm(track);
|
||||
|
||||
@ -271,20 +315,27 @@ class YoutubeSourcedTrack extends SourcedTrack {
|
||||
await ref.read(youtubeEngineProvider).searchVideos(query);
|
||||
|
||||
if (ServiceUtils.onlyContainsEnglish(query)) {
|
||||
return await Future.wait(searchResults
|
||||
.map(YoutubeVideoInfo.fromVideo)
|
||||
.mapIndexed((index, info) => toSiblingType(index, info, ref)));
|
||||
}
|
||||
|
||||
final rankedSiblings = rankResults(
|
||||
videoResults
|
||||
.addAll(searchResults.map(YoutubeVideoInfo.fromVideo).toList());
|
||||
} else {
|
||||
videoResults.addAll(rankResults(
|
||||
searchResults.map(YoutubeVideoInfo.fromVideo).toList(),
|
||||
track,
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
final seenIds = <String>{};
|
||||
int index = 0;
|
||||
return await Future.wait(
|
||||
rankedSiblings
|
||||
.mapIndexed((index, info) => toSiblingType(index, info, ref)),
|
||||
);
|
||||
videoResults.map((videoResult) async {
|
||||
// Deduplicate results
|
||||
if (!seenIds.contains(videoResult.id)) {
|
||||
seenIds.add(videoResult.id);
|
||||
return await toSiblingType(index++, videoResult, ref);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
).then((s) => s.whereType<SiblingType>().toList());
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -32,6 +32,7 @@ function(APPLY_STANDARD_SETTINGS TARGET)
|
||||
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||
target_compile_options(${TARGET} PRIVATE -Wno-error=deprecated-declarations)
|
||||
endfunction()
|
||||
|
||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||
|
||||
@ -2012,10 +2012,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: shadcn_flutter
|
||||
sha256: "1e5f40484a42217a69af254952168783d1305025d56dabc45ab16396dba84d5e"
|
||||
sha256: "2b6faf9a93628469c29a534e653295e26781f2799efe5dc971b91e91062ebf52"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.26"
|
||||
version: "0.0.32"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -2449,10 +2449,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: tray_manager
|
||||
sha256: f231031c5c0eb4ad514e18ddaab27a912ddbe50335c594bc28fb0f9972ab6a84
|
||||
sha256: c2da0f0f1ddb455e721cf68d05d1281fec75cf5df0a1d3cb67b6ca0bdfd5709d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.1"
|
||||
version: "0.4.0"
|
||||
type_plus:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -102,7 +102,7 @@ dependencies:
|
||||
ref: dart-3-support
|
||||
url: https://github.com/KRTirtho/scrobblenaut.git
|
||||
scroll_to_index: ^3.0.1
|
||||
shadcn_flutter: ^0.0.26
|
||||
shadcn_flutter: ^0.0.32
|
||||
shared_preferences: ^2.2.3
|
||||
shelf: ^1.4.1
|
||||
shelf_router: ^1.1.4
|
||||
@ -120,7 +120,7 @@ dependencies:
|
||||
test: ^1.25.7
|
||||
timezone: ^0.10.0
|
||||
titlebar_buttons: ^1.0.0
|
||||
tray_manager: ^0.3.0
|
||||
tray_manager: ^0.4.0
|
||||
url_launcher: ^6.2.6
|
||||
uuid: ^4.4.0
|
||||
version: ^3.0.2
|
||||
|
||||
Loading…
Reference in New Issue
Block a user