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", "fuzzywuzzy",
"gapless", "gapless",
"instrumentalness", "instrumentalness",
"isrc",
"Mpris", "Mpris",
"RGBO", "RGBO",
"riverpod", "riverpod",

View File

@ -20,17 +20,20 @@ class HomeRecentlyPlayedSection extends HookConsumerWidget {
return const SizedBox(); 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( return Skeletonizer(
enabled: history.isLoading, enabled: history.isLoading,
child: HorizontalPlaybuttonCardView( child: HorizontalPlaybuttonCardView(
title: Text(context.l10n.recently_played), title: Text(context.l10n.recently_played),
items: [ items: filteredItems,
for (final item in historyData)
if (item.playlist != null)
item.playlist
else if (item.album != null)
item.album
],
hasNextPage: false, hasNextPage: false,
isLoadingNextPage: false, isLoadingNextPage: false,
onFetchMore: () {}, onFetchMore: () {},

View File

@ -128,7 +128,10 @@ class ServerPlaybackRoutes {
.read(sourcedTrackProvider(SpotubeMedia(track)).notifier) .read(sourcedTrackProvider(SpotubeMedia(track)).notifier)
.refreshStreamingUrl(); .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>( return await dio.get<Uint8List>(
sourcedTrack!.url, sourcedTrack!.url,
@ -199,7 +202,10 @@ class ServerPlaybackRoutes {
? activeSourcedTrack ? activeSourcedTrack
: await ref.read(sourcedTrackProvider(SpotubeMedia(track)).future); : 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) = final (bytes: audioBytes, response: res) =
await streamTrack(sourcedTrack!, request.headers); await streamTrack(sourcedTrack!, request.headers);

View File

@ -238,32 +238,28 @@ class YoutubeSourcedTrack extends SourcedTrack {
static Future<List<YoutubeVideoInfo>> fetchFromIsrc({ static Future<List<YoutubeVideoInfo>> fetchFromIsrc({
required Track track, required Track track,
required Provider provider,
required Ref ref, required Ref ref,
}) async { }) async {
final isrcResults = <YoutubeVideoInfo>[]; final isrcResults = <YoutubeVideoInfo>[];
final isrc = track.externalIds?.isrc; final isrc = track.externalIds?.isrc;
if (isrc != null && isrc.isNotEmpty) { if (isrc != null && isrc.isNotEmpty) {
final searchedVideos = await ref final searchedVideos =
.read(provider) await ref.read(youtubeEngineProvider).searchVideos(isrc.toString());
.searchVideos(isrc.toString());
if (searchedVideos.isNotEmpty) { if (searchedVideos.isNotEmpty) {
isrcResults.addAll(searchedVideos isrcResults.addAll(searchedVideos
.map<YoutubeVideoInfo>(YoutubeVideoInfo.fromVideo) .map<YoutubeVideoInfo>(YoutubeVideoInfo.fromVideo)
.map((YoutubeVideoInfo videoInfo) { .map((YoutubeVideoInfo videoInfo) {
final ytWords = final ytWords = videoInfo.title
videoInfo.title .toLowerCase()
.toLowerCase() .replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '')
.replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '') .split(RegExp(r'\s+'))
.split(RegExp(r'\s+')) .where((item) => item.isNotEmpty);
.where((item) => item.isNotEmpty); final spWords = track.name!
final spWords = .toLowerCase()
track.name! .replaceAll(RegExp(r'\((.*)\)'), '')
.toLowerCase() .replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '')
.replaceAll(RegExp(r'\((.*)\)'), '') .split(RegExp(r'\s+'))
.replaceAll(RegExp(r'[^a-zA-Z0-9\s]+'), '') .where((item) => item.isNotEmpty);
.split(RegExp(r'\s+'))
.where((item) => item.isNotEmpty);
// Word match to filter out unrelated results // Word match to filter out unrelated results
final matchCount = final matchCount =
ytWords.where((word) => spWords.contains(word)).length; ytWords.where((word) => spWords.contains(word)).length;
@ -271,8 +267,9 @@ class YoutubeSourcedTrack extends SourcedTrack {
return videoInfo; return videoInfo;
} }
return null; return null;
} })
).whereType<YoutubeVideoInfo>().toList()); .whereType<YoutubeVideoInfo>()
.toList());
} }
} }
return isrcResults; return isrcResults;
@ -284,22 +281,31 @@ class YoutubeSourcedTrack extends SourcedTrack {
}) async { }) async {
final videoResults = <YoutubeVideoInfo>[]; final videoResults = <YoutubeVideoInfo>[];
final isrcResults = await fetchFromIsrc(track: track, provider: youtubeEngineProvider, ref: ref); if (track is! SourcedTrack) {
videoResults.addAll(isrcResults); final isrcResults = await fetchFromIsrc(
track: track,
ref: ref,
);
final links = await SongLinkService.links(track.id!); videoResults.addAll(isrcResults);
final ytLink = links.firstWhereOrNull((link) => link.platform == "youtube");
if (isrcResults.isEmpty && ytLink?.url != null) { if (isrcResults.isEmpty) {
try { final links = await SongLinkService.links(track.id!);
videoResults.add( final ytLink = links.firstWhereOrNull(
YoutubeVideoInfo.fromVideo( (link) => link.platform == "youtube",
await ref.read(youtubeEngineProvider) );
.getVideo(Uri.parse(ytLink!.url!).queryParameters["v"]!) if (ytLink?.url != null) {
)); try {
} on VideoUnplayableException catch (e, stack) { videoResults.add(
// Ignore this error and continue with the search YoutubeVideoInfo.fromVideo(await ref
AppLogger.reportError(e, stack); .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); await ref.read(youtubeEngineProvider).searchVideos(query);
if (ServiceUtils.onlyContainsEnglish(query)) { if (ServiceUtils.onlyContainsEnglish(query)) {
videoResults.addAll( videoResults
searchResults.map(YoutubeVideoInfo.fromVideo).toList() .addAll(searchResults.map(YoutubeVideoInfo.fromVideo).toList());
);
} else { } else {
videoResults.addAll(rankResults( videoResults.addAll(rankResults(
searchResults.map(YoutubeVideoInfo.fromVideo).toList(), searchResults.map(YoutubeVideoInfo.fromVideo).toList(),
track, track,
)); ));
} }

View File

@ -32,6 +32,7 @@ function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE -Wall -Werror)
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>") target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>") target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
target_compile_options(${TARGET} PRIVATE -Wno-error=deprecated-declarations)
endfunction() endfunction()
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")

View File

@ -2449,10 +2449,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: tray_manager name: tray_manager
sha256: f231031c5c0eb4ad514e18ddaab27a912ddbe50335c594bc28fb0f9972ab6a84 sha256: c2da0f0f1ddb455e721cf68d05d1281fec75cf5df0a1d3cb67b6ca0bdfd5709d
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.1" version: "0.4.0"
type_plus: type_plus:
dependency: transitive dependency: transitive
description: description:

View File

@ -120,7 +120,7 @@ dependencies:
test: ^1.25.7 test: ^1.25.7
timezone: ^0.10.0 timezone: ^0.10.0
titlebar_buttons: ^1.0.0 titlebar_buttons: ^1.0.0
tray_manager: ^0.3.0 tray_manager: ^0.4.0
url_launcher: ^6.2.6 url_launcher: ^6.2.6
uuid: ^4.4.0 uuid: ^4.4.0
version: ^3.0.2 version: ^3.0.2