-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
45 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,33 +211,38 @@ | |
|
||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/index.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/index.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].23/dist/index.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].24/dist/index.min.js"></script> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].3/dist/airplay.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].5/dist/chromecast.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].6/dist/airplay.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected].6/dist/chromecast.min.js"></script> | ||
|
||
<script> | ||
var playlistScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/playlist.min.js' | ||
var playlistScriptCdn = | ||
'https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/playlist.min.js' | ||
var danmakuScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/danmaku@latest/dist/index.min.js' | ||
|
||
var query = document.location.search.substring(1) | ||
var src, poster, subtitle, danmaku, title, watermark | ||
var playlist = [], | ||
deps = [], | ||
isM3u = false | ||
|
||
if (query.endsWith('==')) { | ||
src = atob(query.substring(0, query.length - 2)) | ||
} else if (query.startsWith('http')) { | ||
src = safeDecodeURIComponent(query.substring(0, query.length - 1)) | ||
m3u = false, | ||
p = 0 | ||
|
||
var _query = decodeURIComponent(query || '') | ||
if (_query.startsWith('http')) { | ||
// ?https://xx.com= 有时候会自动带上 “=” | ||
src = _query.endsWith('=') ? _query.substring(0, _query.length - 1) : query | ||
} else if (_query.endsWith('=')) { | ||
src = atob(_query) | ||
} else { | ||
var search = new URLSearchParams(document.location.search) | ||
src = safeDecodeURIComponent(search.get('src')) | ||
playlist = JSON.parse(safeDecodeURIComponent(search.get('playlist')) || '[]') | ||
poster = safeDecodeURIComponent(search.get('poster')) | ||
title = safeDecodeURIComponent(search.get('title')) || '❤OPlayer' | ||
danmaku = safeDecodeURIComponent(search.get('danmaku')) | ||
isM3u = Boolean(search.get('m3u')) | ||
m3u = safeDecodeURIComponent(search.get('m3u')) | ||
p = search.get('p') || 0 | ||
|
||
subtitle = search.get('subtitle') | ||
? { | ||
|
@@ -267,9 +272,9 @@ | |
: undefined | ||
} | ||
|
||
if (/m3u(#|\?|$)/i.test(src) || isM3u) { | ||
playlist = [{ title: '-', src, poster }] | ||
isM3u = true | ||
if (/m3u(#|\?|$)/i.test(src) || m3u) { | ||
playlist = [{ title: '-', src: typeof m3u == 'string' ? m3u : src, poster }] | ||
m3u = true | ||
src = undefined | ||
deps.push(['https://cdn.jsdelivr.net/npm/[email protected]/dist/m3u8-parser.min.js']) | ||
} | ||
|
@@ -328,7 +333,7 @@ | |
library: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/hls.min.js' | ||
}), | ||
ODash({ library: 'https://cdn.dashjs.org/latest/dash.all.min.js' }), | ||
OMpegts(), | ||
OMpegts({ library: 'https://cdn.jsdelivr.net/npm/mpegts.js/dist/mpegts.min.js' }), | ||
new OAirplay(), | ||
new OChromecast() | ||
]) | ||
|
@@ -342,22 +347,24 @@ | |
OPlaylist.m3u8Parser = m3u8Parser | ||
player.applyPlugin( | ||
new OPlaylist({ | ||
initialIndex: 0, | ||
initialIndex: p, | ||
autoHide: false, | ||
sources: playlist, | ||
m3uList: isM3u | ||
m3uList: m3u | ||
? { | ||
sourceFormat(info) { | ||
try { | ||
const chunk = info.title.substring(3).split(' ') | ||
const titleWith = chunk.find((it) => it.includes('title')).split('=')[1] | ||
const posterWith = chunk.find((it) => it.includes('logo'))?.split('=')[1] | ||
const chunk = info.title.substring(3).split('" ') | ||
const titleWith = /group-title="(.+",.+)/.exec(info.title) | ||
const posterWith = /tvg-logo="(.+)"/.exec(info.title) | ||
return { | ||
src: info.uri, | ||
title: titleWith.substring(1, titleWith.length), | ||
poster: posterWith?.substring(1, posterWith.length) | ||
format: 'm3u8', | ||
title: titleWith ? titleWith[1] : /group-title="(.+)"/.exec(info.title)[1], | ||
poster: posterWith && posterWith[1] | ||
} | ||
} catch (error) { | ||
return { src: info.uri, title: info.title } | ||
return { src: info.uri, title: info.title, format: 'm3u8' } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters