-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add route of javtiful (#16964)
* feat(route): add route of javtiful * fix: fix some wrong
- Loading branch information
Showing
5 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Route, Data, DataItem } from '@/types'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { load } from 'cheerio'; | ||
import { parseItems } from './utils'; | ||
|
||
export const route: Route = { | ||
path: '/actress/:id', | ||
name: 'Actress', | ||
maintainers: ['huanfe1'], | ||
example: '/javtiful/actress/akari-tsumugi', | ||
parameters: { id: 'Actress name' }, | ||
handler, | ||
categories: ['multimedia'], | ||
radar: [ | ||
{ | ||
source: ['javtiful.com/actress/:id', 'javtiful.com/actress/:id/*'], | ||
target: '/actress/:id', | ||
}, | ||
], | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const { id } = ctx.req.param(); | ||
const html = await ofetch(`https://javtiful.com/actress/${id}`); | ||
const $ = load(<string>html); | ||
const items: DataItem[] = $('section .card:not(:has(.bg-danger))') | ||
.toArray() | ||
.map((item) => parseItems($(item))); | ||
return { | ||
title: $('.channel-item__name_details a').text(), | ||
link: `https://javtiful.com/actress/${id}`, | ||
allowEmpty: true, | ||
item: items, | ||
image: $('.content-section-title img').attr('src'), | ||
language: $('html').attr('lang'), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Route, Data, DataItem } from '@/types'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { load } from 'cheerio'; | ||
import { parseItems } from './utils'; | ||
|
||
export const route: Route = { | ||
path: '/channel/:id', | ||
name: 'Channel', | ||
maintainers: ['huanfe1'], | ||
example: '/javtiful/channel/madonna', | ||
parameters: { id: 'Channel name' }, | ||
handler, | ||
categories: ['multimedia'], | ||
radar: [ | ||
{ | ||
source: ['javtiful.com/channel/:id', 'javtiful.com/channel/:id/*'], | ||
target: '/channel/:id', | ||
}, | ||
], | ||
}; | ||
|
||
async function handler(ctx): Promise<Data> { | ||
const { id } = ctx.req.param(); | ||
const html = await ofetch(`https://javtiful.com/channel/${id}`); | ||
const $ = load(<string>html); | ||
const items: DataItem[] = $('section .card:not(:has(.bg-danger))') | ||
.toArray() | ||
.map((item) => parseItems($(item))); | ||
return { | ||
title: $('.channel-item__name_details a').text(), | ||
link: `https://javtiful.com/channel/${id}`, | ||
allowEmpty: true, | ||
item: items, | ||
image: $('.content-section-title img').attr('src'), | ||
language: $('html').attr('lang'), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Javtiful', | ||
url: 'javtiful.com', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{ if previewVideo }} | ||
<video controls preload="metadata" poster="{{ poster }}"> | ||
<source src="{{ previewVideo }}" type="video/mp4"> | ||
</video> | ||
{{else if poster}} | ||
<img src="{{ poster }}"> | ||
{{ /if }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getCurrentPath } from '@/utils/helpers'; | ||
const __dirname = getCurrentPath(import.meta.url); | ||
|
||
import { art } from '@/utils/render'; | ||
import path from 'node:path'; | ||
import { parseRelativeDate } from '@/utils/parse-date'; | ||
|
||
const renderDescription = (data) => art(path.join(__dirname, 'templates/description.art'), data); | ||
|
||
export const parseItems = (e) => ({ | ||
title: e.find('a > img').attr('alt')!, | ||
link: e.find('a').attr('href')!, | ||
description: renderDescription({ | ||
poster: e.find('a > img').data('src'), | ||
previewVideo: e.find('a > span').data('trailer'), | ||
}), | ||
pubDate: parseRelativeDate(e.find('.video-addtime').text()), | ||
}); |