mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-12-20 01:11:34 +08:00
chore: clean code
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import dayjs from "dayjs/esm"
|
||||
import { myFetch } from "#/utils/fetch"
|
||||
import { defineSource } from "#/utils/source"
|
||||
|
||||
@@ -46,68 +45,13 @@ const hotRankList = defineSource(async () => {
|
||||
})
|
||||
|
||||
return resp?.items[0]?.video[0]?.data.map((item) => {
|
||||
const creator = item.creator?.map(a => a.name).join(" ")
|
||||
const contributor = item.contributor?.map(a => a.name).join(" ")
|
||||
const info = [item.desc, creator, contributor].filter(Boolean).join("|")
|
||||
return {
|
||||
id: item.entity_id,
|
||||
title: item.title,
|
||||
url: item.page_url,
|
||||
pubDate: item?.showDate,
|
||||
extra: {
|
||||
info,
|
||||
hover: item.description,
|
||||
tag: item.tag,
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
interface WarpCartoon {
|
||||
code: number
|
||||
cname: string
|
||||
items: {
|
||||
order: number
|
||||
channel: string
|
||||
temp: any
|
||||
video: {
|
||||
basisDataUrls: string
|
||||
title: string
|
||||
block_id: string
|
||||
card_source: string
|
||||
links: any[]
|
||||
data: VideoInfo[]
|
||||
adverts: any[]
|
||||
config: any[]
|
||||
}[]
|
||||
lib_keys: any
|
||||
}[]
|
||||
extData: any
|
||||
}
|
||||
|
||||
const cartoonToday = defineSource(async () => {
|
||||
const url = "https://mesh.if.iqiyi.com/portal/lw/v7/channel/cartoon"
|
||||
const resp = await myFetch<WarpCartoon>(url, {
|
||||
headers: { Referer: "https://www.iqiyi.com" },
|
||||
})
|
||||
|
||||
// items[2] 为追番表数据
|
||||
const items = resp?.items[2]
|
||||
// 获取今天是一周的第几天
|
||||
const weekday = dayjs().day() || 7
|
||||
// 获取今天的追番表数据
|
||||
const videos = items?.video[weekday - 1] // 减去1是因为数组索引从0开始
|
||||
return videos?.data.map((item) => {
|
||||
const creator = item.creator?.map(a => a.name).join(" ")
|
||||
const contributor = item.contributor?.map(a => a.name).join(" ")
|
||||
const info = [item.desc, item.dq_updatestatus, creator, contributor].filter(Boolean).join("|")
|
||||
return {
|
||||
id: item.entity_id,
|
||||
title: item.title,
|
||||
url: item.page_url,
|
||||
pubDate: item?.showDate,
|
||||
extra: {
|
||||
info,
|
||||
info: item.desc,
|
||||
hover: item.description,
|
||||
tag: item.tag,
|
||||
},
|
||||
@@ -117,5 +61,4 @@ const cartoonToday = defineSource(async () => {
|
||||
|
||||
export default defineSource({
|
||||
"iqiyi-hot-ranklist": hotRankList,
|
||||
"iqiyi-cartoon-today": cartoonToday,
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import dayjs from "dayjs/esm"
|
||||
import { myFetch } from "#/utils/fetch.ts"
|
||||
import { defineSource } from "#/utils/source.ts"
|
||||
import { myFetch } from "#/utils/fetch"
|
||||
import { defineSource } from "#/utils/source"
|
||||
|
||||
interface WapResp {
|
||||
data: {
|
||||
@@ -138,23 +138,12 @@ const hotSearch = defineSource(async () => {
|
||||
})
|
||||
|
||||
return resp?.data?.card?.children_list?.list?.cards?.map((item) => {
|
||||
const uni_imgtag = JSON.parse(item?.params?.uni_imgtag)
|
||||
// 去掉空值
|
||||
const info = [
|
||||
item?.params?.second_title,
|
||||
item?.params?.topic_label,
|
||||
uni_imgtag?.tag_2?.text,
|
||||
uni_imgtag?.tag_4?.text,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ")
|
||||
return {
|
||||
id: item?.id,
|
||||
title: item?.params?.title,
|
||||
url: getQqVideoUrl(item?.id),
|
||||
pubDate: item?.params?.publish_date ?? getTodaySlash(),
|
||||
extra: {
|
||||
info,
|
||||
hover: item?.params?.sub_title,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -47,11 +47,6 @@
|
||||
"steam": "Steam-zaixianrenshu",
|
||||
"tencent-hot": "tengxunxinwen-zonghezaobao",
|
||||
"freebuf": "Freebuf-wangluoanquan",
|
||||
|
||||
"qqvideo-tv-hotsearch": "tengxunshipin-dianshiju-resoubang"
|
||||
|
||||
"iqiyi-hot-ranklist": "aiqiyi-rebobang",
|
||||
"iqiyi-cartoon-today": "aiqiyi-dongman-zhuifanbiao",
|
||||
|
||||
"youku-webcomic-today": "youku-dongman-zhuifanbiao"
|
||||
"qqvideo-tv-hotsearch": "tengxunshipin-dianshiju-resoubang",
|
||||
"iqiyi-hot-ranklist": "aiqiyi-rebobang"
|
||||
}
|
||||
@@ -461,13 +461,13 @@ export const originSources = {
|
||||
home: "https://v.qq.com/",
|
||||
sub: {
|
||||
"tv-hotsearch": {
|
||||
title: "电视剧-热搜榜",
|
||||
title: "热搜榜",
|
||||
type: "hottest",
|
||||
interval: Time.Common,
|
||||
home: "https://v.qq.com/channel/tv",
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
"iqiyi": {
|
||||
name: "爱奇艺",
|
||||
@@ -481,26 +481,6 @@ export const originSources = {
|
||||
interval: Time.Common,
|
||||
home: "https://www.iqiyi.com",
|
||||
},
|
||||
"cartoon-today": {
|
||||
title: "动漫-追番表",
|
||||
type: "hottest",
|
||||
interval: Time.Slow,
|
||||
home: "https://www.iqiyi.com/comic",
|
||||
},
|
||||
},
|
||||
},
|
||||
"youku": {
|
||||
name: "优酷",
|
||||
column: "china",
|
||||
color: "blue",
|
||||
home: "https://www.youku.com/ku/webhome",
|
||||
sub: {
|
||||
"webcomic-today": {
|
||||
title: "动漫-追番表",
|
||||
type: "hottest",
|
||||
interval: Time.Slow,
|
||||
home: "https://www.youku.com/ku/webcomic",
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const satisfies Record<string, OriginSource>
|
||||
|
||||
@@ -526,5 +526,42 @@
|
||||
"color": "green",
|
||||
"interval": 600000
|
||||
},
|
||||
|
||||
"qqvideo": {
|
||||
"redirect": "qqvideo-tv-hotsearch",
|
||||
"name": "腾讯视频",
|
||||
"type": "hottest",
|
||||
"column": "china",
|
||||
"home": "https://v.qq.com/channel/tv",
|
||||
"color": "blue",
|
||||
"interval": 1800000,
|
||||
"title": "电视剧-热搜榜"
|
||||
},
|
||||
"qqvideo-tv-hotsearch": {
|
||||
"name": "腾讯视频",
|
||||
"type": "hottest",
|
||||
"column": "china",
|
||||
"home": "https://v.qq.com/channel/tv",
|
||||
"color": "blue",
|
||||
"interval": 1800000,
|
||||
"title": "电视剧-热搜榜"
|
||||
},
|
||||
"iqiyi": {
|
||||
"redirect": "iqiyi-hot-ranklist",
|
||||
"name": "爱奇艺",
|
||||
"type": "hottest",
|
||||
"column": "china",
|
||||
"home": "https://www.iqiyi.com",
|
||||
"color": "green",
|
||||
"interval": 1800000,
|
||||
"title": "热播榜"
|
||||
},
|
||||
"iqiyi-hot-ranklist": {
|
||||
"name": "爱奇艺",
|
||||
"type": "hottest",
|
||||
"column": "china",
|
||||
"home": "https://www.iqiyi.com",
|
||||
"color": "green",
|
||||
"interval": 1800000,
|
||||
"title": "热播榜"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user