Merge branch 'master' of https://github.com/Hunlongyu/ZY-Player into master

This commit is contained in:
Hunlongyu
2020-10-30 09:30:59 +08:00
18 changed files with 4374 additions and 113 deletions

View File

@@ -35,6 +35,7 @@
"mousetrap": "^1.6.5",
"qrcode.vue": "^1.7.0",
"randomstring": "^1.1.5",
"request": "^2.88.2",
"v-fit-columns": "^0.2.0",
"vue": "^2.6.12",
"vue-infinite-loading": "^2.4.5",

View File

@@ -10,6 +10,7 @@
<History v-show="view === 'History'" />
<Setting v-show="view === 'Setting'" />
<EditSites v-if="view === 'EditSites'"/>
<Recommandation v-show="view === 'Recommandation'" />
</div>
<transition name="slide">
<Detail v-if="detail.show"/>
@@ -43,6 +44,9 @@ export default {
},
editSites () {
return this.$store.getters.getEditSites
},
recommandation () {
return this.$store.getters.recommandation
}
},
watch: {

View File

@@ -170,7 +170,7 @@
}
}
}
.film{
.pictureView{
.body{
background-color: var(--d-bgc-1);
box-shadow: var(--d-bsc);
@@ -286,10 +286,6 @@
}
}
}
.star{
background-color: var(--d-bgc-1);
box-shadow: var(--d-bsc);
}
.setting{
background-color: var(--d-bgc-1);
box-shadow: var(--d-bsc);

View File

@@ -166,7 +166,7 @@
}
}
}
.film{
.pictureView{
.body{
background-color: var(--g-bgc-1);
box-shadow: var(--g-bsc);
@@ -282,10 +282,6 @@
}
}
}
.star{
background-color: var(--g-bgc-1);
box-shadow: var(--g-bsc);
}
.setting{
background-color: var(--g-bgc-1);
box-shadow: var(--g-bsc);

View File

@@ -166,7 +166,7 @@
}
}
}
.film{
.pictureView{
.body{
background-color: var(--l-bgc-1);
box-shadow: var(--l-bsc);
@@ -282,10 +282,6 @@
}
}
}
.star{
background-color: var(--l-bgc-1);
box-shadow: var(--l-bsc);
}
.setting{
background-color: var(--l-bgc-1);
box-shadow: var(--l-bsc);

View File

@@ -165,7 +165,7 @@
}
}
}
.film{
.pictureView{
.body{
background-color: var(--p-bgc-1);
box-shadow: var(--p-bsc);
@@ -281,10 +281,6 @@
}
}
}
.star{
background-color: var(--p-bgc-1);
box-shadow: var(--p-bsc);
}
.setting{
background-color: var(--p-bgc-1);
box-shadow: var(--p-bsc);

View File

@@ -21,6 +21,13 @@
<polyline stroke-linejoin="round" points="8 4 12 7.917 16 4"></polyline>
</svg>
</span>
<span :class="[view === 'Recommandation' ? 'active ': ''] + 'zy-svg'" @click="changeView('Recommandation')">
<svg role="img" xmlns="http://www.w3.org/2000/svg" width="48px" height="48px" viewBox="0 0 24 24" aria-labelledby="thumbUpIconTitle" stroke="#2329D6" stroke-width="1" stroke-linecap="square" stroke-linejoin="miter" fill="none" color="#2329D6">
<title id="thumbUpIconTitle">影视推荐</title>
<path d="M8,8.73984815 C8,8.26242561 8.17078432,7.80075162 8.4814868,7.43826541 L13.2723931,1.84887469 C13.7000127,1.34998522 14.4122932,1.20614658 15,1.5 C15.5737957,1.78689785 15.849314,2.45205792 15.6464466,3.06066017 L14,8 L18.6035746,8 C18.7235578,8 18.8432976,8.01079693 18.9613454,8.03226018 C20.0480981,8.22985158 20.7689058,9.27101818 20.5713144,10.3577709 L19.2985871,17.3577709 C19.1256814,18.3087523 18.2974196,19 17.3308473,19 L10,19 C8.8954305,19 8,18.1045695 8,17 L8,8.73984815 Z"/>
<path d="M4,18 L4,9"/>
</svg>
</span>
<span :class="[view === 'Play' ? 'active ': ''] + 'zy-svg'" @click="changeView('Play')">
<svg role="img" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" aria-labelledby="playIconTitle">
<title id="playIconTitle">播放</title>

View File

@@ -173,18 +173,19 @@ export default {
},
async starEvent () {
const db = await star.find({ key: this.detail.key, ids: this.info.id })
const doc = {
key: this.detail.key,
ids: this.info.id,
site: this.detail.site,
name: this.info.name,
detail: this.info,
rate: this.info.rate
}
if (db) {
this.$message.info('该影片已被收藏')
star.update(db.id, doc)
this.$message.success('收藏更新成功')
} else {
const docs = {
key: this.detail.key,
ids: this.info.id,
site: this.detail.site,
name: this.info.name,
detail: this.info,
rate: this.info.rate
}
star.add(docs).then(res => {
star.add(doc).then(res => {
this.$message.success('收藏成功')
})
}

View File

@@ -1,5 +1,5 @@
<template>
<div class="film">
<div class="film pictureView">
<div class="header">
<div class="zy-select" @mouseleave="show.site = false">
<div class="vs-placeholder" @click="show.site = true">{{site.name}}</div>

View File

@@ -0,0 +1,373 @@
<template>
<div class="listpage recommandataions pictureView">
<div class="listpage-content">
<div class="listpage-header">
<el-switch v-model="viewMode" active-text="海报" active-value="picture" inactive-text="列表" inactive-value="list" @change="updateViewMode"></el-switch>
<el-button @click.stop="updateEvent" icon="el-icon-refresh">更新推荐</el-button>
</div>
<div class="listpage-body" id="recommandataions-table" v-show="viewMode === 'list'">
<el-table size="mini" fit height="100%" row-key="id"
ref="recommandataionsTable"
:data="recommandations"
@row-click="detailEvent">
<el-table-column
prop="name"
label="片名">
</el-table-column>
<el-table-column
:sort-by="['detail.type', 'name']"
sortable
:sort-method="sortByType"
prop="detail.type"
label="类型"
width="100">
</el-table-column>
<el-table-column
sortable
:sort-by="['detail.year', 'name']"
prop="detail.year"
label="上映"
width="100"
align="center">
</el-table-column>
<el-table-column v-if="recommandations.some(e => e.detail.note)"
prop="detail.note"
width="120"
label="备注">
</el-table-column>
<el-table-column v-if="recommandations.some(e => e.rate)"
prop="rate"
width="120"
label="豆瓣评分">
</el-table-column>
<el-table-column
label="操作"
header-align="right"
align="right">
<template slot-scope="scope">
<el-button @click.stop="playEvent(scope.row)" type="text">播放</el-button>
<el-button @click.stop="shareEvent(scope.row)" type="text">分享</el-button>
<el-button @click.stop="downloadEvent(scope.row)" type="text">下载</el-button>
<el-button @click.stop="deleteEvent(scope.row)" type="text">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="body zy-scroll" id="star-picture" v-show="viewMode === 'picture'">
<div class="show-img">
<Waterfall ref="waterfall" :list="recommandations" :gutter="20" :width="240"
:breakpoints="{ 1200: { rowPerView: 4 } }"
animationEffect="fadeInUp"
backgroundColor="rgba(0, 0, 0, 0)">
<template slot="item" slot-scope="props">
<div class="card">
<div class="img">
<div class="rate">
<span v-if="props.data.rate && props.data.rate !== '暂无评分'">豆瓣评分: {{props.data.rate}}</span>
</div>
<img style="width: 100%" :src="props.data.detail.pic" alt="" @load="$refs.waterfall.refresh()" @click="detailEvent(props.data)">
<div class="operate">
<div class="operate-wrap">
<span class="o-play" @click="playEvent(props.data)">播放</span>
<span class="o-share" @click="shareEvent(props.data)">分享</span>
<span class="o-star" @click="downloadEvent(props.data)">下载</span>
<span class="o-star" @click="deleteEvent(props.data)">删除</span>
</div>
</div>
</div>
<div class="name" @click="detailEvent(props.data)">{{props.data.name}}</div>
<div class="info">
<span>{{props.data.detail.year}}</span>
<span>{{props.data.detail.note}}</span>
<span>{{props.data.detail.type}}</span>
</div>
</div>
</template>
</Waterfall>
</div>
</div>
</div>
</div>
</template>
<script>
import { mapMutations } from 'vuex'
import { history, recommandation, setting } from '../lib/dexie'
import zy from '../lib/site/tools'
import Waterfall from 'vue-waterfall-plugin'
// import { recommandations as buildInRecommandations } from '../lib/dexie/initData'
const { clipboard } = require('electron')
export default {
name: 'recommandations',
data () {
return {
recommandations: [],
sites: [],
viewMode: 'picture'
}
},
components: {
Waterfall
},
computed: {
view: {
get () {
return this.$store.getters.getView
},
set (val) {
this.SET_VIEW(val)
}
},
video: {
get () {
return this.$store.getters.getVideo
},
set (val) {
this.SET_VIDEO(val)
}
},
detail: {
get () {
return this.$store.getters.getDetail
},
set (val) {
this.SET_DETAIL(val)
}
},
share: {
get () {
return this.$store.getters.getShare
},
set (val) {
this.SET_SHARE(val)
}
}
},
watch: {
view () {
this.getRecommandations()
}
},
methods: {
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
sortByType (a, b) {
return a.detail.type.localeCompare(b.detail.type)
},
detailEvent (e) {
this.detail = {
show: true,
key: e.key,
info: {
id: e.ids,
name: e.name
}
}
},
updateEvent () {
const url = 'https://raw.githubusercontent.com/Hunlongyu/ZY-Player/master/src/lib/dexie/iniData/Recommandations.json'
const request = require('request')
const options = { json: true }
request(url, options, (error, res, body) => {
if (!error && res.statusCode === 200) {
// do something with JSON, using the 'body' variable
if (body.length > 0) {
this.recommandations = body
this.recommandations.sort(function (a, b) {
return b.detail.year - a.detail.year
})
recommandation.clear().then(recommandation.bulkAdd(this.recommandations))
this.$message.success('更新推荐成功')
}
}
})
},
async playEvent (e) {
const db = await history.find({ site: e.key, ids: e.ids })
if (db) {
this.video = { key: e.key, info: { id: db.ids, name: db.name, index: db.index } }
} else {
this.video = { key: e.key, info: { id: e.ids, name: e.name, index: 0 } }
}
this.view = 'Play'
},
deleteEvent (e) {
recommandation.remove(e.id).then(res => {
if (res) {
this.$message.warning('删除失败')
} else {
this.$message.success('删除成功')
}
this.getRecommandations()
})
},
shareEvent (e) {
this.share = {
show: true,
key: e.key,
info: e
}
},
downloadEvent (e) {
zy.download(e.key, e.ids).then(res => {
if (res && res.dl && res.dl.dd) {
const text = res.dl.dd._t
if (text) {
const list = text.split('#')
let downloadUrl = ''
for (const i of list) {
const url = encodeURI(i.split('$')[1])
downloadUrl += (url + '\n')
}
clipboard.writeText(downloadUrl)
this.$message.success('『MP4』格式的链接已复制, 快去下载吧!')
} else {
this.$message.warning('没有查询到下载链接.')
}
} else {
var m3u8List = {}
zy.detail(e.key, e.ids).then(res => {
const dd = res.dl.dd
const type = Object.prototype.toString.call(dd)
if (type === '[object Array]') {
for (const i of dd) {
if (i._flag.indexOf('m3u8') >= 0) {
m3u8List = i._t.split('#')
}
}
} else {
m3u8List = dd._t.split('#')
}
const list = [...m3u8List]
let downloadUrl = ''
for (const i of list) {
const url = encodeURI(i.split('$')[1])
downloadUrl += (url + '\n')
}
clipboard.writeText(downloadUrl)
this.$message.success('『M3U8』格式的链接已复制, 快去下载吧!')
})
}
})
},
getRecommandations () {
recommandation.all().then(res => {
this.recommandations = res
this.recommandations.sort(function (a, b) {
return b.detail.year - a.detail.year
})
})
},
getViewMode () {
setting.find().then(res => {
this.viewMode = res.recommandationViewMode
})
},
updateViewMode () {
setting.find().then(res => {
res.recommandationViewMode = this.viewMode
setting.update(res)
})
}
},
created () {
this.getRecommandations()
this.getViewMode()
}
}
</script>
<style lang="scss" scoped>
.recommandataions{
.body{
height: calc(100% - 40px);
display: flex;
position: relative;
overflow-y: auto;
&::-webkit-scrollbar{
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 10px;
position: absolute;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
position: absolute;
}
.body-box{
height: 100%;
width: 100%;
}
.show-img{
height: 100%;
width: 100%;
padding: 10px;
.card{
border-radius: 6px;
overflow: hidden;
.img{
position: relative;
min-height: 40px;
img{
width: 100%;
height: auto;
cursor: pointer;
}
.rate{
right: 0;
top: 0;
position: absolute;
width: 100%;
font-size: 1rem;
background-color: #111111aa;
color: #cdcdcd;
}
.operate{
display: none;
position: absolute;
left: 0;
bottom: 0;
background-color: #111111aa;
width: 100%;
font-size: 13px;
.operate-wrap{
display: flex;
justify-content: space-between;
.o-play, .o-star, .o-share{
cursor: pointer;
display: inline-block;
width: 80px;
height: 36px;
text-align: center;
line-height: 36px;
color: #cdcdcd;
&:hover{
background-color: #111;
}
}
}
}
}
.name{
font-size: 16px;
padding: 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.info{
display: flex;
justify-content: space-between;
font-size: 12px;
padding: 10px;
}
&:hover{
.operate{
display: block;
}
}
}
}
}
}
</style>

View File

@@ -210,17 +210,7 @@ export default {
},
getSetting () {
setting.find().then(res => {
this.d = {
id: res.id,
theme: res.theme,
shortcut: res.shortcut,
view: res.view,
externalPlayer: res.externalPlayer,
searchAllSites: res.searchAllSites,
excludeRootClasses: res.excludeRootClasses,
excludeR18Films: res.excludeR18Films,
forwardTimeInSec: res.forwardTimeInSec
}
this.d = res
this.setting = this.d
})
},

View File

@@ -1,8 +1,8 @@
<template>
<div class="listpage" id="star">
<div class="listpage star pictureView">
<div class="listpage-content">
<div class="listpage-header">
<el-switch v-model="viewMode" active-text="海报" active-value="picture" inactive-text="列表" inactive-value="list"></el-switch>
<el-switch v-model="viewMode" active-text="海报" active-value="picture" inactive-text="列表" inactive-value="list" @change="updateViewMode"></el-switch>
<el-button @click.stop="exportFavoritesEvent" icon="el-icon-upload2">导出</el-button>
<el-button @click.stop="importFavoritesEvent" icon="el-icon-download">导入</el-button>
<el-button @click.stop="clearFavoritesEvent" icon="el-icon-delete-solid">清空</el-button>
@@ -76,8 +76,8 @@
</el-table-column>
</el-table>
</div>
<div class="star zy-scroll" id="star-picture" v-show="viewMode === 'picture'">
<div class="star-box">
<div class="body zy-scroll" id="star-picture" v-show="viewMode === 'picture'">
<div class="show-img">
<Waterfall ref="waterfall" :list="list" :gutter="20" :width="240"
:breakpoints="{ 1200: { rowPerView: 4 } }"
animationEffect="fadeInUp"
@@ -85,7 +85,10 @@
<template slot="item" slot-scope="props">
<div class="card">
<div class="img">
<img style="width: 100%" :src="props.data.detail.pic" alt="" @load="$refs.waterfall.refresh()" @click="detailEvent(site, props.data)">
<div class="rate">
<span v-if="props.data.rate && props.data.rate !== '暂无评分'">豆瓣评分: {{props.data.rate}}</span>
</div>
<img style="width: 100%" :src="props.data.detail.pic" alt="" @load="$refs.waterfall.refresh()" @click="detailEvent(props.data)">
<div class="operate">
<div class="operate-wrap">
<span class="o-play" @click="playEvent(props.data)">播放</span>
@@ -111,7 +114,7 @@
</template>
<script>
import { mapMutations } from 'vuex'
import { star, history, sites } from '../lib/dexie'
import { star, history, sites, setting } from '../lib/dexie'
import zy from '../lib/site/tools'
import { remote } from 'electron'
import fs from 'fs'
@@ -439,6 +442,17 @@ export default {
_this.updateDatabase()
}
})
},
getViewMode () {
setting.find().then(res => {
this.viewMode = res.starViewMode
})
},
updateViewMode () {
setting.find().then(res => {
res.starViewMode = this.viewMode
setting.update(res)
})
}
},
mounted () {
@@ -446,74 +460,101 @@ export default {
},
created () {
this.getFavorites()
this.getViewMode()
}
}
</script>
<style lang="scss" scoped>
.star{
height: calc(100% - 40px);
display: flex;
position: relative;
overflow-y: auto;
.star-box{
position: absolute;
width: 100%;
height: 100%;
padding: 10px;
.card{
border-radius: 6px;
overflow: hidden;
.img{
position: relative;
min-height: 40px;
img{
width: 100%;
height: auto;
cursor: pointer;
}
.operate{
display: none;
position: absolute;
left: 0;
bottom: 0;
background-color: #111111aa;
width: 100%;
font-size: 13px;
.operate-wrap{
display: flex;
justify-content: space-between;
.o-play, .o-star, .o-share{
cursor: pointer;
display: inline-block;
width: 80px;
height: 36px;
text-align: center;
line-height: 36px;
color: #cdcdcd;
&:hover{
background-color: #111;
.body{
height: calc(100% - 40px);
display: flex;
position: relative;
overflow-y: auto;
&::-webkit-scrollbar{
width: 5px;
height: 1px;
}
&::-webkit-scrollbar-thumb {
border-radius: 10px;
position: absolute;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
position: absolute;
}
.body-box{
height: 100%;
width: 100%;
}
.show-img{
height: 100%;
width: 100%;
padding: 10px;
.card{
border-radius: 6px;
overflow: hidden;
.img{
position: relative;
min-height: 40px;
img{
width: 100%;
height: auto;
cursor: pointer;
}
.rate{
right: 0;
top: 0;
position: absolute;
width: 100%;
font-size: 1rem;
background-color: #111111aa;
color: #cdcdcd;
}
.operate{
display: none;
position: absolute;
left: 0;
bottom: 0;
background-color: #111111aa;
width: 100%;
font-size: 13px;
.operate-wrap{
display: flex;
justify-content: space-between;
.o-play, .o-star, .o-share{
cursor: pointer;
display: inline-block;
width: 80px;
height: 36px;
text-align: center;
line-height: 36px;
color: #cdcdcd;
&:hover{
background-color: #111;
}
}
}
}
}
}
.name{
font-size: 16px;
padding: 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.info{
display: flex;
justify-content: space-between;
font-size: 12px;
padding: 10px;
}
&:hover{
.operate{
display: block;
.name{
font-size: 16px;
padding: 10px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
}
.info{
display: flex;
justify-content: space-between;
font-size: 12px;
padding: 10px;
}
&:hover{
.operate{
display: block;
}
}
}
}

View File

@@ -10,7 +10,7 @@ import Share from './Share'
import History from './History'
import EditSites from './EditSites'
import IPTV from './IPTV'
import Recommandation from './Recommandation'
export default {
registerComponents () {
Vue.component('Aside', Aside)
@@ -24,5 +24,6 @@ export default {
Vue.component('History', History)
Vue.component('EditSites', EditSites)
Vue.component('IPTV', IPTV)
Vue.component('Recommandation', Recommandation)
}
}

View File

@@ -1,14 +1,15 @@
import Dexie from 'dexie'
import { setting, sites, localKey, iptv } from './initData'
import { setting, sites, localKey, iptv, recommandations } from './initData'
const db = new Dexie('zy')
db.version(4).stores({
search: '++id, keywords',
iptvSearch: '++id, keywords',
setting: 'id, theme, site, shortcut, view, externalPlayer, searchAllSites, excludeRootClasses, excludeR18Films, forwardTimeInSec',
setting: 'id, theme, site, shortcut, view, externalPlayer, searchAllSites, excludeRootClasses, excludeR18Films, forwardTimeInSec, starViewMode, recommandationViewMode',
shortcut: 'name, key, desc',
star: '++id, [key+ids], site, name, detail, index, rate, hasUpdate',
recommandation: '++id, [key+ids], site, name, detail, index, rate, hasUpdate',
sites: '++id, key, name, api, download, isActive, group',
history: '++id, [site+ids], name, type, year, index, time',
mini: 'id, site, ids, name, index, time',
@@ -20,6 +21,7 @@ db.on('populate', () => {
db.sites.bulkAdd(sites)
db.shortcut.bulkAdd(localKey)
db.iptv.bulkAdd(iptv)
db.recommandation.bulkAdd(recommandations)
})
db.open()

View File

@@ -7,6 +7,7 @@ import sites from './sites'
import search from './search'
import iptvSearch from './iptvSearch'
import iptv from './iptv'
import recommandation from './recommandation'
export {
history,
@@ -17,5 +18,6 @@ export {
sites,
iptv,
search,
iptvSearch
iptvSearch,
recommandation
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,9 @@ const setting = [
searchAllSites: true,
excludeRootClasses: true,
excludeR18Films: true,
forwardTimeInSec: 5
forwardTimeInSec: 5,
starViewMode: 'picture',
recommandationViewMode: 'picture'
}
]
@@ -342,11 +344,12 @@ const getSite = (key) => {
}
const iptv = require('./iniData/Iptv.json')
const recommandations = require('./iniData/Recommandations.json')
export {
setting,
sites,
iptv,
recommandations,
localKey,
getSite
}

View File

@@ -0,0 +1,28 @@
import db from './dexie'
const { recommandation } = db
export default {
async add (doc) {
return await recommandation.add(doc)
},
async bulkAdd (doc) {
return await recommandation.bulkAdd(doc)
},
async find (doc) {
return await recommandation.where(doc).first()
},
async update (id, docs) {
return await recommandation.update(id, docs)
},
async all () {
return await recommandation.toArray()
},
async remove (id) {
return await recommandation.delete(id)
},
async get (id) {
return await recommandation.get(id)
},
async clear () {
return await recommandation.clear()
}
}