1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge branch 'master' into subtitle-improvements-2

This commit is contained in:
MBR-0001 2023-09-16 00:45:14 +02:00 committed by GitHub
commit f872f604f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
59 changed files with 1693 additions and 489 deletions

View file

@ -3,41 +3,32 @@ import browser from '../scripts/browser';
import dialog from './dialog/dialog';
import globalize from '../scripts/globalize';
function useNativeAlert() {
// webOS seems to block modals
// Tizen 2.x seems to block modals
return !browser.web0s
&& !(browser.tizenVersion && browser.tizenVersion < 3)
&& browser.tv
&& window.alert;
}
export default async function (text, title) {
let options;
if (typeof text === 'string') {
options = {
title: title,
text: text
};
} else {
options = text;
}
// Modals seem to be blocked on Web OS and Tizen 2.x
const canUseNativeAlert = !!(
!browser.web0s
&& !(browser.tizenVersion && browser.tizenVersion < 3)
&& browser.tv
&& window.alert
);
const options = typeof text === 'string' ? { title, text } : text;
await appRouter.ready();
if (useNativeAlert()) {
if (canUseNativeAlert) {
alert((options.text || '').replaceAll('<br/>', '\n'));
return Promise.resolve();
} else {
const items = [];
items.push({
return Promise.resolve();
}
options.buttons = [
{
name: globalize.translate('ButtonGotIt'),
id: 'ok',
type: 'submit'
});
}
];
options.buttons = items;
return dialog.show(options);
}
return dialog.show(options);
}

View file

@ -803,19 +803,17 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
} else {
lines.push(escapeHtml(item.SeriesName));
}
} else if (isUsingLiveTvNaming(item)) {
lines.push(escapeHtml(item.Name));
if (!item.EpisodeTitle && !item.IndexNumber) {
titleAdded = true;
}
} else {
if (isUsingLiveTvNaming(item)) {
lines.push(escapeHtml(item.Name));
const parentTitle = item.SeriesName || item.Series || item.Album || item.AlbumArtist || '';
if (!item.EpisodeTitle && !item.IndexNumber) {
titleAdded = true;
}
} else {
const parentTitle = item.SeriesName || item.Series || item.Album || item.AlbumArtist || '';
if (parentTitle || showTitle) {
lines.push(escapeHtml(parentTitle));
}
if (parentTitle || showTitle) {
lines.push(escapeHtml(parentTitle));
}
}
}
@ -898,13 +896,11 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
if (item.Type === 'Series') {
if (item.Status === 'Continuing') {
lines.push(globalize.translate('SeriesYearToPresent', productionYear || ''));
} else if (item.EndDate && item.ProductionYear) {
const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false });
lines.push(productionYear + ((endYear === item.ProductionYear) ? '' : (' - ' + endYear)));
} else {
if (item.EndDate && item.ProductionYear) {
const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false });
lines.push(productionYear + ((endYear === item.ProductionYear) ? '' : (' - ' + endYear)));
} else {
lines.push(productionYear || '');
}
lines.push(productionYear || '');
}
} else {
lines.push(productionYear || '');

View file

@ -762,12 +762,10 @@ function Guide(options) {
} else {
container.scrollTo(0, pos);
}
} else if (horizontal) {
container.scrollLeft = Math.round(pos);
} else {
if (horizontal) {
container.scrollLeft = Math.round(pos);
} else {
container.scrollTop = Math.round(pos);
}
container.scrollTop = Math.round(pos);
}
}

View file

@ -216,14 +216,12 @@ function getFetchLatestItemsFn(serverId, parentId, collectionType) {
if (collectionType === 'music') {
limit = 30;
}
} else if (collectionType === 'tvshows') {
limit = 5;
} else if (collectionType === 'music') {
limit = 9;
} else {
if (collectionType === 'tvshows') {
limit = 5;
} else if (collectionType === 'music') {
limit = 9;
} else {
limit = 8;
}
limit = 8;
}
const options = {

View file

@ -76,20 +76,18 @@ export function handleHlsJsMediaError(instance, reject) {
recoverDecodingErrorDate = now;
console.debug('try to recover media Error ...');
hlsPlayer.recoverMediaError();
} else if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) {
recoverSwapAudioCodecDate = now;
console.debug('try to swap Audio Codec and recover media Error ...');
hlsPlayer.swapAudioCodec();
hlsPlayer.recoverMediaError();
} else {
if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) {
recoverSwapAudioCodecDate = now;
console.debug('try to swap Audio Codec and recover media Error ...');
hlsPlayer.swapAudioCodec();
hlsPlayer.recoverMediaError();
} else {
console.error('cannot recover, last media error recovery failed ...');
console.error('cannot recover, last media error recovery failed ...');
if (reject) {
reject();
} else {
onErrorInternal(instance, 'mediadecodeerror');
}
if (reject) {
reject();
} else {
onErrorInternal(instance, 'mediadecodeerror');
}
}
}

