diff --git a/src/App.vue b/src/App.vue
index 29c7d26..34d74c7 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -27,7 +27,7 @@
-
+
@@ -36,18 +36,35 @@
-
diff --git a/src/lib/util.zy.ts b/src/lib/util.zy.ts
index d7adb1b..e497271 100644
--- a/src/lib/util.zy.ts
+++ b/src/lib/util.zy.ts
@@ -1,33 +1,171 @@
import fly from 'flyio'
import sites from './sites'
+import { TimeSelect } from 'element-ui'
interface ZY {
num: number
page: number
key: string
- site: object
+ site: any
list: Array
getInfoRequire: any
getInfoHtml: any
info: any
- getDetailUrls: any
detail: any
- getFilmsRequire: any
films: any
}
-const zy:ZY = {
+
+interface info {
+ name?: string
+ type?: string
+ time?: string
+ detail?: string
+ urls?: Array
+ index?: number
+}
+
+interface detail {
+ box?: any
+ info?: any
+ urls?: Array
+}
+
+const zy: ZY = {
num: 0,
page: 1,
key: '',
site: {},
list: [],
- getInfoRequire () {},
- getInfoHtml () {},
- info () {},
- getDetailUrls () {},
- detail () {},
- getFilmsRequire () {},
- films () {}
+ getInfoRequire () {
+ return new Promise((resolve, reject) => {
+ let key = encodeURI(this.key)
+ const params = `${this.site.url}/index.php?m=vod-search-pg-${this.page}-wd-${key}.html`
+ fly.get(params).then(res => {
+ this.getInfoHtml(res.data).then((data: any) => {
+ resolve(data)
+ })
+ }).catch(err => {
+ reject(err)
+ })
+ })
+ },
+ getInfoHtml (txt: string): any {
+ return new Promise((resolve, reject) => {
+ try {
+ const parser = new DOMParser()
+ const html = parser.parseFromString(txt, 'text/html')
+ const list: any = html.querySelectorAll('.xing_vb li')
+ let d: any = { list: [], total: 0 }
+ for (let i = 1; i < list.length - 1; i++) {
+ let info: info = {
+ name: list[i].childNodes[1].innerText,
+ type: list[i].childNodes[3].innerText,
+ time: list[i].childNodes[5].innerText,
+ detail: this.site.url + list[i].childNodes[1].childNodes[0].getAttribute('href'),
+ index: 0,
+ urls: []
+ }
+ d.list.push(info)
+ }
+ let num: any = (html.querySelectorAll('.nvc dd span')[1]).innerText
+ num = parseInt(num)
+ d.total = num
+ resolve(d)
+ } catch (err) {
+ reject(err)
+ }
+ })
+ },
+ info (n: number = 0, p: number = 1, k: string = '') {
+ return new Promise((resolve, reject) => {
+ this.num = n
+ this.page = p
+ this.key = k
+ this.site = sites[n]
+ this.getInfoRequire().then((res: any) => {
+ resolve(res)
+ }).catch((err: any) => {
+ reject(err)
+ })
+ })
+ },
+ detail (url: string) {
+ return new Promise((resolve, reject) => {
+ if (!url) return
+ fly.get(url).then(res => {
+ const parser = new DOMParser()
+ let html = parser.parseFromString(res.data, 'text/html')
+ let data: detail = {
+ box: '',
+ info: '',
+ urls: []
+ }
+ let vodBox = html.querySelector('.vodBox')
+ if (vodBox) {
+ data.box = vodBox.innerHTML
+ }
+ let vodInfo = {}
+ if (url.indexOf('123ku') !== -1 || url.indexOf('subo988') !== -1) {
+ vodInfo = html.querySelectorAll('.vodplayinfo')[1]
+ } else {
+ vodInfo = html.querySelector('.vodplayinfo')
+ }
+ data.info = (vodInfo).innerText
+ let urls = html.querySelectorAll('.vodplayinfo li')
+ let arr = []
+ for (let i in urls) {
+ let j = (urls[i]).innerText
+ if (j !== undefined && j.indexOf('.m3u8') !== -1) {
+ arr.push((urls[i]).innerText)
+ }
+ }
+ data.urls = arr
+ resolve(data)
+ }).catch(err => {
+ reject(err)
+ })
+ })
+ },
+ films (n: number = 0, p: number = 1, type: number = 0) {
+ return new Promise((resolve, reject) => {
+ this.site = sites[n]
+ let url: string = sites[n].url
+ let params: string = ''
+ if (type === 0) {
+ params = `${url}/?m=vod-index-pg-${p}.html`
+ } else {
+ params = `${url}/?m=vod-type-id-${type}-pg-${p}.html`
+ }
+ fly.get(params).then(res => {
+ const parser = new DOMParser()
+ const html = parser.parseFromString(res.data, 'text/html')
+ const list: any = html.querySelectorAll('.xing_vb li')
+ let d: any = { list: [], total: 0 }
+ for (let i = 1; i < list.length - 1; i++) {
+ let info: info = {
+ name: list[i].childNodes[1].innerText,
+ type: list[i].childNodes[3].innerText,
+ time: list[i].childNodes[5].innerText,
+ detail: this.site.url + list[i].querySelector('a').getAttribute('href'),
+ index: 0,
+ urls: []
+ }
+ d.list.push(info)
+ }
+ let num: any = html.querySelectorAll('.pages')
+ if (num) {
+ let n = num[0].innerText
+ n = n.split('条')[0]
+ n = n.split('共')[1]
+ n = parseInt(n)
+ d.total = n
+ }
+ resolve(d)
+ }).catch(err => {
+ reject(err)
+ })
+ })
+ }
}
export default zy
diff --git a/src/page/film.vue b/src/page/film.vue
index f8b04a2..deb019a 100644
--- a/src/page/film.vue
+++ b/src/page/film.vue
@@ -1,26 +1,26 @@
-
-
+
+
-
+
- 详情
- 收藏
- 播放
+ 详情
+ 收藏
+ 播放
-
+
{
+ this.filmTotal = res.total
+ this.filmData = res.list
+ this.filmPage = p
+ this.loading = false
+ })
+ },
+ tableBtnClick (type: string, e: any) {
+ if (type === 'detail') {
+ this.video = e
+ this.SET_DETAIL(true)
+ }
+ if (type === 'star') {
+ video.find({ detail: e.detail }).then(res => {
+ if (res) {
+ this.$message.warning('已存在')
+ } else {
+ video.add(e).then(res => {
+ this.$message.success('收藏成功')
+ })
+ }
+ })
+ }
+ if (type === 'play') {
+ this.Main = 'Player'
+ this.video = e
+ }
}
},
- created () {}
+ created () {
+ this.getFilmList()
+ }
})