Skip to content

Commit 0d618d1

Browse files
committed
Remove redundant video titles from descriptions
youtube displays video title in the description
1 parent 538e87e commit 0d618d1

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

node-scripts/yt-description.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,23 @@ function writeDescription(video) {
476476
description += `\n${group.title}:\n`;
477477
for (const link of group.links) {
478478
link.icon = link.icon || (group.title === 'Videos' ? '🎥' : '🔗');
479-
const url = link.url;
480-
if (/https?:\/\/.*/.test(url)) {
479+
let url;
480+
if (/https?:\/\/.*/.test(link.url)) {
481481
// Starts with http:// or https://
482-
description += `${link.icon} ${link.title}: ${url}\n`;
482+
url = link.url;
483483
} else {
484484
// assume relative link in thecodingtrain.com
485485
// try to get YT link instead of website link
486-
description += `${link.icon} ${link.title}: ${resolveCTLink(url)}\n`;
486+
url = resolveCTLink(link.url);
487+
}
488+
// if it's a youtube link, don't add the title (#1280)
489+
if (
490+
new URL(url).hostname.includes('youtube') ||
491+
new URL(url).hostname.includes('youtu.be')
492+
) {
493+
description += `${link.icon} ${url}\n`;
494+
} else {
495+
description += `${link.icon} ${link.title} ${url}\n`;
487496
}
488497
}
489498
}
@@ -499,8 +508,7 @@ function writeDescription(video) {
499508
if (challengeData) {
500509
const { videoNumber, challengeTitle } = challengeData.data;
501510
const url = challengeData.canonicalURL;
502-
description +=
503-
`🚂 ${videoNumber} ${challengeTitle}: ${resolveCTLink(url)}` + '\n';
511+
description += `🚂 CC${videoNumber} ${resolveCTLink(url)}` + '\n';
504512
} else {
505513
console.log(`Challenge ${challenge} not found`);
506514
}

0 commit comments

Comments
 (0)