获取英文名
This commit is contained in:
		
							parent
							
								
									3adfce7781
								
							
						
					
					
						commit
						ce408dce8b
					
				
							
								
								
									
										
											BIN
										
									
								
								db/database.db
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db/database.db
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							@ -1,5 +1,7 @@
 | 
				
			|||||||
const Router = require("koa-router")
 | 
					const Router = require("koa-router")
 | 
				
			||||||
const { serach, gen_douban } = require("../util/ptgen")
 | 
					const { serach, gen_douban } = require("../util/ptgen")
 | 
				
			||||||
 | 
					const axios = require("axios")
 | 
				
			||||||
 | 
					const cheerio = require("cheerio"); // HTML页面解析
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const router = new Router({
 | 
					const router = new Router({
 | 
				
			||||||
    prefix: "/videoInfo"
 | 
					    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
 | 
					module.exports = router
 | 
				
			||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
import {base} from "./base";
 | 
					import {base} from "./base";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function getVideoInfo(id) {
 | 
					export async function getVideoInfo(id) {
 | 
				
			||||||
    return await base.get("/videoInfo/getVideoInfo", {
 | 
					    return await base.get("/videoInfo/getVideoInfo", {
 | 
				
			||||||
        params: {
 | 
					        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})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -17,11 +17,26 @@
 | 
				
			|||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
    <el-dialog v-model="dialogFormVisible" title="详情">
 | 
					    <el-dialog v-model="dialogFormVisible" title="详情">
 | 
				
			||||||
      <textarea style="width: 95%;height: 400px;" v-model="info"></textarea>
 | 
					      <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>
 | 
					      <template #footer>
 | 
				
			||||||
                <span class="dialog-footer">
 | 
					                <span class="dialog-footer">
 | 
				
			||||||
                    <el-button @click="dialogFormVisible = false">Cancel</el-button>
 | 
					                    <el-button @click="dialogFormVisible = false">关闭</el-button>
 | 
				
			||||||
                    <el-button type="primary" @click="dialogFormVisible = false">
 | 
					                    <el-button type="primary" @click="addsubscribe">
 | 
				
			||||||
                        Confirm
 | 
					                        订阅
 | 
				
			||||||
                    </el-button>
 | 
					                    </el-button>
 | 
				
			||||||
                </span>
 | 
					                </span>
 | 
				
			||||||
      </template>
 | 
					      </template>
 | 
				
			||||||
@ -31,14 +46,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<script setup>
 | 
					<script setup>
 | 
				
			||||||
import {ref} from 'vue';
 | 
					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 {onBeforeRouteUpdate, useRoute} from "vue-router";
 | 
				
			||||||
import {ElLoading} from "element-plus";
 | 
					import {ElLoading} from "element-plus";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
let list = ref([])
 | 
					let list = ref([])
 | 
				
			||||||
const info = ref("")
 | 
					const info = ref("")
 | 
				
			||||||
const route = useRoute()
 | 
					const route = useRoute()
 | 
				
			||||||
 | 
					const year = ref("")
 | 
				
			||||||
 | 
					const ep = ref(1)
 | 
				
			||||||
 | 
					const season = ref(1)
 | 
				
			||||||
 | 
					const url = ref("")
 | 
				
			||||||
async function onSubmit(name) {
 | 
					async function onSubmit(name) {
 | 
				
			||||||
  let res = await searchVideo(name)
 | 
					  let res = await searchVideo(name)
 | 
				
			||||||
  list.value = res.data.data
 | 
					  list.value = res.data.data
 | 
				
			||||||
@ -60,10 +78,27 @@ async function getInfo(id) {
 | 
				
			|||||||
  vid = id
 | 
					  vid = id
 | 
				
			||||||
  let res = await getVideoInfo(id)
 | 
					  let res = await getVideoInfo(id)
 | 
				
			||||||
  info.value = res.data.format
 | 
					  info.value = res.data.format
 | 
				
			||||||
 | 
					  year.value = res.data.year
 | 
				
			||||||
 | 
					  await subscribe(res.data.imdb_link)
 | 
				
			||||||
  dialogFormVisible.value = true
 | 
					  dialogFormVisible.value = true
 | 
				
			||||||
  loadingInstance.close()
 | 
					  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>
 | 
					</script>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user