Skip to content

Commit

Permalink
continued pacification of es-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sky-High committed Sep 25, 2023
1 parent a909ba9 commit db5eb70
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 54 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"eslint-config-prettier": "9.0.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.28.1",
"eslint-plugin-jsdoc": "46.8.2",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-prettier": "5.0.0",
"eslint-plugin-promise": "6.1.1",
Expand Down
6 changes: 4 additions & 2 deletions src/components/fetchhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @param request - Custom request object, mostly modeled after RequestInit.
* @returns response promise
*/
function getFetchPromise(request: any): Promise<Response> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function getFetchPromise(request: any): Promise<Response> {
const headers = request.headers || {};

if (request.dataType === 'json') {
Expand Down Expand Up @@ -102,7 +103,8 @@ function paramsToString(params: Record<string, string>): string {
* @param request - RequestInit-like structure but with url/type/timeout parameters as well
* @returns response promise, may be automatically unpacked based on request datatype
*/
export async function ajax(request: any): Promise<Response | string> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function ajax(request: any): Promise<Response | string> {
if (!request) {
throw new Error('Request cannot be null');
}
Expand Down
9 changes: 6 additions & 3 deletions src/components/jellyfinActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function restartPingInterval(reportingParams: PlaybackProgressInfo): void {
stopPingInterval();

if (reportingParams.PlayMethod == 'Transcode') {
pingInterval = <any>setInterval(() => { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
pingInterval = <any>setInterval(() => {
pingTranscoder(reportingParams);
}, 1000);
}
Expand Down Expand Up @@ -183,7 +184,8 @@ export function pingTranscoder(
* @param customData - data to set on playback state.
* @param serverItem - item that is playing
*/
export function load(customData: any, serverItem: BaseItemDto): void { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function load(customData: any, serverItem: BaseItemDto): void {
PlaybackManager.resetPlaybackScope();

const state = PlaybackManager.playbackState;
Expand Down Expand Up @@ -255,7 +257,8 @@ export function getPlaybackInfo(
audioStreamIndex: number,
subtitleStreamIndex: number,
liveStreamId: string | null = null
): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): Promise<any> {
const postData = {
DeviceProfile: deviceProfile
};
Expand Down
10 changes: 7 additions & 3 deletions src/components/jellyfinApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export abstract class JellyfinApi {
serverAddress?: string,
receiverName = ''
): void {
console.debug(`JellyfinApi.setServerInfo: user:${userId}, token:${accessToken}, server:${serverAddress}, name:${receiverName}`);
console.debug(
`JellyfinApi.setServerInfo: user:${userId}, token:${accessToken}, server:${serverAddress}, name:${receiverName}`
);
this.userId = userId;
this.accessToken = accessToken;
this.serverAddress = serverAddress;
Expand Down Expand Up @@ -124,7 +126,8 @@ export abstract class JellyfinApi {
}

// Authenticated ajax
public static authAjax(path: string, args: any): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static authAjax(path: string, args: any): Promise<any> {
if (
this.userId === undefined ||
this.accessToken === undefined ||
Expand All @@ -146,7 +149,8 @@ export abstract class JellyfinApi {
}

// Authenticated ajax
public static authAjaxUser(path: string, args: any): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public static authAjaxUser(path: string, args: any): Promise<any> {
if (
this.userId === undefined ||
this.accessToken === undefined ||
Expand Down
37 changes: 24 additions & 13 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ window.playerManager.addEventListener(
reportPlaybackStopped(
PlaybackManager.playbackState,
getReportingParams(PlaybackManager.playbackState)
);
);
}
);

Expand Down Expand Up @@ -284,7 +284,8 @@ export async function reportDeviceCapabilities(): Promise<void> {
* processMessage
* @param data - data
*/
export function processMessage(data: any): void { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function processMessage(data: any): void {
if (
!data.command ||
!data.serverAddress ||
Expand Down Expand Up @@ -385,7 +386,8 @@ export function setSubtitleStreamIndex(

// FIXME: Possible index error when MediaStreams is undefined.
const currentSubtitleStream = state.mediaSource?.MediaStreams?.filter(
(m: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(m: any) => {
return m.Index == state.subtitleStreamIndex && m.Type == 'Subtitle';
}
)[0];
Expand Down Expand Up @@ -456,6 +458,7 @@ export function setSubtitleStreamIndex(
* setAudioStreamIndex
* @param state - playback state.
* @param index - index
* @returns promise
*/
export function setAudioStreamIndex(
state: PlaybackState,
Expand Down Expand Up @@ -534,7 +537,8 @@ export async function changeStream(
// TODO save namespace somewhere global?
window.castReceiverContext.addCustomMessageListener(
'urn:x-cast:com.connectsdk',
(evt: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(evt: any) => {
let data: any = evt.data; // eslint-disable-line @typescript-eslint/no-explicit-any

// Apparently chromium likes to pass it as json, not as object.
Expand Down Expand Up @@ -595,8 +599,10 @@ export async function translateItems(
* @returns promise
*/
export async function instantMix(
data: any, // eslint-disable-line @typescript-eslint/no-explicit-any
options: any, // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: any,
item: BaseItemDto
): Promise<void> {
const result = await getInstantMixItems(data.userId, item);
Expand All @@ -613,8 +619,10 @@ export async function instantMix(
* @returns promise
*/
export async function shuffle(
data: any, // eslint-disable-line @typescript-eslint/no-explicit-any
options: any, // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: any,
item: BaseItemDto
): Promise<void> {
const result = await getShuffleItems(data.userId, item);
Expand All @@ -633,7 +641,8 @@ export async function shuffle(
*/
export async function onStopPlayerBeforePlaybackDone(
item: BaseItemDto,
options: any // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: any
): Promise<void> {
const data = await JellyfinApi.authAjaxUser(`Items/${item.Id}`, {
dataType: 'json',
Expand Down Expand Up @@ -697,7 +706,8 @@ export function showPlaybackInfoErrorMessage(error: string): void {
* @param versions - versions
* @returns stream
*/
export function getOptimalMediaSource(versions: Array<any>): any { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getOptimalMediaSource(versions: Array<any>): any {
let optimalVersion = versions.filter((v) => {
checkDirectPlay(v);

Expand All @@ -721,7 +731,7 @@ export function getOptimalMediaSource(versions: Array<any>): any { // eslint-dis
// Disable direct play on non-http sources
/**
* checkDirectPlay
* @param mediaSource
* @param mediaSource - mediaSource
*/
export function checkDirectPlay(mediaSource: MediaSourceInfo): void {
if (
Expand All @@ -738,7 +748,7 @@ export function checkDirectPlay(mediaSource: MediaSourceInfo): void {

/**
* setTextTrack
* @param index
* @param index - index
*/
export function setTextTrack(index: number | null): void {
try {
Expand Down Expand Up @@ -830,7 +840,8 @@ export function setTextTrack(index: number | null): void {
export function createMediaInformation(
playSessionId: string,
item: BaseItemDto,
streamInfo: any // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
streamInfo: any
): framework.messages.MediaInformation {
const mediaInfo = new cast.framework.messages.MediaInformation();

Expand Down
38 changes: 26 additions & 12 deletions src/components/playbackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import type {
} from '@jellyfin/sdk/lib/generated-client';
import { RepeatMode } from '@jellyfin/sdk/lib/generated-client';
import { AppStatus } from '../types/appStatus';
import { ItemIndex } from '~/types/global';
import {
broadcastConnectionErrorMessage,
createStreamInfo,
ticksToSeconds
} from '../helpers';
import { DocumentManager } from './documentManager';
import { getDeviceProfile } from './deviceprofileBuilder';
import {
getPlaybackInfo,
getLiveStream,
load,
stopPingInterval
} from './jellyfinActions';
import { getDeviceProfile } from './deviceprofileBuilder';
import {
onStopPlayerBeforePlaybackDone,
getMaxBitrate,
Expand All @@ -26,7 +26,7 @@ import {
checkDirectPlay,
createMediaInformation
} from './maincontroller';
import { DocumentManager } from './documentManager';
import { ItemIndex } from '~/types/global';

export interface PlaybackState {
startPositionTicks: number;
Expand All @@ -51,7 +51,6 @@ export interface PlaybackState {
runtimeTicks: number;
}


export abstract class PlaybackManager {
private static playerManager: framework.PlayerManager;
private static activePlaylist: Array<BaseItemDto>;
Expand Down Expand Up @@ -90,16 +89,22 @@ export abstract class PlaybackManager {
*/
static isPlaying(): boolean {
return (
this.playerManager.getPlayerState() === cast.framework.messages.PlayerState.PLAYING ||
this.playerManager.getPlayerState() === cast.framework.messages.PlayerState.PAUSED
this.playerManager.getPlayerState() ===
cast.framework.messages.PlayerState.PLAYING ||
this.playerManager.getPlayerState() ===
cast.framework.messages.PlayerState.PAUSED
);
}

static isBuffering(): boolean {
return this.playerManager.getPlayerState() === cast.framework.messages.PlayerState.BUFFERING;
return (
this.playerManager.getPlayerState() ===
cast.framework.messages.PlayerState.BUFFERING
);
}

static async playFromOptions(options: any): Promise<void> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static async playFromOptions(options: any): Promise<void> {
const firstItem = options.items[0];

if (options.startPositionTicks || firstItem.MediaType !== 'Video') {
Expand All @@ -109,7 +114,8 @@ export abstract class PlaybackManager {
return this.playFromOptionsInternal(options);
}

private static playFromOptionsInternal(options: any): Promise<void> { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private static playFromOptionsInternal(options: any): Promise<void> {
const stopPlayer =
this.activePlaylist && this.activePlaylist.length > 0;

Expand Down Expand Up @@ -143,22 +149,26 @@ export abstract class PlaybackManager {
return this.activePlaylistIndex > 0;
}

static playNextItem(options: any = {}, stopPlayer = false): boolean { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static playNextItem(options: any = {}, stopPlayer = false): boolean {
const nextItemInfo = this.getNextPlaybackItemInfo();

if (nextItemInfo) {
this.activePlaylistIndex = nextItemInfo.index;
this.playItem(options, stopPlayer);

return true;
}

return false;
}

static playPreviousItem(options: any = {}): boolean { // eslint-disable-line @typescript-eslint/no-explicit-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static playPreviousItem(options: any = {}): boolean {
if (this.activePlaylist && this.activePlaylistIndex > 0) {
this.activePlaylistIndex--;
this.playItem(options, true);

return true;
}

Expand All @@ -175,7 +185,9 @@ export abstract class PlaybackManager {
}

const item = this.activePlaylist[this.activePlaylistIndex];

console.log(`Playing index ${this.activePlaylistIndex}`, item);

return await onStopPlayerBeforePlaybackDone(item, options);
}

Expand Down Expand Up @@ -270,7 +282,9 @@ export abstract class PlaybackManager {
// If we should seek at the start, translate it
// to seconds and give it to loadRequestData :)
if (mediaInfo.customData.startPositionTicks > 0) {
loadRequestData.currentTime = ticksToSeconds(mediaInfo.customData.startPositionTicks);
loadRequestData.currentTime = ticksToSeconds(
mediaInfo.customData.startPositionTicks
);
}

load(mediaInfo.customData, item);
Expand Down
Loading

0 comments on commit db5eb70

Please sign in to comment.