Skip to content

Commit

Permalink
Update youtubeUtils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaXser authored Dec 27, 2023
1 parent 7f9e51d commit 98c85fa
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/utils/youtubeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,20 @@ async function getLanguage(player, response, title, description) {
// If there is no caption track, use detect to get the language code from the description\

const deletefilter = [
// Filters for deleting a string
/https?:\/\/\S+/g, // remove links
// deletion words
/Auto-generated by YouTube/g,
/Provided to YouTube by/g,
/Released on/g,
];

let cleanedDescription = description
const cleanedDescription = description
.split("\n")
.filter((line) => !deletefilter.some((regex) => regex.test(line)))
.join("\n");

cleanedDescription = cleanedDescription.replace(/[^\p{L}\s]/gu, " ");

cleanedDescription = cleanedDescription.trim().replace(/\s+/g, " ");

cleanedDescription = cleanedDescription.slice(0, 250);
.join("\n")
.replace(/[^\p{L}\s]/gu, " ")
.trim()
.replace(/\s+/g, " ")
.slice(0, 250);

const cleanText = [cleanedDescription, title].join(" ");

Expand Down

0 comments on commit 98c85fa

Please sign in to comment.