View file

@ -171,14 +171,12 @@ function getRemoteImageHtml(image, imageType) {
shape = 'banner';
} else if (imageType === 'Disc') {
shape = 'square';
} else if (currentItemType === 'Episode') {
shape = 'backdrop';
} else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') {
shape = 'square';
} else {
if (currentItemType === 'Episode') {
shape = 'backdrop';
} else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') {
shape = 'square';
} else {
shape = 'portrait';
}
shape = 'portrait';
}
cssClass += ' ' + shape + 'Card ' + shape + 'Card-scalable';
@ -230,10 +228,8 @@ function getRemoteImageHtml(image, imageType) {
if (image.Language) {
html += ' • ' + image.Language;
}
} else {
if (image.Language) {
html += image.Language;
}
} else if (image.Language) {
html += image.Language;
}
html += '</div>';
@ -244,16 +240,14 @@ function getRemoteImageHtml(image, imageType) {
if (image.RatingType === 'Likes') {
html += image.CommunityRating + (image.CommunityRating === 1 ? ' like' : ' likes');
} else {
if (image.CommunityRating) {
html += image.CommunityRating.toFixed(1);
} else if (image.CommunityRating) {
html += image.CommunityRating.toFixed(1);
if (image.VoteCount) {
html += ' • ' + image.VoteCount + (image.VoteCount === 1 ? ' vote' : ' votes');
}
} else {
html += 'Unrated';
if (image.VoteCount) {
html += ' • ' + image.VoteCount + (image.VoteCount === 1 ? ' vote' : ' votes');
}
} else {
html += 'Unrated';
}
html += '</div>';

View file

@ -164,10 +164,8 @@ function getCardHtml(image, apiClient, options) {
} else {
html += '<button type="button" is="paper-icon-button-light" class="autoSize" disabled title="' + globalize.translate('MoveRight') + '"><span class="material-icons chevron_right" aria-hidden="true"></span></button>';
}
} else {
if (options.imageProviders.length) {
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('Search') + '"><span class="material-icons search" aria-hidden="true"></span></button>';
}
} else if (options.imageProviders.length) {
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('Search') + '"><span class="material-icons search" aria-hidden="true"></span></button>';
}
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" data-index="' + (image.ImageIndex != null ? image.ImageIndex : 'null') + '" class="btnDeleteImage autoSize" title="' + globalize.translate('Delete') + '"><span class="material-icons delete" aria-hidden="true"></span></button>';

View file

@ -374,14 +374,12 @@ export function getListViewHtml(options) {
if (options.artist !== false && item.AlbumArtist && item.Type === 'MusicAlbum') {
textlines.push(item.AlbumArtist);
}
} else {
if (options.artist) {
const artistItems = item.ArtistItems;
if (artistItems && item.Type !== 'MusicAlbum') {
textlines.push(artistItems.map(a => {
return a.Name;
}).join(', '));
}
} else if (options.artist) {
const artistItems = item.ArtistItems;
if (artistItems && item.Type !== 'MusicAlbum') {
textlines.push(artistItems.map(a => {
return a.Name;
}).join(', '));
}
}

View file

@ -649,10 +649,8 @@ function onPlaybackStopped(e, state) {
if (state.NextMediaType !== 'Audio') {
hideNowPlayingBar();
}
} else {
if (!state.NextMediaType) {
hideNowPlayingBar();
}
} else if (!state.NextMediaType) {
hideNowPlayingBar();
}
}

View file

@ -14,6 +14,7 @@ import alert from '../alert';
import { PluginType } from '../../types/plugin.ts';
import { includesAny } from '../../utils/container.ts';
import { getItems } from '../../utils/jellyfin-apiclient/getItems.ts';
import { getItemBackdropImageUrl } from '../../utils/jellyfin-apiclient/backdropImage';
const UNLIMITED_ITEMS = -1;
@ -154,28 +155,6 @@ function mergePlaybackQueries(obj1, obj2) {
return query;
}
function backdropImageUrl(apiClient, item, options) {
options = options || {};
options.type = options.type || 'Backdrop';
// If not resizing, get the original image
if (!options.maxWidth && !options.width && !options.maxHeight && !options.height && !options.fillWidth && !options.fillHeight) {
options.quality = 100;
}
if (item.BackdropImageTags?.length) {
options.tag = item.BackdropImageTags[0];
return apiClient.getScaledImageUrl(item.Id, options);
}
if (item.ParentBackdropImageTags?.length) {
options.tag = item.ParentBackdropImageTags[0];
return apiClient.getScaledImageUrl(item.ParentBackdropItemId, options);
}
return null;
}
function getMimeType(type, container) {
container = (container || '').toLowerCase();
@ -1437,15 +1416,13 @@ class PlaybackManager {
if (Screenfull.isEnabled) {
Screenfull.toggle();
} else {
} else if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
// iOS Safari
if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
document.webkitCancelFullscreen();
} else {
const elem = document.querySelector('video');
if (elem?.webkitEnterFullscreen) {
elem.webkitEnterFullscreen();
}
document.webkitCancelFullscreen();
} else {
const elem = document.querySelector('video');
if (elem?.webkitEnterFullscreen) {
elem.webkitEnterFullscreen();
}
}
};
@ -2345,30 +2322,23 @@ class PlaybackManager {
let prevRelIndex = 0;
for (const stream of prevSource.MediaStreams) {
if (stream.Type != streamType)
continue;
if (stream.Type != streamType) continue;
if (stream.Index == prevIndex)
break;
if (stream.Index == prevIndex) break;
prevRelIndex += 1;
}
let newRelIndex = 0;
for (const stream of mediaSource.MediaStreams) {
if (stream.Type != streamType)
continue;
if (stream.Type != streamType) continue;
let score = 0;
if (prevStream.Codec == stream.Codec)
score += 1;
if (prevRelIndex == newRelIndex)
score += 1;
if (prevStream.DisplayTitle && prevStream.DisplayTitle == stream.DisplayTitle)
score += 2;
if (prevStream.Language && prevStream.Language != 'und' && prevStream.Language == stream.Language)
score += 2;
if (prevStream.Codec == stream.Codec) score += 1;
if (prevRelIndex == newRelIndex) score += 1;
if (prevStream.DisplayTitle && prevStream.DisplayTitle == stream.DisplayTitle) score += 2;
if (prevStream.Language && prevStream.Language != 'und' && prevStream.Language == stream.Language) score += 2;
console.debug(`AutoSet ${streamType} - Score ${score} for ${stream.Index} - ${stream.DisplayTitle}`);
if (score > bestStreamScore && score >= 3) {
@ -2388,8 +2358,9 @@ class PlaybackManager {
mediaSource.DefaultSubtitleStreamIndex = bestStreamIndex;
}
}
if (streamType == 'Audio')
if (streamType == 'Audio') {
mediaSource.DefaultAudioStreamIndex = bestStreamIndex;
}
} else {
console.debug(`AutoSet ${streamType} - Threshold not met. Using default.`);
}
@ -2693,7 +2664,7 @@ class PlaybackManager {
title: item.Name
};
const backdropUrl = backdropImageUrl(apiClient, item, {});
const backdropUrl = getItemBackdropImageUrl(apiClient, item, {}, true);
if (backdropUrl) {
resultInfo.backdropUrl = backdropUrl;
}

View file

@ -129,22 +129,6 @@ class PluginManager {
.sort((p1, p2) => (p1.priority || 0) - (p2.priority || 0))[0];
}
#mapRoute(plugin, route) {
if (typeof plugin === 'string') {
plugin = this.pluginsList.filter((p) => {
return (p.id || p.packageName) === plugin;
})[0];
}
route = route.path || route;
if (route.toLowerCase().startsWith('http')) {
return route;
}
return '/plugins/' + plugin.id + '/' + route;
}
mapPath(plugin, path, addCacheParam) {
if (typeof plugin === 'string') {
plugin = this.pluginsList.filter((p) => {

View file

@ -191,15 +191,13 @@ function onRecordChange(e) {
loading.hide();
});
}
} else {
if (hasEnabledTimer) {
loading.show();
recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () {
Events.trigger(self, 'recordingchanged');
fetchData(self);
loading.hide();
});
}
} else if (hasEnabledTimer) {
loading.show();
recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () {
Events.trigger(self, 'recordingchanged');
fetchData(self);
loading.hide();
});
}
}
@ -223,13 +221,11 @@ function onRecordSeriesChange(e) {
fetchData(self);
});
}
} else {
if (this.SeriesTimerId) {
apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () {
toast(globalize.translate('RecordingCancelled'));
fetchData(self);
});
}
} else if (this.SeriesTimerId) {
apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () {
toast(globalize.translate('RecordingCancelled'));
fetchData(self);
});
}
}

