lemmy-piped-link-bot icon indicating copy to clipboard operation
lemmy-piped-link-bot copied to clipboard

Check if the original link is refering to a video

Open miku4k opened this issue 1 year ago • 0 comments

Problem

Some links to youtube.com aren't videos (e.g. community posts, the settings, and YouTube Studio), but they get picked up by PipedLinkBot anyway which spits out broken links.

This would fix #1 and #67.

Possible Solution

With my limited understanding of things, I think changing the array at line 14 in utils.ts to replace "youtube.com"with "youtube.com/watch" and add "youtube.com/shorts" and somehow making line 20 use "piped.video/watch" if urlObj.hostname begins with "youtube.com" would do the job.

This code should be near functional to replace line 20, but I don't have a way of verifying that right now.

const isYTcom = urlObj.hostname.startsWith("youtube.com");

if (isYTcom) {
        urlObj.hostname = "piped.video/watch";
}; 
else {
        urlObj.hostname = "piped.video";
};

miku4k avatar Nov 03 '23 22:11 miku4k