mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-11-26 22:22:10 +08:00
🎉✨ 新版本内测 🎊🎏
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
const os = require('os')
|
||||
const macaddress = require('macaddress')
|
||||
const AV = require('leancloud-storage')
|
||||
|
||||
macaddress.one((err, mac) => {
|
||||
if (err) {
|
||||
return false
|
||||
}
|
||||
AV.init({
|
||||
appId: 'X6TRIcMjgOG7EJ0t1l5r9In1-gzGzoHsz',
|
||||
appKey: 'JmkGF9UqkWGQNYDcJ2g1QV1b',
|
||||
serverURL: 'https://x6tricmj.lc-cn-n1-shared.com'
|
||||
})
|
||||
const system = os.hostname() + ' ' + os.type() + ' ' + os.arch()
|
||||
const query = new AV.Query('ZYPlayer')
|
||||
query.equalTo('os', system)
|
||||
query.equalTo('mac', mac)
|
||||
query.find().then(res => {
|
||||
// 存储新用户数据
|
||||
if (res.length === 0) {
|
||||
const ZYPlayer = AV.Object.extend('ZYPlayer')
|
||||
const zyPlayer = new ZYPlayer()
|
||||
zyPlayer.set('os', system)
|
||||
zyPlayer.set('mac', mac)
|
||||
zyPlayer.set('times', 1)
|
||||
zyPlayer.save()
|
||||
return false
|
||||
}
|
||||
// 统计启动次数
|
||||
if (res.length === 1) {
|
||||
const id = res[0].id
|
||||
const times = AV.Object.createWithoutData('ZYPlayer', id)
|
||||
times.increment('times', 1)
|
||||
times.save()
|
||||
return false
|
||||
}
|
||||
// 清除冗余数据
|
||||
if (res.length > 1) {
|
||||
const arr = res
|
||||
arr.shift()
|
||||
AV.Object.destroyAll(arr)
|
||||
}
|
||||
})
|
||||
})
|
||||
24
src/lib/dexie/dexie.js
Normal file
24
src/lib/dexie/dexie.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import Dexie from 'dexie'
|
||||
import { setting, sites, localKey } from './initData'
|
||||
|
||||
const db = new Dexie('zy')
|
||||
|
||||
db.version(3).stores({
|
||||
search: '++id, keywords',
|
||||
setting: 'id, theme, site, shortcut, view',
|
||||
shortcut: 'name, key, desc',
|
||||
star: '++id, site, ids, name, type, year, index',
|
||||
sites: '++id, key, name, json, xml, down, level',
|
||||
history: '++id, site, ids, name, type, year, index, time',
|
||||
mini: 'id, site, ids, name, index, time'
|
||||
})
|
||||
|
||||
db.on('populate', () => {
|
||||
db.setting.bulkAdd(setting)
|
||||
db.sites.bulkAdd(sites)
|
||||
db.shortcut.bulkAdd(localKey)
|
||||
})
|
||||
|
||||
db.open()
|
||||
|
||||
export default db
|
||||
@@ -1,4 +1,4 @@
|
||||
import db from './index'
|
||||
import db from './dexie'
|
||||
const { history } = db
|
||||
export default {
|
||||
async add (doc) {
|
||||
|
||||
@@ -1,33 +1,17 @@
|
||||
import Dexie from 'dexie'
|
||||
import history from './history'
|
||||
import mini from './mini'
|
||||
import setting from './setting'
|
||||
import shortcut from './shortcut'
|
||||
import star from './star'
|
||||
import sites from './sites'
|
||||
import search from './search'
|
||||
|
||||
const db = new Dexie('zy')
|
||||
|
||||
db.version(1).stores({
|
||||
theme: '++id, theme',
|
||||
site: '++id, site',
|
||||
video: '++id, name, type, time, detail, urls, index'
|
||||
})
|
||||
|
||||
db.version(2).stores({
|
||||
setting: 'id, theme, site, language, cloud, cloudKey',
|
||||
video: '++id, site, name, type, time, detail, index',
|
||||
history: '++id, site, name, type, time, detail, index, currentTime',
|
||||
mini: 'id, site, name, type, time, detail, index, currentTime'
|
||||
})
|
||||
|
||||
const initData = [{
|
||||
id: 0,
|
||||
theme: 'light',
|
||||
site: 'zuidazy',
|
||||
language: 'zhCn',
|
||||
cloud: false,
|
||||
cloudKey: ''
|
||||
}]
|
||||
|
||||
db.on('populate', () => {
|
||||
db.setting.bulkAdd(initData)
|
||||
})
|
||||
|
||||
db.open()
|
||||
|
||||
export default db
|
||||
export {
|
||||
history,
|
||||
mini,
|
||||
setting,
|
||||
shortcut,
|
||||
star,
|
||||
sites,
|
||||
search
|
||||
}
|
||||
|
||||
376
src/lib/dexie/initData.js
Normal file
376
src/lib/dexie/initData.js
Normal file
@@ -0,0 +1,376 @@
|
||||
const setting = [
|
||||
{
|
||||
id: 0,
|
||||
theme: 'light',
|
||||
site: 'zuidazy',
|
||||
shortcut: true,
|
||||
view: 'picture'
|
||||
}
|
||||
]
|
||||
|
||||
const sites = [
|
||||
{
|
||||
id: 1,
|
||||
key: 'okzy',
|
||||
name: 'OK 资源网',
|
||||
api: 'http://cj.okzy.tv/inc/api.php',
|
||||
download: 'http://cj.okzy.tv/inc/apidown.php',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
key: 'zuidazy',
|
||||
name: '最大资源网',
|
||||
api: 'http://www.zdziyuan.com/inc/api.php',
|
||||
download: 'http://www.zdziyuan.com/inc/apidown.php',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
key: 'gaoqingzy',
|
||||
name: '高清资源网',
|
||||
api: 'http://cj.gaoqingzyw.com/inc/api.php',
|
||||
download: 'http://cj.gaoqingzyw.com/inc/apidown.php',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
key: 'doubanzy',
|
||||
name: '豆瓣电影资源',
|
||||
api: 'http://v.1988cj.com/inc/api.php',
|
||||
download: 'http://v.1988cj.com/inc/apidown.php',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
key: '135zy',
|
||||
name: '135 资源网',
|
||||
api: 'http://cj.zycjw1.com/inc/api.php',
|
||||
download: 'http://cj.zycjw1.com/inc/apidown.php',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
key: 'kuyunzy',
|
||||
name: '酷云资源',
|
||||
api: 'http://caiji.kuyun98.com/inc/ldg_api.php',
|
||||
download: 'http://caiji.kuyun98.com/inc/apidown.php',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
key: 'subo988',
|
||||
name: '速播资源站',
|
||||
api: 'https://www.subo988.com/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
key: '209zy',
|
||||
name: '209 资源',
|
||||
api: 'http://cj.1156zy.com/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
key: 'zuixinzy',
|
||||
name: '最新资源',
|
||||
api: 'http://api.zuixinapi.com/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
key: 'kubozy',
|
||||
name: '酷播资源',
|
||||
api: 'http://api.kbzyapi.com/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
key: 'yongjiuzy',
|
||||
name: '永久资源',
|
||||
api: 'http://cj.yongjiuzyw.com/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
key: '123ku',
|
||||
name: '123 资源',
|
||||
api: 'http://cj.123ku2.com:12315/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
key: '88zyw',
|
||||
name: '88 影视资源站',
|
||||
api: 'http://www.88zyw.net/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
key: 'wolongzy',
|
||||
name: '卧龙资源',
|
||||
api: 'http://cj.wlzy.tv/inc/api_mac.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
key: 'mahuazy',
|
||||
name: '麻花资源',
|
||||
api: 'https://www.mhapi123.com/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
key: 'kkzy',
|
||||
name: '快快资源',
|
||||
api: 'https://api.kkzy.tv/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 17,
|
||||
key: '158zy',
|
||||
name: '壹伍捌资源网',
|
||||
api: 'http://cj.158zyz.net:158/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 18,
|
||||
key: 'rrzy',
|
||||
name: '人人资源',
|
||||
api: 'https://www.rrzyw.cc/api.php/provide/vod/from/rrm3u8/at/xml/',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 19,
|
||||
key: 'mokazy',
|
||||
name: '魔卡资源网',
|
||||
api: 'https://cj.heiyap.com/api.php/provide/vod/at/xml/',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 20,
|
||||
key: 'kyzy',
|
||||
name: '快影资源站',
|
||||
api: 'https://www.kyzy.tv/api.php/kyyun/vod/at/xml/',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 21,
|
||||
key: 'khzy',
|
||||
name: '快活资源站',
|
||||
api: 'https://www.khzyapi.com/api.php/provide/vod/at/xml/',
|
||||
download: '',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
key: 'smzy',
|
||||
name: '神马资源网',
|
||||
api: 'http://api.shenmacj.com/api.php/provide/vod/at/xml/',
|
||||
download: '',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 23,
|
||||
key: 'xhgcjym',
|
||||
name: '小黄瓜资源',
|
||||
api: 'http://cj.xhgcjym.com/inc/api.php',
|
||||
download: 'http://cj.xhgcjym.com/inc/apidown.php',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 24,
|
||||
key: 'jiali',
|
||||
name: '佳丽 TV',
|
||||
api: 'https://jialiapi.com/api.php/provide/vod/at/xml/',
|
||||
download: '',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 25,
|
||||
key: 'agzy',
|
||||
name: '环亚资源',
|
||||
api: 'http://wmcj8.com/inc/sapi.php',
|
||||
download: '',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 26,
|
||||
key: 'solezy',
|
||||
name: '搜乐资源网',
|
||||
api: 'https://www.caijizy.vip/api.php/provide/vod/at/xml/',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 27,
|
||||
key: 'lajiaozy',
|
||||
name: '辣椒资源',
|
||||
api: 'http://api.11bat.com/mac10.php',
|
||||
download: '',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 28,
|
||||
key: '9188zy',
|
||||
name: '9188 资源',
|
||||
api: 'http://cj.vod1769.com/zyapimacc.php',
|
||||
download: '',
|
||||
level: 18
|
||||
},
|
||||
{
|
||||
id: 29,
|
||||
key: 'bbkdj',
|
||||
name: '步步高顶尖资源网',
|
||||
api: 'http://api.bbkdj.com/api',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 30,
|
||||
key: '1886zy',
|
||||
name: '1886 资源',
|
||||
api: 'http://cj.1886zy.co/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 31,
|
||||
key: 'mbo',
|
||||
name: '秒播资源',
|
||||
api: 'http://caiji.mb77.vip/inc/api.php',
|
||||
download: '',
|
||||
level: 16
|
||||
},
|
||||
{
|
||||
id: 32,
|
||||
key: 'mgtvzy',
|
||||
name: '芒果 TV 资源网',
|
||||
api: 'https://api.shijiapi.com/api.php/provide/vod/at/xml/',
|
||||
download: '',
|
||||
level: 16
|
||||
}
|
||||
]
|
||||
|
||||
const localKey = [
|
||||
{
|
||||
name: 'playAndPause',
|
||||
desc: '播放或暂停',
|
||||
key: 'space'
|
||||
},
|
||||
{
|
||||
name: 'forward',
|
||||
desc: '快进',
|
||||
key: 'right'
|
||||
},
|
||||
{
|
||||
name: 'back',
|
||||
desc: '快退',
|
||||
key: 'left'
|
||||
},
|
||||
{
|
||||
name: 'volumeUp',
|
||||
desc: '音量调高',
|
||||
key: 'up'
|
||||
},
|
||||
{
|
||||
name: 'volumeDown',
|
||||
desc: '音量调低',
|
||||
key: 'down'
|
||||
},
|
||||
{
|
||||
name: 'mute',
|
||||
desc: '静音',
|
||||
key: 'm'
|
||||
},
|
||||
{
|
||||
name: 'top',
|
||||
desc: '置顶或退出置顶',
|
||||
key: 't'
|
||||
},
|
||||
{
|
||||
name: 'fullscreen',
|
||||
desc: '进入或退出全屏',
|
||||
key: 'f'
|
||||
},
|
||||
{
|
||||
name: 'escape',
|
||||
desc: '退出全屏',
|
||||
key: 'esc'
|
||||
},
|
||||
{
|
||||
name: 'next',
|
||||
desc: '下一集',
|
||||
key: 'alt+right'
|
||||
},
|
||||
{
|
||||
name: 'prev',
|
||||
desc: '上一集',
|
||||
key: 'alt+left'
|
||||
},
|
||||
{
|
||||
name: 'home',
|
||||
desc: '跳到视频开始位置',
|
||||
key: 'home'
|
||||
},
|
||||
{
|
||||
name: 'end',
|
||||
desc: '跳到视频结束位置',
|
||||
key: 'end'
|
||||
},
|
||||
{
|
||||
name: 'opacityUp',
|
||||
desc: '透明度调高',
|
||||
key: 'alt+up'
|
||||
},
|
||||
{
|
||||
name: 'opacityDown',
|
||||
desc: '透明度调低',
|
||||
key: 'alt+down'
|
||||
},
|
||||
{
|
||||
name: 'playbackRateUp',
|
||||
desc: '播放倍速加快',
|
||||
key: 'pageup'
|
||||
},
|
||||
{
|
||||
name: 'playbackRateDown',
|
||||
desc: '播放倍速减慢',
|
||||
key: 'pagedown'
|
||||
},
|
||||
{
|
||||
name: 'mini',
|
||||
desc: '进入或退出mini模式',
|
||||
key: 'alt+m'
|
||||
}
|
||||
]
|
||||
|
||||
const getSite = (key) => {
|
||||
for (const i of sites) {
|
||||
if (key === i.key) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
setting,
|
||||
sites,
|
||||
localKey,
|
||||
getSite
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import db from './index'
|
||||
import db from './dexie'
|
||||
const { mini } = db
|
||||
export default {
|
||||
async add (doc) {
|
||||
|
||||
22
src/lib/dexie/search.js
Normal file
22
src/lib/dexie/search.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import db from './dexie'
|
||||
const { search } = db
|
||||
export default {
|
||||
async add (doc) {
|
||||
return await search.add(doc)
|
||||
},
|
||||
async find (doc) {
|
||||
return await search.get(doc)
|
||||
},
|
||||
async update (id, docs) {
|
||||
return await search.update(id, docs)
|
||||
},
|
||||
async all () {
|
||||
return await search.toArray()
|
||||
},
|
||||
async remove (id) {
|
||||
return await search.delete(id)
|
||||
},
|
||||
async clear () {
|
||||
return await search.clear()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import db from './index'
|
||||
import db from './dexie'
|
||||
const { setting } = db
|
||||
|
||||
export default {
|
||||
async find () {
|
||||
return await setting.get({ id: 0 })
|
||||
|
||||
14
src/lib/dexie/shortcut.js
Normal file
14
src/lib/dexie/shortcut.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import db from './dexie'
|
||||
const { shortcut } = db
|
||||
|
||||
export default {
|
||||
async all () {
|
||||
return await shortcut.toArray()
|
||||
},
|
||||
async clear () {
|
||||
return await shortcut.clear()
|
||||
},
|
||||
async add (doc) {
|
||||
return await shortcut.bulkAdd(doc)
|
||||
}
|
||||
}
|
||||
13
src/lib/dexie/sites.js
Normal file
13
src/lib/dexie/sites.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import db from './dexie'
|
||||
const { sites } = db
|
||||
export default {
|
||||
async all () {
|
||||
return await sites.toArray()
|
||||
},
|
||||
async clear () {
|
||||
return await sites.clear()
|
||||
},
|
||||
async add (doc) {
|
||||
return await sites.bulkAdd(doc)
|
||||
}
|
||||
}
|
||||
19
src/lib/dexie/star.js
Normal file
19
src/lib/dexie/star.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import db from './dexie'
|
||||
const { star } = db
|
||||
export default {
|
||||
async add (doc) {
|
||||
return await star.add(doc)
|
||||
},
|
||||
async find (doc) {
|
||||
return await star.get(doc)
|
||||
},
|
||||
async update (id, docs) {
|
||||
return await star.update(id, docs)
|
||||
},
|
||||
async all () {
|
||||
return await star.toArray()
|
||||
},
|
||||
async remove (id) {
|
||||
return await star.delete(id)
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import db from './index'
|
||||
const { video } = db
|
||||
export default {
|
||||
async add (doc) {
|
||||
return await video.add(doc)
|
||||
},
|
||||
async find (doc) {
|
||||
return await video.get(doc)
|
||||
},
|
||||
async update (id, docs) {
|
||||
return await video.update(id, docs)
|
||||
},
|
||||
async all () {
|
||||
return await video.toArray()
|
||||
},
|
||||
async remove (id) {
|
||||
return await video.delete(id)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,3 @@
|
||||
import Vue from 'vue'
|
||||
import { Message, Pagination } from 'element-ui'
|
||||
|
||||
Vue.use(Pagination)
|
||||
|
||||
Vue.prototype.$m = Message
|
||||
import { Message } from 'element-ui'
|
||||
Vue.prototype.$message = Message
|
||||
|
||||
18
src/lib/site/server.js
Normal file
18
src/lib/site/server.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import express from 'express'
|
||||
import cors from 'cors'
|
||||
const Axios = require('axios')
|
||||
|
||||
const app = express()
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
app.use(express.urlencoded())
|
||||
|
||||
app.post('/api', async (req, res) => {
|
||||
const result = await Axios.get(req.body.url)
|
||||
res.json({
|
||||
code: 1,
|
||||
info: result.data
|
||||
})
|
||||
})
|
||||
|
||||
app.listen(4848)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,477 +1,193 @@
|
||||
import { sites } from '../dexie'
|
||||
import axios from 'axios'
|
||||
import { getSite } from './sites'
|
||||
import parser from 'fast-xml-parser'
|
||||
const zy = {
|
||||
key: 'zuidazy', // sites[n] 视频源
|
||||
id: 0, // 视频类型
|
||||
page: 1, // 第几页
|
||||
keywords: '', // 搜索关键字
|
||||
// 获取浏览列表
|
||||
film_get (key, id = 0, page = 1) {
|
||||
ports: 4848, // 端口号
|
||||
xmlConfig: { // XML 转 JSON 配置
|
||||
trimValues: true,
|
||||
textNodeName: '_t',
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: '_',
|
||||
parseAttributeValue: true
|
||||
},
|
||||
getSite (key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const site = getSite(key)
|
||||
let url = ''
|
||||
if (id === 0) {
|
||||
url = site.new.replace(/{page}/, page)
|
||||
} else {
|
||||
url = site.view.replace(/{id}/, id).replace(/{page}/, page)
|
||||
}
|
||||
const type = site.type
|
||||
axios.get(url).then(async res => {
|
||||
const data = res.data
|
||||
if (type === 0) {
|
||||
const zeroData = await this.film_get_type_zero(data, key)
|
||||
resolve(zeroData)
|
||||
}
|
||||
if (type === 1) {
|
||||
const oneData = await this.film_get_type_one(data, key)
|
||||
resolve(oneData)
|
||||
}
|
||||
if (type === 2) {
|
||||
const twoData = await this.film_get_type_two(data, key)
|
||||
resolve(twoData)
|
||||
}
|
||||
if (type === 3) {
|
||||
const threeData = await this.film_get_type_three(data, key)
|
||||
resolve(threeData)
|
||||
sites.all().then(res => {
|
||||
for (const i of res) {
|
||||
if (key === i.key) {
|
||||
resolve(i)
|
||||
}
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
film_get_type_zero (txt, key) {
|
||||
/**
|
||||
* 获取资源分类 和 所有资源的总数, 分页等信息
|
||||
* @param {*} key 资源网 key
|
||||
* @returns
|
||||
*/
|
||||
class (key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.xing_vb li')
|
||||
const d = { list: [], total: 0, update: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 1; i < list.length - 1; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: list[i].childNodes[1].innerText,
|
||||
type: list[i].childNodes[3].innerText,
|
||||
time: list[i].childNodes[5].innerText,
|
||||
detail: url + list[i].childNodes[1].querySelector('a').getAttribute('href'),
|
||||
index: 0
|
||||
this.getSite(key).then(res => {
|
||||
const site = res
|
||||
axios.post(`http://localhost:${this.ports}/api`, { url: site.api }).then(res => {
|
||||
const data = res.data.info
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const arr = []
|
||||
if (json.rss.class) {
|
||||
for (const i of json.rss.class.ty) {
|
||||
const j = {
|
||||
tid: i._id,
|
||||
name: i._t
|
||||
}
|
||||
arr.push(j)
|
||||
}
|
||||
}
|
||||
d.list.push(info)
|
||||
}
|
||||
d.update = parseInt(html.querySelectorAll('.xing_top_right li strong')[0].innerText)
|
||||
let t = html.querySelector('.pages').innerText
|
||||
t = t.split('条')[0]
|
||||
t = t.split('共')[1]
|
||||
d.total = parseInt(t)
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
const doc = {
|
||||
class: arr,
|
||||
page: json.rss.list._page,
|
||||
pagecount: json.rss.list._pagecount,
|
||||
pagesize: json.rss.list._pagesize,
|
||||
recordcount: json.rss.list._recordcount
|
||||
}
|
||||
resolve(doc)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
film_get_type_one (txt, key) {
|
||||
/**
|
||||
* 获取资源列表
|
||||
* @param {*} key 资源网 key
|
||||
* @param {number} [pg=1] 翻页 page
|
||||
* @param {*} t 分类 type
|
||||
* @returns
|
||||
*/
|
||||
list (key, pg = 1, t) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.videoContent li')
|
||||
const d = { list: [], total: 0, update: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: list[i].querySelector('.videoName').innerText,
|
||||
type: list[i].querySelector('.category').innerText,
|
||||
time: list[i].querySelector('.time').innerText,
|
||||
detail: url + list[i].querySelector('.address').getAttribute('href'),
|
||||
index: 0
|
||||
}
|
||||
d.list.push(info)
|
||||
this.getSite(key).then(res => {
|
||||
const site = res
|
||||
let url = null
|
||||
if (t) {
|
||||
url = `${site.api}?ac=videolist&t=${t}&pg=${pg}`
|
||||
} else {
|
||||
url = `${site.api}?ac=videolist&pg=${pg}`
|
||||
}
|
||||
d.update = parseInt(html.querySelectorAll('.header_list li span')[0].innerText)
|
||||
let t = html.querySelectorAll('.pagination li')
|
||||
t = t[t.length - 2].innerText
|
||||
d.total = parseInt(t) * 50
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
axios.post(`http://localhost:${this.ports}/api`, { url: url }).then(async res => {
|
||||
const data = res.data.info
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const videoList = json.rss.list.video
|
||||
resolve(videoList)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
film_get_type_two (txt, key) {
|
||||
/**
|
||||
* 获取总资源数, 以及页数
|
||||
* @param {*} key 资源网
|
||||
* @param {*} t 分类 type
|
||||
* @returns page object
|
||||
*/
|
||||
page (key, t) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.nr')
|
||||
const d = { list: [], total: 0, update: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: '',
|
||||
type: list[i].querySelector('.btn_span').innerText,
|
||||
time: list[i].querySelector('.hours').innerText,
|
||||
detail: url + list[i].querySelector('.name').getAttribute('href'),
|
||||
index: 0
|
||||
}
|
||||
let name = list[i].querySelector('.name').innerText
|
||||
name = name.replace(/^\s*|\s*$/g, '')
|
||||
info.name = name
|
||||
d.list.push(info)
|
||||
this.getSite(key).then(res => {
|
||||
const site = res
|
||||
let url = ''
|
||||
if (t) {
|
||||
url = `${site.api}?ac=videolist&t=${t}`
|
||||
} else {
|
||||
url = `${site.api}?ac=videolist`
|
||||
}
|
||||
d.update = parseInt(html.querySelector('.kfs em').innerText)
|
||||
d.total = parseInt(html.querySelector('.date span').innerText)
|
||||
let t = html.querySelector('.pag2').innerText
|
||||
t = t.split('条')[0]
|
||||
t = t.split('共')[1]
|
||||
d.total = parseInt(t)
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
axios.post(`http://localhost:${this.ports}/api`, { url: url }).then(async res => {
|
||||
const data = res.data.info
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const pg = {
|
||||
page: json.rss.list._page,
|
||||
pagecount: json.rss.list._pagecount,
|
||||
pagesize: json.rss.list._pagesize,
|
||||
recordcount: json.rss.list._recordcount
|
||||
}
|
||||
resolve(pg)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
film_get_type_three (txt, key) {
|
||||
/**
|
||||
* 搜索资源
|
||||
* @param {*} key 资源网 key
|
||||
* @param {*} wd 搜索关键字
|
||||
* @returns
|
||||
*/
|
||||
search (key, wd) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.xing_vb li')
|
||||
const d = { list: [], total: 0, update: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 1; i < list.length - 1; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: list[i].childNodes[1].innerText,
|
||||
type: list[i].childNodes[2].innerText,
|
||||
time: list[i].childNodes[3].innerText,
|
||||
detail: url + list[i].childNodes[1].querySelector('a').getAttribute('href'),
|
||||
index: 0
|
||||
}
|
||||
d.list.push(info)
|
||||
}
|
||||
d.update = parseInt(html.querySelectorAll('.xing_top_right li strong')[0].innerText)
|
||||
let t = html.querySelector('.pages').innerText
|
||||
t = t.split('条')[0]
|
||||
t = t.split('共')[1]
|
||||
d.total = parseInt(t)
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
this.getSite(key).then(res => {
|
||||
const site = res
|
||||
wd = encodeURI(wd)
|
||||
axios.post(`http://localhost:${this.ports}/api`, { url: site.api + '?wd=' + wd }).then(res => {
|
||||
const data = res.data.info
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const videoList = json.rss.list.video
|
||||
resolve(videoList)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取详情
|
||||
detail_get (key, url) {
|
||||
/**
|
||||
* 获取资源详情
|
||||
* @param {*} key 资源网 key
|
||||
* @param {*} id 资源唯一标识符 id
|
||||
* @returns
|
||||
*/
|
||||
detail (key, id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const type = getSite(key).type
|
||||
axios.get(url).then(async res => {
|
||||
if (type === 0) {
|
||||
const zeroData = await this.detail_get_type_zero(res.data, key)
|
||||
resolve(zeroData)
|
||||
}
|
||||
if (type === 1) {
|
||||
const oneData = await this.detail_get_type_one(res.data, key)
|
||||
resolve(oneData)
|
||||
}
|
||||
if (type === 2) {
|
||||
const twoData = await this.detail_get_type_two(res.data, key)
|
||||
resolve(twoData)
|
||||
}
|
||||
if (type === 3) {
|
||||
const threeData = await this.detail_get_type_three(res.data, key)
|
||||
resolve(threeData)
|
||||
}
|
||||
this.getSite(key).then(res => {
|
||||
axios.post(`http://localhost:${this.ports}/api`, { url: res.api + '?ac=videolist&ids=' + id }).then(res => {
|
||||
const data = res.data.info
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const videoList = json.rss.list.video
|
||||
resolve(videoList)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
detail_get_type_zero (txt, key) {
|
||||
/**
|
||||
* 下载资源
|
||||
* @param {*} key 资源网 key
|
||||
* @param {*} id 资源唯一标识符 id
|
||||
* @returns
|
||||
*/
|
||||
download (key, id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const data = {
|
||||
site: key,
|
||||
name: '',
|
||||
info: '',
|
||||
desc: '',
|
||||
m3u8_urls: [],
|
||||
mp4_urls: []
|
||||
this.getSite(key).then(res => {
|
||||
const site = res
|
||||
const url = site.download
|
||||
if (url) {
|
||||
axios.post(`http://localhost:${this.ports}/api`, { url: url + '?ac=videolist&ids=' + id + '&ct=1' }).then(res => {
|
||||
const data = res.data.info
|
||||
const json = parser.parse(data, this.xmlConfig)
|
||||
const videoList = json.rss.list.video
|
||||
resolve(videoList)
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
} else {
|
||||
resolve(null)
|
||||
}
|
||||
const vodBox = html.querySelector('.vodBox')
|
||||
data.info = vodBox.innerHTML
|
||||
const title = html.querySelector('.vodh h2').innerText
|
||||
const index = html.querySelector('.vodh span').innerText
|
||||
data.name = title + index
|
||||
const vodInfo = html.querySelectorAll('.playBox')
|
||||
for (let i = 0; i < vodInfo.length; i++) {
|
||||
const k = vodInfo[i].innerText
|
||||
if (k.indexOf('剧情介绍') >= 0) {
|
||||
data.desc = vodInfo[i].querySelector('.vodplayinfo').innerText
|
||||
}
|
||||
}
|
||||
const vodLi = html.querySelectorAll('.ibox .vodplayinfo li')
|
||||
const m3u8UrlArr = []
|
||||
const mp4UrlArr = []
|
||||
for (let i = 0; i < vodLi.length; i++) {
|
||||
const j = vodLi[i].innerText
|
||||
if (j.indexOf('.m3u8') >= 0) {
|
||||
m3u8UrlArr.push(j)
|
||||
}
|
||||
if (j.indexOf('.mp4') >= 0) {
|
||||
mp4UrlArr.push(j)
|
||||
}
|
||||
}
|
||||
data.m3u8_urls = m3u8UrlArr
|
||||
data.mp4_urls = mp4UrlArr
|
||||
resolve(data)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
detail_get_type_one (txt, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const data = {
|
||||
site: key,
|
||||
name: '',
|
||||
info: '',
|
||||
desc: '',
|
||||
m3u8_urls: [],
|
||||
mp4_urls: []
|
||||
}
|
||||
let name = html.querySelector('.whitetitle').innerText
|
||||
name = name.split(':')[1].replace(/^\s*|\s*$/g, '')
|
||||
data.name = name
|
||||
const vodBox = html.querySelector('.white').innerHTML
|
||||
data.info = vodBox
|
||||
const vodInfo = html.querySelectorAll('.white')
|
||||
for (let i = 0; i < vodInfo.length; i++) {
|
||||
const k = vodInfo[i].innerText
|
||||
if (k.indexOf('剧情介绍') >= 0) {
|
||||
data.desc = vodInfo[i].querySelector('div').innerText
|
||||
}
|
||||
}
|
||||
const vodLi = html.querySelectorAll('.playlist li #m3u8')
|
||||
const m3u8UrlArr = []
|
||||
const mp4UrlArr = []
|
||||
for (let i = 0; i < vodLi.length; i++) {
|
||||
const j = vodLi[i].value
|
||||
if (j.indexOf('.m3u8') >= 0) {
|
||||
m3u8UrlArr.push(j)
|
||||
}
|
||||
if (j.indexOf('.mp4') >= 0) {
|
||||
mp4UrlArr.push(j)
|
||||
}
|
||||
}
|
||||
data.m3u8_urls = m3u8UrlArr
|
||||
data.mp4_urls = mp4UrlArr
|
||||
resolve(data)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
detail_get_type_two (txt, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const data = {
|
||||
site: key,
|
||||
name: '',
|
||||
info: '',
|
||||
desc: '',
|
||||
m3u8_urls: [],
|
||||
mp4_urls: []
|
||||
}
|
||||
const title = html.querySelector('.vodh h2').innerText
|
||||
const index = html.querySelector('.vodh span').innerText
|
||||
data.name = title + index
|
||||
const vodBox = html.querySelector('.vodBox').innerHTML
|
||||
data.info = vodBox
|
||||
data.desc = html.querySelector('.vodplayinfo').innerText
|
||||
const vodLi = html.querySelectorAll('.vodplayinfo li')
|
||||
const m3u8UrlArr = []
|
||||
const mp4UrlArr = []
|
||||
for (let i = 0; i < vodLi.length; i++) {
|
||||
const j = vodLi[i].innerText
|
||||
if (j.indexOf('.m3u8') >= 0) {
|
||||
m3u8UrlArr.push(j)
|
||||
}
|
||||
if (j.indexOf('.mp4') >= 0) {
|
||||
mp4UrlArr.push(j)
|
||||
}
|
||||
}
|
||||
data.m3u8_urls = m3u8UrlArr
|
||||
data.mp4_urls = mp4UrlArr
|
||||
resolve(data)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
detail_get_type_three (txt, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const data = {
|
||||
site: key,
|
||||
name: '',
|
||||
info: '',
|
||||
desc: '',
|
||||
m3u8_urls: [],
|
||||
mp4_urls: []
|
||||
}
|
||||
const vodBox = html.querySelector('.vodBox')
|
||||
data.info = vodBox.innerHTML
|
||||
const title = html.querySelector('.vodh h2').innerText
|
||||
const index = html.querySelector('.vodh span').innerText
|
||||
data.name = title + index
|
||||
const vodInfo = html.querySelectorAll('.playBox')
|
||||
for (let i = 0; i < vodInfo.length; i++) {
|
||||
const k = vodInfo[i].innerText
|
||||
if (k.indexOf('剧情介绍') >= 0) {
|
||||
data.desc = vodInfo[i].querySelector('.vodplayinfo').innerHTML
|
||||
}
|
||||
}
|
||||
const vodLi = html.querySelectorAll('.ibox .vodplayinfo li')
|
||||
const m3u8UrlArr = []
|
||||
const mp4UrlArr = []
|
||||
for (let i = 0; i < vodLi.length; i++) {
|
||||
const j = vodLi[i].innerText
|
||||
if (j.indexOf('.m3u8') >= 0) {
|
||||
m3u8UrlArr.unshift(j)
|
||||
}
|
||||
if (j.indexOf('.mp4') >= 0) {
|
||||
mp4UrlArr.unshift(j)
|
||||
}
|
||||
}
|
||||
data.m3u8_urls = m3u8UrlArr
|
||||
data.mp4_urls = mp4UrlArr
|
||||
resolve(data)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 搜索列表
|
||||
search_get (key, keywords = '', page = 1) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const site = getSite(key)
|
||||
const type = site.type
|
||||
let url = null
|
||||
if (type === 0) {
|
||||
url = site.search.replace(/{page}/, page).replace(/{keywords}/, keywords)
|
||||
}
|
||||
if (type === 1) {
|
||||
url = site.search.replace(/{keywords}/, keywords)
|
||||
}
|
||||
axios.get(url).then(async res => {
|
||||
const data = res.data
|
||||
if (type === 0) {
|
||||
const zeroData = await this.search_get_type_zero(data, key)
|
||||
resolve(zeroData)
|
||||
}
|
||||
if (type === 1) {
|
||||
const oneData = await this.search_get_type_one(data, key)
|
||||
resolve(oneData)
|
||||
}
|
||||
if (type === 3) {
|
||||
const threeData = await this.search_get_type_three(data, key)
|
||||
resolve(threeData)
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
search_get_type_zero (txt, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.xing_vb li')
|
||||
const d = { list: [], total: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 1; i < list.length - 1; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: list[i].childNodes[1].innerText,
|
||||
type: list[i].childNodes[3].innerText,
|
||||
time: list[i].childNodes[5].innerText,
|
||||
detail: url + list[i].childNodes[1].querySelector('a').getAttribute('href'),
|
||||
index: 0
|
||||
}
|
||||
d.list.push(info)
|
||||
}
|
||||
const t = html.querySelector('.nvc dd').innerText.replace(/[^\d]/g, '')
|
||||
d.total = parseInt(t)
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
search_get_type_one (txt, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.videoContent li')
|
||||
const d = { list: [], total: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: list[i].querySelector('.videoName').innerText,
|
||||
type: list[i].querySelector('.category').innerText,
|
||||
time: list[i].querySelector('.time').innerText,
|
||||
detail: url + list[i].querySelector('.address').getAttribute('href'),
|
||||
index: 0
|
||||
}
|
||||
d.list.push(info)
|
||||
}
|
||||
d.total = list.length
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
search_get_type_three (txt, key) {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.xing_vb li')
|
||||
const d = { list: [], total: 0 }
|
||||
const url = getSite(key).url
|
||||
for (let i = 1; i < list.length - 1; i++) {
|
||||
const info = {
|
||||
site: key,
|
||||
name: list[i].childNodes[1].innerText,
|
||||
type: list[i].childNodes[2].innerText,
|
||||
time: list[i].childNodes[3].innerText,
|
||||
detail: url + list[i].childNodes[1].querySelector('a').getAttribute('href'),
|
||||
index: 0
|
||||
}
|
||||
d.list.push(info)
|
||||
}
|
||||
const t = html.querySelector('.nvc dd').innerText.replace(/[^\d]/g, '')
|
||||
d.total = parseInt(t)
|
||||
resolve(d)
|
||||
} catch (err) {
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user