mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-19 15:42:05 +00:00
feat: preferred sub and audio
This commit is contained in:
parent
e5e69f39d0
commit
547100a835
4 changed files with 97 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Miru",
|
||||
"version": "3.8.3",
|
||||
"version": "3.9.0",
|
||||
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
||||
"description": "Stream anime torrents, real-time with no waiting for downloads.",
|
||||
"main": "src/index.js",
|
||||
|
|
|
|||
|
|
@ -69,12 +69,20 @@
|
|||
$: safeduration = (isFinite(duration) ? duration : currentTime) || 0
|
||||
|
||||
function checkAudio () {
|
||||
if ('audioTracks' in HTMLVideoElement.prototype && !video.audioTracks.length) {
|
||||
addToast({
|
||||
text: "This torrent's audio codec is not supported, try a different release by disabling Autoplay Torrents in RSS settings.",
|
||||
title: 'Audio Codec Unsupported',
|
||||
type: 'danger'
|
||||
})
|
||||
if ('audioTracks' in HTMLVideoElement.prototype) {
|
||||
if (!video.audioTracks.length) {
|
||||
addToast({
|
||||
text: "This torrent's audio codec is not supported, try a different release by disabling Autoplay Torrents in RSS settings.",
|
||||
title: 'Audio Codec Unsupported',
|
||||
type: 'danger'
|
||||
})
|
||||
} else if (video.audioTracks.length > 1) {
|
||||
const preferredTrack = [...video.audioTracks].find(({ language }) => language === set.audioLanguage)
|
||||
if (preferredTrack) return selectAudio(preferredTrack.id)
|
||||
|
||||
const japaneseTrack = [...video.audioTracks].find(({ language }) => language === 'jpn')
|
||||
if (japaneseTrack) return selectAudio(japaneseTrack.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
torrentDHT: false,
|
||||
torrentPeX: false,
|
||||
missingFont: true,
|
||||
maxConns: 20
|
||||
maxConns: 20,
|
||||
subtitleLanguage: 'eng',
|
||||
audioLanguage: 'jpn'
|
||||
}
|
||||
localStorage.removeItem('relations') // TODO: remove
|
||||
export const set = { ...defaults, ...(JSON.parse(localStorage.getItem('settings')) || {}) }
|
||||
|
|
@ -234,6 +236,67 @@
|
|||
<input type='checkbox' id='player-autocomplete' bind:checked={settings.playerAutocomplete} />
|
||||
<label for='player-autocomplete'>Autocomplete Episodes</label>
|
||||
</div>
|
||||
<div class='col p-10 d-flex flex-column justify-content-end'>
|
||||
<div class='font-size-24 font-weight-semi-bold d-flex'>
|
||||
<div class='material-icons mr-10 font-size-30'>translate</div>
|
||||
Language Settings
|
||||
</div>
|
||||
</div>
|
||||
<div class='input-group mb-10 w-400 form-control-lg' data-toggle='tooltip' data-placement='top' data-title='What Subtitle Language To Automatically Select, If Not Found Defaults To English'>
|
||||
<div class='input-group-prepend'>
|
||||
<span class='input-group-text w-250 justify-content-center'>Preferred Subtitle Language</span>
|
||||
</div>
|
||||
<select class='form-control form-control-lg' bind:value={settings.subtitleLanguage}>
|
||||
<option value=''>None</option>
|
||||
<option value='eng' selected>English</option>
|
||||
<option value='jpn'>Japanese</option>
|
||||
<option value='chi'>Chinese</option>
|
||||
<option value='por'>Portuguese</option>
|
||||
<option value='spa'>Spanish</option>
|
||||
<option value='ger'>German</option>
|
||||
<option value='pol'>Polish</option>
|
||||
<option value='cze'>Czech</option>
|
||||
<option value='dan'>Danish</option>
|
||||
<option value='gre'>Greek</option>
|
||||
<option value='fin'>Finnish</option>
|
||||
<option value='fre'>French</option>
|
||||
<option value='hun'>Hungarian</option>
|
||||
<option value='ita'>Italian</option>
|
||||
<option value='kor'>Korean</option>
|
||||
<option value='dut'>Dutch</option>
|
||||
<option value='nor'>Norwegian</option>
|
||||
<option value='rum'>Romanian</option>
|
||||
<option value='slo'>Slovak</option>
|
||||
<option value='swe'>Swedish</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class='input-group mb-10 w-400 form-control-lg' data-toggle='tooltip' data-placement='top' data-title='What Audio Language To Automatically Select, If Not Found Defaults To Japanese'>
|
||||
<div class='input-group-prepend'>
|
||||
<span class='input-group-text w-250 justify-content-center'>Preferred Audio Language</span>
|
||||
</div>
|
||||
<select class='form-control form-control-lg' bind:value={settings.audioLanguage}>
|
||||
<option value='eng'>English</option>
|
||||
<option value='jpn' selected>Japanese</option>
|
||||
<option value='chi'>Chinese</option>
|
||||
<option value='por'>Portuguese</option>
|
||||
<option value='spa'>Spanish</option>
|
||||
<option value='ger'>German</option>
|
||||
<option value='pol'>Polish</option>
|
||||
<option value='cze'>Czech</option>
|
||||
<option value='dan'>Danish</option>
|
||||
<option value='gre'>Greek</option>
|
||||
<option value='fin'>Finnish</option>
|
||||
<option value='fre'>French</option>
|
||||
<option value='hun'>Hungarian</option>
|
||||
<option value='ita'>Italian</option>
|
||||
<option value='kor'>Korean</option>
|
||||
<option value='dut'>Dutch</option>
|
||||
<option value='nor'>Norwegian</option>
|
||||
<option value='rum'>Romanian</option>
|
||||
<option value='slo'>Slovak</option>
|
||||
<option value='swe'>Swedish</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</Tab>
|
||||
<Tab>
|
||||
|
|
|
|||
|
|
@ -66,14 +66,6 @@ export default class Subtitles {
|
|||
if (!this.tracks[track.number]) {
|
||||
// overwrite webvtt or other header with custom one
|
||||
if (track.type !== 'ass') track.header = defaultHeader
|
||||
if (!this.current) {
|
||||
this.current = track.number
|
||||
const styleMatches = track.header.match(stylesRx)
|
||||
for (let i = 0; i < styleMatches.length; ++i) {
|
||||
const style = styleMatches[i].replace('Style:', '').trim()
|
||||
this._stylesMap[style] = i + 1
|
||||
}
|
||||
}
|
||||
this.tracks[track.number] = []
|
||||
this._tracksString[track.number] = new Set()
|
||||
this.headers[track.number] = track
|
||||
|
|
@ -82,6 +74,23 @@ export default class Subtitles {
|
|||
}
|
||||
}
|
||||
this.initSubtitleRenderer()
|
||||
const tracks = this.headers?.filter(t => t)
|
||||
if (tracks?.length && set.subtitleLanguage) {
|
||||
if (tracks.length === 1) {
|
||||
this.selectCaptions(tracks[0].number)
|
||||
} else {
|
||||
const wantedTrack = tracks.find(({ language }) => {
|
||||
if (language == null) language = 'eng'
|
||||
return language === set.subtitleLanguage
|
||||
})
|
||||
if (wantedTrack) return this.selectCaptions(wantedTrack.number)
|
||||
|
||||
const englishTrack = tracks.find(({ language }) => language === null || language === 'eng')
|
||||
if (englishTrack) return this.selectCaptions(englishTrack.number)
|
||||
|
||||
this.selectCaptions(tracks[0].number)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +142,7 @@ export default class Subtitles {
|
|||
if (!this.renderer) {
|
||||
const options = {
|
||||
video: this.video,
|
||||
subContent: this.headers[this.current].header.slice(0, -1),
|
||||
subContent: defaultHeader,
|
||||
fonts: this.fonts,
|
||||
fallbackFont: set.font?.name || 'roboto medium',
|
||||
availableFonts: {
|
||||
|
|
@ -146,7 +155,6 @@ export default class Subtitles {
|
|||
options.availableFonts[set.font.name.toLowerCase()] = new Uint8Array(set.font.data)
|
||||
}
|
||||
this.renderer = new JASSUB(options)
|
||||
this.selectCaptions(this.current)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue