Skip to content

Commit

Permalink
chore: remove - topic from video artist download tags
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Feb 16, 2024
1 parent a3b2b58 commit eccec09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
12 changes: 10 additions & 2 deletions lib/base/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1414,10 +1414,18 @@ extension YoutubeIDToMediaItem on YoutubeID {
final artistAndTitle = vi?.name?.splitArtistAndTitle();
final videoName = vi?.name;
final channelName = vi?.uploaderName;

final title = artistAndTitle?.$2?.keepFeatKeywordsOnly() ?? videoName ?? '';
String? artistName = artistAndTitle?.$1;
if ((artistName == null || artistName == '') && channelName != null) {
const topic = '- Topic';
final startIndex = (channelName.length - topic.length).withMinimum(0);
artistName = channelName.replaceFirst(topic, '', startIndex).trimAll();
}
return MediaItem(
id: vi?.id ?? '',
title: artistAndTitle?.$2?.keepFeatKeywordsOnly() ?? videoName ?? '',
artist: artistAndTitle?.$1 ?? channelName?.replaceFirst('- Topic', '').trimAll(),
title: title,
artist: artistName,
album: '',
genre: '',
displayTitle: videoName,
Expand Down
11 changes: 10 additions & 1 deletion lib/youtube/yt_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ class YTUtils {
}

static Map<String, String?> getMetadataInitialMap(String id, VideoInfo? info, {bool autoExtract = true}) {
String removeTopic(String text) {
const topic = '- Topic';
final startIndex = (text.length - topic.length).withMinimum(0);
return text.replaceFirst(topic, '', startIndex).trimAll();
}

final date = info?.date;
final description = info?.description;
String? title = info?.name;
Expand All @@ -272,10 +278,13 @@ class YTUtils {
if (splitted != null && splitted.$1 != null && splitted.$2 != null) {
title = splitted.$2;
artist = splitted.$1;
album = info?.uploaderName;
}
final uploaderName = info?.uploaderName;
if (uploaderName != null) album = removeTopic(uploaderName);
}

if (artist != null) artist = removeTopic(artist);

String? synopsis;
if (description != null) {
try {
Expand Down

0 comments on commit eccec09

Please sign in to comment.