Compare commits

...

6 Commits

Author SHA1 Message Date
Richard Hajek
6906a92f82
Merge 42e954428b into b74c2eab8f 2025-03-28 21:20:44 +06:00
Kingkor Roy Tirtho
b74c2eab8f fix: calling /track/:streamId endpoint causes active sourced track to be anything 2025-03-28 20:57:46 +06:00
Richard Hajek
42e954428b feat: added filtering duplicates in recent 2025-01-18 18:01:26 +01:00
Kingkor Roy Tirtho
8c1337d1fc
Merge pull request #2118 from KRTirtho/dev
chore: release 3.9.0
2024-12-09 00:04:29 +06:00
Kingkor Roy Tirtho
94e704087f Merge branch 'dev' 2024-10-09 16:38:23 +06:00
Kingkor Roy Tirtho
8e287ab1e5
Merge pull request #1981 from KRTirtho/dev
Release 3.8.3
2024-10-09 15:39:31 +06:00
7 changed files with 67 additions and 51 deletions

View File

@ -9,6 +9,7 @@
"fuzzywuzzy",
"gapless",
"instrumentalness",
"isrc",
"Mpris",
"RGBO",
"riverpod",

View File

@ -9,7 +9,7 @@ import 'package:spotube/provider/history/recent.dart';
class HomeRecentlyPlayedSection extends HookConsumerWidget {
const HomeRecentlyPlayedSection({super.key});
@override
Widget build(BuildContext context, ref) {
final history = ref.watch(recentlyPlayedItems);
@ -20,17 +20,20 @@ class HomeRecentlyPlayedSection extends HookConsumerWidget {
return const SizedBox();
}
final uniqueItems = <dynamic>{};
final filteredItems = [
for (final item in historyData)
if (item.playlist != null && item.playlist?.id != null && uniqueItems.add(item.playlist!.id!))
item.playlist
else if (item.album != null && item.album?.id != null && uniqueItems.add(item.album?.id))
item.album
];
return Skeletonizer(
enabled: history.isLoading,
child: HorizontalPlaybuttonCardView(
title: Text(context.l10n.recently_played),
items: [
for (final item in historyData)
if (item.playlist != null)
item.playlist
else if (item.album != null)
item.album
],
items: filteredItems,
hasNextPage: false,
isLoadingNextPage: false,
onFetchMore: () {},

View File

@ -128,7 +128,10 @@ class ServerPlaybackRoutes {
.read(sourcedTrackProvider(SpotubeMedia(track)).notifier)
.refreshStreamingUrl();
ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack);
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);
ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack);
if (playlist.activeTrack?.id == sourcedTrack?.id &&
sourcedTrack != null) {
ref.read(activeSourcedTrackProvider.notifier).update(sourcedTrack);
}
final (bytes: audioBytes, response: res) =
await streamTrack(sourcedTrack!, request.headers);

View File

@ -238,32 +238,28 @@ class YoutubeSourcedTrack extends SourcedTrack {
static Future<List<YoutubeVideoInfo>> fetchFromIsrc({
required Track track,
required Provider provider,
required Ref ref,
}) async {
final isrcResults = <YoutubeVideoInfo>[];
final isrc = track.externalIds?.isrc;
if (isrc != null && isrc.isNotEmpty) {
final searchedVideos = await ref
.read(provider)
.searchVideos(isrc.toString());
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);
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;
@ -271,8 +267,9 @@ class YoutubeSourcedTrack extends SourcedTrack {
return videoInfo;
}
return null;
}
).whereType<YoutubeVideoInfo>().toList());
})
.whereType<YoutubeVideoInfo>()
.toList());
}
}
return isrcResults;
@ -284,22 +281,31 @@ class YoutubeSourcedTrack extends SourcedTrack {
}) async {
final videoResults = <YoutubeVideoInfo>[];
final isrcResults = await fetchFromIsrc(track: track, provider: youtubeEngineProvider, ref: ref);
videoResults.addAll(isrcResults);
if (track is! SourcedTrack) {
final isrcResults = await fetchFromIsrc(
track: track,
ref: ref,
);
final links = await SongLinkService.links(track.id!);
final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube");
videoResults.addAll(isrcResults);
if (isrcResults.isEmpty && ytLink?.url != null) {
try {
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);
if (isrcResults.isEmpty) {
final links = await SongLinkService.links(track.id!);
final ytLink = links.firstWhereOrNull(
(link) => link.platform == "youtube",
);
if (ytLink?.url != null) {
try {
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);
}
}
}
}
@ -309,13 +315,12 @@ class YoutubeSourcedTrack extends SourcedTrack {
await ref.read(youtubeEngineProvider).searchVideos(query);
if (ServiceUtils.onlyContainsEnglish(query)) {
videoResults.addAll(
searchResults.map(YoutubeVideoInfo.fromVideo).toList()
);
videoResults
.addAll(searchResults.map(YoutubeVideoInfo.fromVideo).toList());
} else {
videoResults.addAll(rankResults(
searchResults.map(YoutubeVideoInfo.fromVideo).toList(),
track,
searchResults.map(YoutubeVideoInfo.fromVideo).toList(),
track,
));
}

View File

@ -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")

View File

@ -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:

View File

@ -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