Skip to content

Commit c66ff2b

Browse files
committed
Apply clean up util to title + enrich prefixes
1 parent d089487 commit c66ff2b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

plugins/downloader/youtube-dl.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const ytdl = require("ytdl-core");
1515
const { triggerAction, triggerActionSync } = require("../utils");
1616
const { ACTIONS, CHANNEL } = require("./actions.js");
1717
const { getFolder, urlToJPG } = require("./utils");
18-
const { cleanupArtistName } = require("../../providers/song-info");
18+
const { cleanupName } = require("../../providers/song-info");
1919

2020
const { createFFmpeg } = FFmpeg;
2121
const ffmpeg = createFFmpeg({
@@ -40,7 +40,10 @@ const downloadVideoToMP3 = async (
4040
const { videoDetails } = await ytdl.getInfo(videoUrl);
4141
const thumbnails = videoDetails?.thumbnails;
4242
metadata = {
43-
artist: videoDetails?.media?.artist || cleanupArtistName(videoDetails?.author?.name) || "",
43+
artist:
44+
videoDetails?.media?.artist ||
45+
cleanupName(videoDetails?.author?.name) ||
46+
"",
4447
title: videoDetails?.media?.song || videoDetails?.title || "",
4548
imageSrcYTPL: thumbnails ?
4649
urlToJPG(thumbnails[thumbnails.length - 1].url, videoDetails?.videoId)

providers/song-info.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ const songInfo = {
5555

5656
const handleData = async (responseText, win) => {
5757
let data = JSON.parse(responseText);
58-
songInfo.title = data?.videoDetails?.title;
59-
songInfo.artist = await getArtist(win) || cleanupArtistName(data?.videoDetails?.author);
58+
songInfo.title = cleanupName(data?.videoDetails?.title);
59+
songInfo.artist =
60+
(await getArtist(win)) || cleanupName(data?.videoDetails?.author);
6061
songInfo.views = data?.videoDetails?.viewCount;
6162
songInfo.imageSrc = data?.videoDetails?.thumbnail?.thumbnails?.pop()?.url;
6263
songInfo.songDuration = data?.videoDetails?.lengthSeconds;
@@ -98,8 +99,15 @@ const registerProvider = (win) => {
9899
});
99100
};
100101

101-
const suffixesToRemove = [' - Topic', 'VEVO'];
102-
function cleanupArtistName(artist) {
102+
const suffixesToRemove = [
103+
" - Topic",
104+
"VEVO",
105+
" (Performance Video)",
106+
" (Official Music Video)",
107+
" (Official Video)",
108+
" (Clip officiel)",
109+
];
110+
function cleanupName(artist) {
103111
if (!artist) {
104112
return artist;
105113
}
@@ -114,4 +122,4 @@ function cleanupArtistName(artist) {
114122
module.exports = registerCallback;
115123
module.exports.setupSongInfo = registerProvider;
116124
module.exports.getImage = getImage;
117-
module.exports.cleanupArtistName = cleanupArtistName;
125+
module.exports.cleanupName = cleanupName;

0 commit comments

Comments
 (0)