Skip to content

Commit

Permalink
ESLint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wrgallo committed Jan 6, 2025
1 parent 720990e commit 6d01271
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/components/playback/playbackmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import browser from 'scripts/browser.js';
import { bindSkipSegment } from './skipsegment.ts';
import OpenSubtitlesManager from '../../scripts/opensubtitles/opensubtitles';


const UNLIMITED_ITEMS = -1;

function enableLocalPlaylistManagement(player) {
Expand Down
8 changes: 3 additions & 5 deletions src/controllers/itemDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async function renderSubtitleSelections(page, mediaSources) {
return m.Type === 'Subtitle';
});
tracks.sort(itemHelper.sortTracks);

const select = page.querySelector('.selectSubtitles');
select.setLabel(globalize.translate('Subtitles'));
const selectedId = mediaSource.DefaultSubtitleStreamIndex == null ? -1 : mediaSource.DefaultSubtitleStreamIndex;
Expand All @@ -297,7 +297,7 @@ async function renderSubtitleSelections(page, mediaSources) {
select.innerHTML = '<option value="-1">' + globalize.translate('Off') + '</option>' + tracks.map(function (v) {
selected = v.Index === selectedId ? ' selected' : '';
let out = '<option value="' + v.Index + '" ' + selected;
if ( Object.prototype.hasOwnProperty.call(v, 'OpenSubstitlesFileId') ) {
if ( Object.hasOwn(v, 'OpenSubstitlesFileId') ) {
out += ' data-OpenSubstitlesFileId=' + v.OpenSubstitlesFileId;
}
out += '>' + v.DisplayTitle + '</option>';
Expand Down Expand Up @@ -1991,18 +1991,16 @@ export default function (view, params) {
if ( currentItem?.MediaType === 'Video' ) {
const select = view.querySelector('.selectSubtitles');
const selectedSubtitleOption = select.options[ select.selectedIndex ];
if ( Object.prototype.hasOwnProperty.call(selectedSubtitleOption.dataset, 'OpenSubstitlesFileId') ) {
if ( Object.hasOwn(selectedSubtitleOption.dataset, 'OpenSubstitlesFileId') ) {
OpenSubtitlesManager.appendSubtitleTracks( currentItem.MediaStreams, currentItem );
await OpenSubtitlesManager.getDownloadLink( selectedSubtitleOption.dataset.OpenSubstitlesFileId );
//await fetch( OpenSubtitlesManager.downloadData.link );
}
}
} catch (err) {
console.error( err );
}
//-----------------


playCurrentItem(actionElem, action);
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/playback/video/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ export default function (view) {
const streams = playbackManager.subtitleTracks(player);
const secondaryStreams = playbackManager.secondarySubtitleTracks(player);
let currentIndex = playbackManager.getSubtitleStreamIndex(player);

playbackManager.pause(player);

if (currentIndex == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ build: ${__JF_BUILD_VERSION__}`);

// Connect to server
ServerConnections.firstConnection = await ServerConnections.connect();

// Start OpenSubtitlesManager
OpenSubtitlesManager.start();

Expand Down
15 changes: 4 additions & 11 deletions src/plugins/htmlVideoPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export class HtmlVideoPlayer {
destroyCastPlayer(this);

let secondaryTrackValid = true;

const subtitleTrackIndexToSetOnPlaying = options.mediaSource.DefaultSubtitleStreamIndex == null ? -1 : options.mediaSource.DefaultSubtitleStreamIndex;
this.#subtitleTrackIndexToSetOnPlaying = subtitleTrackIndexToSetOnPlaying;
if (this.#subtitleTrackIndexToSetOnPlaying != null && this.#subtitleTrackIndexToSetOnPlaying >= 0) {
Expand Down Expand Up @@ -1216,28 +1216,21 @@ export class HtmlVideoPlayer {
try {
const textTrackUrl = await getTextTrackUrl(track, item, '.js');
console.debug('[fetchSubtitles] textTrackUrl', textTrackUrl);

if ( textTrackUrl.includes('opensubtitles.com') ) {
const response = await fetch(textTrackUrl);
if (!response.ok) {
throw new Error(response);
}
console.debug('[opensubtitles] fetch(textTrackUrl)', response );
const srtText = await response.text();
// Special handling of the SRT file from opensubtitles
// Special handling of the SRT file from opensubtitles
return OpenSubtitlesManager.utils.srtToJson( srtText );
} else {
const response = await fetch(textTrackUrl);
if (!response.ok) {
throw new Error(response);
}
return response.json();
}

const response = await fetch(textTrackUrl);
if (!response.ok) {
throw new Error(response);
}

return response.json();
} finally {
this.decrementFetchQueue();
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/opensubtitles/opensubtitles.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class OpenSubtitlesManagerClass {

if ( mediaSource ) {
// OpenSubtitles is only for videos
if ( !Object.prototype.hasOwnProperty.call(mediaSource, 'VideoType') ) {
if ( !Object.hasOwn(mediaSource, 'VideoType') ) {
return streams;
}

Expand Down
6 changes: 3 additions & 3 deletions src/scripts/opensubtitles/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const languages = require('./languages.json');
/**
* OpenSubtitles supported languages and codes
*/
const Languages = languages.data.sort( function(a, b) {
const Languages = languages.data.toSorted( function(a, b) {
if (a.language_code < b.language_code) {
return -1;
} else if (a.language_code > b.language_code) {
Expand All @@ -22,8 +22,8 @@ function srtToJson( srt ) {
const out = { TrackEvents: [] };
let obj = { Text: '' };
try {
for (let line of data) {
line = line.trim();
for (const dataLine of data) {
const line = dataLine.trim();
if ( !line.length && obj.EndPositionTicks && obj.StartPositionTicks && obj.Text ) {
if ( !obj.Id ) {
obj.Id = 1 + out.TrackEvents.length;
Expand Down
2 changes: 1 addition & 1 deletion src/strings/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@
"Penciller": "Lápis",
"LabelSelectPreferredTranscodeVideoCodec": "Codec de vídeo transcodificado preferido",
"SelectPreferredTranscodeVideoCodecHelp": "Seleccione o codec de vídeo preferido para transcodificar. Se o codec preferido não for suportado, o servidor irá usar o melhor codec disponível a seguir.",
"HeaderNextItemPlayingInValue": "Próximo{0} Tocando em {1}",
"HeaderNextItemPlayingInValue": "Próximo {0} Tocando em {1}",
"LibraryInvalidItemIdError": "A biblioteca está em um estado inválido e não pode ser editada. Você possivelmente está encontrando um bug: o caminho no banco de dados não é o caminho correto no sistema de arquivos.",
"Reset": "Resetar",
"PasswordMissingSaveError": "A nova senha não pode ser em branco.",
Expand Down

0 comments on commit 6d01271

Please sign in to comment.