View file

@ -514,10 +514,12 @@ export default function (options) {
function toggleFullscreenButtons(isFullscreen) {
const btnFullscreen = dialog.querySelector('.btnFullscreen');
const btnFullscreenExit = dialog.querySelector('.btnFullscreenExit');
if (btnFullscreen)
if (btnFullscreen) {
btnFullscreen.classList.toggle('hide', isFullscreen);
if (btnFullscreenExit)
}
if (btnFullscreenExit) {
btnFullscreenExit.classList.toggle('hide', !isFullscreen);
}
}
/**

View file

@ -194,7 +194,8 @@ function renderSearchResults(context, results) {
html += '<span class="listItemIcon material-icons closed_caption" aria-hidden="true"></span>';
const bodyClass = result.Comment || result.IsHashMatch ? 'three-line' : 'two-line';
const hasAnyFlags = result.IsHashMatch || result.AiTranslated || result.MachineTranslated || result.Forced || result.HearingImpaired;
const bodyClass = result.Comment || hasAnyFlags ? 'three-line' : 'two-line';
html += '<div class="listItemBody ' + bodyClass + '">';
@ -206,16 +207,45 @@ function renderSearchResults(context, results) {
}
if (result.DownloadCount != null) {
html += '<span>' + globalize.translate('DownloadsValue', result.DownloadCount) + '</span>';
html += '<span style="margin-right:1em;">' + globalize.translate('DownloadsValue', result.DownloadCount) + '</span>';
}
if (result.FrameRate) {
html += '<span>' + globalize.translate('Framerate') + ': ' + result.FrameRate + '</span>';
}
html += '</div>';
if (result.Comment) {
html += '<div class="secondary listItemBodyText">' + escapeHtml(result.Comment) + '</div>';
html += '<div class="secondary listItemBodyText" style="white-space:pre-line;">' + escapeHtml(result.Comment) + '</div>';
}
if (result.IsHashMatch) {
html += '<div class="secondary listItemBodyText"><div class="inline-flex align-items-center justify-content-center" style="background:#3388cc;color:#fff;padding: .3em 1em;border-radius:1000em;">' + globalize.translate('PerfectMatch') + '</div></div>';
if (hasAnyFlags) {
html += '<div class="secondary listItemBodyText">';
const spanOpen = '<span class="inline-flex align-items-center justify-content-center subtitleFeaturePillow">';
if (result.IsHashMatch) {
html += spanOpen + globalize.translate('PerfectMatch') + '</span>';
}
if (result.AiTranslated) {
html += spanOpen + globalize.translate('AiTranslated') + '</span>';
}
if (result.MachineTranslated) {
html += spanOpen + globalize.translate('MachineTranslated') + '</span>';
}
if (result.Forced) {
html += spanOpen + globalize.translate('ForeignPartsOnly') + '</span>';
}
if (result.HearingImpaired) {
html += spanOpen + globalize.translate('HearingImpairedShort') + '</span>';
}
html += '</div>';
}
html += '</div>';

View file

@ -1,3 +1,11 @@
.originalSubtitleFileLabel {
margin-right: 1em;
}
.subtitleFeaturePillow {
background: #00a4dc;
color: #000;
padding: 0.3em 1em;
border-radius: 1000em;
margin-right: 0.25em;
}

View file

@ -73,12 +73,10 @@ export function loadView(options) {
} else {
mainAnimatedPages.replaceChild(view, currentPage);
}
} else if (newViewInfo.hasScript && window.$) {
view = $(view).appendTo(mainAnimatedPages)[0];
} else {
if (newViewInfo.hasScript && window.$) {
view = $(view).appendTo(mainAnimatedPages)[0];
} else {
mainAnimatedPages.appendChild(view);
}
mainAnimatedPages.appendChild(view);
}
if (options.type) {