import { dataToRSS } from "https://esm.town/v/Glench/dataToRSS";
import { fetch } from "https://esm.town/v/std/fetch";
async function getOfficialRedditPosts() {
const resp = await fetch("https://www.reddit.com/r/googlephotos/.json");
if (!resp.ok) return [];
const json = await resp.json();
const filtered_posts = json.data.children.filter(x => {
const title = x.data.title.toLowerCase();
return title.includes("delet") || title.includes("remov") || title.includes("free");
});
return filtered_posts;
}
async function getGoogleSupportForumPosts() {
const resp = await fetch(
"https://support.google.com/photos/threads?hl=en&max_results=500",
);
const text = await resp.text();
const [_, ...threads_text] = text.split(/class="thread-list-thread"/);
return threads_text.map(x => {
const id = x.match(/\d+/)[0];
const url = `https://support.google.com${x.split("href=\"")[1].split("\"")[0]}`;
const title = x.split("thread-list-thread__title\">")[1].split("<span")[0].trim() + " (Google Support Forum)";
const selfText = x.split("\"thread-list-thread__snippet\">")[1].split("</span>")[0];
return { data: { created: id, url, title, selfText } };
}).filter(thread_obj => {
const title = thread_obj.data.title.toLowerCase();
return title.includes("delet") && !(
title.includes("recover")
|| title.includes("restor")
|| title.includes("perma")
|| title.includes("trash")
|| title.includes("back")
|| title.includes("deleted")
|| title.includes("mistak")
);
});
}
export const googlePhotosMarketingRSS = async (x) => {
const reddit_posts = await getOfficialRedditPosts();
const google_forum_posts = [];
return new Response(dataToRSS([...reddit_posts, ...google_forum_posts], {
title: "Delete All Google Photos Marketing RSS",
description:
"For marketing Delete All Google Photos Extension. Scrapes r/GooglePhotos and Google's official support forum.",
link: "https://www.reddit.com/r/googlephotos/",
item: {
title: x => x.data.title,
description: x => x.data.selfText,
link: x => x.data.url,
pubDate: x => x.data.created,
},
}));
};