获取英文名

This commit is contained in:
theluyuan 2023-07-11 20:52:30 +08:00
parent 3adfce7781
commit ce408dce8b
4 changed files with 86 additions and 17 deletions

Binary file not shown.

View File

@ -1,5 +1,7 @@
const Router = require("koa-router")
const { serach, gen_douban } = require("../util/ptgen")
const axios = require("axios")
const cheerio = require("cheerio"); // HTML页面解析
const router = new Router({
prefix: "/videoInfo"
@ -33,4 +35,22 @@ router.get("/getVideoInfo",async (ctx)=>{
})
router.post("/addSubscribe", async (ctx) => {
// console.log(ctx.request.body)
let data = ctx.request.body
})
router.get("/getImdbName", async (ctx) => {
let res = await axios.get(ctx.query.url, {
proxy: false,
headers:{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
}
})
// console.log(res.data)
let $ = cheerio.load(res.data)
ctx.body = $("h1").text()
})
module.exports = router

View File

@ -1,4 +1,5 @@
import {base} from "./base";
export async function getVideoInfo(id) {
return await base.get("/videoInfo/getVideoInfo", {
params: {
@ -14,3 +15,16 @@ export async function searchVideo(name){
}
})
}
export async function getImdbName(url) {
return await base.get("/videoInfo/getImdbName", {
params: {
url
}
})
}
export async function addSubscribe({name, desc, year, season, ep, url}) {
return await base.post("/videoInfo/addSubscribe", {name, desc, year, season, ep, url})
}

View File

@ -17,11 +17,26 @@
</div>
<el-dialog v-model="dialogFormVisible" title="详情">
<textarea style="width: 95%;height: 400px;" v-model="info"></textarea>
<div style="display: flex;align-items: center;padding: 5px">
英文名:
<el-input style="width: 300px" v-model="enName"></el-input>
年份
<el-input style="width: 100px" v-model="year"></el-input>
第几季
<el-input style="width: 100px" v-model="season"></el-input>
开始集数
<el-input style="width: 100px" v-model="ep"></el-input>
</div>
<div style="display: flex;align-items: center;padding: 5px">
地址:
<el-input style="width: 80%" v-model="url"></el-input>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogFormVisible = false">Cancel</el-button>
<el-button type="primary" @click="dialogFormVisible = false">
Confirm
<el-button @click="dialogFormVisible = false">关闭</el-button>
<el-button type="primary" @click="addsubscribe">
订阅
</el-button>
</span>
</template>
@ -31,14 +46,17 @@
<script setup>
import {ref} from 'vue';
import {getVideoInfo, searchVideo} from '../../api/Video.js'
import {addSubscribe, getImdbName, getVideoInfo, searchVideo} from '../../api/Video.js'
import {onBeforeRouteUpdate, useRoute} from "vue-router";
import {ElLoading} from "element-plus";
let list = ref([])
const info = ref("")
const route = useRoute()
const year = ref("")
const ep = ref(1)
const season = ref(1)
const url = ref("")
async function onSubmit(name) {
let res = await searchVideo(name)
list.value = res.data.data
@ -60,10 +78,27 @@ async function getInfo(id) {
vid = id
let res = await getVideoInfo(id)
info.value = res.data.format
year.value = res.data.year
await subscribe(res.data.imdb_link)
dialogFormVisible.value = true
loadingInstance.close()
}
const enName = ref("")
async function subscribe(url){
const res = await getImdbName(url)
enName.value = res.data
}
async function addsubscribe() {
addSubscribe({
name: enName.value,
desc: info.value,
year:year.value,
season:season.value,
ep:ep.value,
url:url.value
})
}
</script>