获取英文名
This commit is contained in:
parent
3adfce7781
commit
ce408dce8b
BIN
db/database.db
BIN
db/database.db
Binary file not shown.
@ -1,12 +1,14 @@
|
||||
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"
|
||||
prefix: "/videoInfo"
|
||||
})
|
||||
|
||||
|
||||
router.get("/search",async (ctx)=>{
|
||||
router.get("/search", async (ctx) => {
|
||||
let name = ctx.query.name
|
||||
ctx.body = await serach(name)
|
||||
})
|
||||
@ -17,15 +19,15 @@ router.get("/search",async (ctx)=>{
|
||||
// ctx.body = info
|
||||
// })
|
||||
|
||||
router.get("/searchVideo",async (ctx)=>{
|
||||
router.get("/searchVideo", async (ctx) => {
|
||||
let name = ctx.query.name
|
||||
ctx.body = await serach(name)
|
||||
|
||||
})
|
||||
|
||||
router.get("/getVideoInfo",async (ctx)=>{
|
||||
router.get("/getVideoInfo", async (ctx) => {
|
||||
let id = ctx.query.id
|
||||
if(!id){
|
||||
if (!id) {
|
||||
ctx.body = "请传递id"
|
||||
return
|
||||
}
|
||||
@ -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
|
@ -1,16 +1,30 @@
|
||||
import { base } from "./base";
|
||||
export async function getVideoInfo(id){
|
||||
return await base.get("/videoInfo/getVideoInfo",{
|
||||
params:{
|
||||
import {base} from "./base";
|
||||
|
||||
export async function getVideoInfo(id) {
|
||||
return await base.get("/videoInfo/getVideoInfo", {
|
||||
params: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function searchVideo(name){
|
||||
return await base.get("/videoInfo/searchVideo",{
|
||||
params:{
|
||||
export async function searchVideo(name) {
|
||||
return await base.get("/videoInfo/searchVideo", {
|
||||
params: {
|
||||
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})
|
||||
}
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user