Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions lib/routes/scroll/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Data, Route, ViewType } from '@/types';
import { rootUrl, extractFeedArticleLinks, fetchArticleContent } from './utils';

const categoryMap = {
politics: '76',
culture: '107',
india: '105',
world: '3554',
};

export const route: Route = {
path: '/category/:category',
view: ViewType.Articles,
categories: ['new-media'],
example: '/scroll/category/india',
parameters: {
category: {
description: 'Category name',
options: [
{ value: 'politics', label: 'Politics' },
{ value: 'culture', label: 'Culture' },
{ value: 'india', label: 'India' },
{ value: 'world', label: 'World' },
],
},
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scroll.in/category/:id/:category'],
target: '/category/:category',
},
],
name: 'Category',
maintainers: ['Rjnishant530'],
handler,
};

async function handler(ctx: any) {
const { category } = ctx.req.param();
const categoryId = categoryMap[category.toLowerCase()];

if (!categoryId) {
throw new Error(`Invalid category: ${category}. Valid categories are: ${Object.keys(categoryMap).join(', ')}`);
}

const currentUrl = `${rootUrl}/category/${categoryId}/${category}`;
const articleLinks = await extractFeedArticleLinks(`category/${categoryId}`);
const items = await Promise.all(articleLinks.map((item) => fetchArticleContent(item)));

return {
title: `Scroll.in - ${category.charAt(0).toUpperCase() + category.slice(1)}`,
description: `Stories published under ${category.charAt(0).toUpperCase() + category.slice(1)}`,
link: currentUrl,
item: items,
language: 'en',
logo: `${rootUrl}/favicon.ico`,
icon: `${rootUrl}/favicon.ico`,
} as Data;
}
43 changes: 43 additions & 0 deletions lib/routes/scroll/common-ground.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Data, Route, ViewType } from '@/types';
import { rootUrl, extractFeedArticleLinks, fetchArticleContent } from './utils';

export const route: Route = {
path: '/commonGround',
view: ViewType.Articles,
categories: ['new-media'],
example: '/scroll/commonGround',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scroll.in/topic/56439/common-ground'],
target: '/commonGround',
},
],
name: 'Common Ground',
maintainers: ['Rjnishant530'],
handler,
};

async function handler() {
const currentUrl = `${rootUrl}/topic/56439/common-ground`;
const articleLinks = await extractFeedArticleLinks('topic/56439');

const items = await Promise.all(articleLinks.map((item) => fetchArticleContent(item)));

return {
title: 'Scroll.in - Common Ground',
description: 'Common Ground articles from Scroll.in',
link: currentUrl,
item: items,
language: 'en',
logo: `${rootUrl}/favicon.ico`,
icon: `${rootUrl}/favicon.ico`,
} as Data;
}
42 changes: 42 additions & 0 deletions lib/routes/scroll/eco-india.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Data, Route, ViewType } from '@/types';
import { rootUrl, extractFeedArticleLinks, fetchArticleContent } from './utils';

export const route: Route = {
path: '/ecoIndia',
view: ViewType.Articles,
categories: ['new-media'],
example: '/scroll/ecoIndia',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scroll.in/topic/56120/eco-india'],
target: '/ecoIndia',
},
],
name: 'Eco India',
maintainers: ['Rjnishant530'],
handler,
};

async function handler() {
const currentUrl = `${rootUrl}/topic/56120/eco-india`;
const articleLinks = await extractFeedArticleLinks('topic/56120');
const items = await Promise.all(articleLinks.map((item) => fetchArticleContent(item)));

return {
title: 'Scroll.in - Eco India',
description: 'Eco India articles and videos from Scroll.in',
link: currentUrl,
item: items,
language: 'en',
logo: `${rootUrl}/favicon.ico`,
icon: `${rootUrl}/favicon.ico`,
} as Data;
}
42 changes: 42 additions & 0 deletions lib/routes/scroll/latest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Data, Route, ViewType } from '@/types';
import { rootUrl, extractFeedArticleLinks, fetchArticleContent } from './utils';

export const route: Route = {
path: '/latest',
view: ViewType.Articles,
categories: ['new-media'],
example: '/scroll/latest',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scroll.in/latest/'],
target: '/latest',
},
],
name: 'Latest News',
maintainers: ['Rjnishant530'],
handler,
};

async function handler() {
const currentUrl = `${rootUrl}/latest/`;
const articleLinks = await extractFeedArticleLinks('series/2');
const items = await Promise.all(articleLinks.map((item) => fetchArticleContent(item)));

return {
title: 'Scroll.in - Latest News',
description: 'Latest news from Scroll.in',
link: currentUrl,
item: items,
language: 'en',
logo: `${rootUrl}/favicon.ico`,
icon: `${rootUrl}/favicon.ico`,
} as Data;
}
8 changes: 8 additions & 0 deletions lib/routes/scroll/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Scroll',
url: 'scroll.in',
categories: ['new-media'],
lang: 'en',
};
42 changes: 42 additions & 0 deletions lib/routes/scroll/the-india-fix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Data, Route, ViewType } from '@/types';
import { rootUrl, extractFeedArticleLinks, fetchArticleContent } from './utils';

export const route: Route = {
path: '/theIndiaFix',
view: ViewType.Articles,
categories: ['new-media'],
example: '/scroll/theIndiaFix',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scroll.in/topic/56455/the-india-fix'],
target: '/theIndiaFix',
},
],
name: 'The India Fix',
maintainers: ['Rjnishant530'],
handler,
};

async function handler() {
const currentUrl = `${rootUrl}/topic/56455/the-india-fix`;
const articleLinks = await extractFeedArticleLinks('topic/56455');
const items = await Promise.all(articleLinks.map((item) => fetchArticleContent(item)));

return {
title: 'Scroll.in - The India Fix',
description: 'The India Fix articles from Scroll.in',
link: currentUrl,
item: items,
language: 'en',
logo: `${rootUrl}/favicon.ico`,
icon: `${rootUrl}/favicon.ico`,
} as Data;
}
42 changes: 42 additions & 0 deletions lib/routes/scroll/trending.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Data, Route, ViewType } from '@/types';
import { rootUrl, extractTrendingArticles, fetchArticleContent } from './utils';

export const route: Route = {
path: '/trending',
view: ViewType.Articles,
categories: ['new-media'],
example: '/scroll/trending',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['scroll.in/trending'],
target: '/trending',
},
],
name: 'Trending',
maintainers: ['Rjnishant530'],
handler,
};

async function handler() {
const currentUrl = `${rootUrl}/trending`;
const articleLinks = await extractTrendingArticles();
const items = await Promise.all(articleLinks.map((item) => fetchArticleContent(item)));

return {
title: 'Scroll.in - Trending',
description: 'Trending articles from Scroll.in',
link: currentUrl,
item: items,
language: 'en',
logo: `${rootUrl}/favicon.ico`,
icon: `${rootUrl}/favicon.ico`,
} as Data;
}
Loading
Loading