Normalize to double quotes across all files with Prettier

This commit is contained in:
X4Lo committed 2026-06-21 22:28:08 +01:00
1 parent 73bff72cec
commit a5659cf4c8
190 files changed
+9523 -8859

No files matched your search

+9 -8
View File
@@ -1,22 +1,23 @@
import axios from 'axios';
import axios from "axios";
const API_BASE_URL = import.meta.env.VITE_ELECTRON === 'true'
? 'http://localhost:4000/api/v1'
: (import.meta.env.VITE_API_URL || '/api/v1');
const API_BASE_URL =
import.meta.env.VITE_ELECTRON === "true"
? "http://localhost:4000/api/v1"
: import.meta.env.VITE_API_URL || "/api/v1";
export const api = axios.create({
baseURL: API_BASE_URL,
headers: {
'Content-Type': 'application/json',
"Content-Type": "application/json",
},
});
export const getMediaUrl = (
category: string,
type: string,
size: 'preview' | 'full',
file: string
size: "preview" | "full",
file: string,
) => `${API_BASE_URL}/media/${category}/${type}/${size}/${file}`;
export const getTmdbImageUrl = (path: string, size = 'w342') =>
export const getTmdbImageUrl = (path: string, size = "w342") =>
`https://image.tmdb.org/t/p/${size}${path}`;
+37 -32
View File
@@ -1,29 +1,29 @@
import { getMediaUrl, getTmdbImageUrl } from '@/lib/api';
import type { Entry, Collection, Media } from '@/types';
import { getMediaUrl, getTmdbImageUrl } from "@/lib/api";
import type { Entry, Collection, Media } from "@/types";
const DEFAULT_POSTER = '/images/default-poster.png';
const DEFAULT_POSTER = "/images/default-poster.png";
export function getPosterUrl(entry: Entry): string {
// Not in library, use TMDB poster
if (!entry.isInLibrary) {
return entry.poster_path
? getTmdbImageUrl(entry.poster_path, 'w342')
? getTmdbImageUrl(entry.poster_path, "w342")
: DEFAULT_POSTER;
}
// In library: try local selected poster
if (entry.medias) {
const selectedPoster = entry.medias.find(
(m: Media) => m.type === 'poster' && m.is_selected
(m: Media) => m.type === "poster" && m.is_selected,
);
if (selectedPoster?.path) {
return getMediaUrl('entries', 'posters', 'preview', selectedPoster.path);
return getMediaUrl("entries", "posters", "preview", selectedPoster.path);
}
}
// Fallback to TMDB poster
if (entry.poster_path) {
return getTmdbImageUrl(entry.poster_path, 'w300');
return getTmdbImageUrl(entry.poster_path, "w300");
}
return DEFAULT_POSTER;
@@ -32,28 +32,23 @@ export function getPosterUrl(entry: Entry): string {
export function getBackdropUrl(entry: Entry): string {
if (entry.medias) {
const selectedBackdrop = entry.medias.find(
(m: Media) => m.type === 'backdrop' && m.is_selected
(m: Media) => m.type === "backdrop" && m.is_selected,
);
if (selectedBackdrop?.path) {
return getMediaUrl(
'entries',
'backdrops',
'full',
selectedBackdrop.path
);
return getMediaUrl("entries", "backdrops", "full", selectedBackdrop.path);
}
}
if (entry.banner_path) {
return getTmdbImageUrl(entry.banner_path, 'w1280');
return getTmdbImageUrl(entry.banner_path, "w1280");
}
return '';
return "";
}
export function getTmdbPosterUrl(
posterPath: string | null,
size = 'w342'
size = "w342",
): string {
if (!posterPath) return DEFAULT_POSTER;
return getTmdbImageUrl(posterPath, size);
@@ -62,14 +57,19 @@ export function getTmdbPosterUrl(
export function getCollectionBackdropUrl(collection: Collection): string {
if (collection.medias) {
const selectedBackdrop = collection.medias.find(
(m: Media) => m.type === 'backdrop' && m.is_selected
(m: Media) => m.type === "backdrop" && m.is_selected,
);
if (selectedBackdrop?.path) {
return getMediaUrl('collections', 'backdrops', 'full', selectedBackdrop.path);
return getMediaUrl(
"collections",
"backdrops",
"full",
selectedBackdrop.path,
);
}
}
if (collection.backdrop_path) {
return getTmdbImageUrl(collection.backdrop_path, 'w780');
return getTmdbImageUrl(collection.backdrop_path, "w780");
}
return getCollectionPosterUrl(collection);
}
@@ -77,42 +77,47 @@ export function getCollectionBackdropUrl(collection: Collection): string {
export function getCollectionPosterUrl(collection: Collection): string {
if (collection.medias) {
const selectedPoster = collection.medias.find(
(m: Media) => m.type === 'poster' && m.is_selected
(m: Media) => m.type === "poster" && m.is_selected,
);
if (selectedPoster?.path) {
return getMediaUrl('collections', 'posters', 'preview', selectedPoster.path);
return getMediaUrl(
"collections",
"posters",
"preview",
selectedPoster.path,
);
}
}
if (collection.poster_path) {
return getTmdbImageUrl(collection.poster_path, 'w342');
return getTmdbImageUrl(collection.poster_path, "w342");
}
return DEFAULT_POSTER;
}
export function getProfileUrl(profilePath: string | null): string {
if (!profilePath) return '/images/default-profile.png';
return getTmdbImageUrl(profilePath, 'w185');
if (!profilePath) return "/images/default-profile.png";
return getTmdbImageUrl(profilePath, "w185");
}
export function formatRuntime(minutes: number | null): string {
if (!minutes) return '';
if (!minutes) return "";
const h = Math.floor(minutes / 60);
const m = minutes % 60;
return h > 0 ? `${h}h ${m}m` : `${m}m`;
}
export function formatDate(dateStr: string | null): string {
if (!dateStr) return '';
return new Date(dateStr).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
if (!dateStr) return "";
return new Date(dateStr).toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "numeric",
});
}
export function getYear(dateStr: string | null): string {
if (!dateStr) return '';
if (!dateStr) return "";
return new Date(dateStr).getFullYear().toString();
}
+13 -2
View File
@@ -1,4 +1,15 @@
export type { StreamingProvider, StreamingServer, StreamRequest, StreamResponse, StreamError, PlayerEvent, WatchProgressData, AutoMarkWatchedConfig, StreamingState, MediaType } from './types';
export type {
StreamingProvider,
StreamingServer,
StreamRequest,
StreamResponse,
StreamError,
PlayerEvent,
WatchProgressData,
AutoMarkWatchedConfig,
StreamingState,
MediaType,
} from "./types";
export {
getAllServers,
getProviderForServer,
@@ -23,4 +34,4 @@ export {
isConsideredWatched,
isValidEmbedUrl,
isValidEventOrigin,
} from './streaming-manager';
} from "./streaming-manager";
@@ -1,42 +1,46 @@
import type { StreamingProvider, StreamingServer, StreamRequest } from '../types';
import type {
StreamingProvider,
StreamingServer,
StreamRequest,
} from "../types";
const ANYEMBED_SERVERS: StreamingServer[] = [
{
id: 'anyembed-1',
name: 'AnyEmbed (Server 1)',
provider: 'anyembed',
id: "anyembed-1",
name: "AnyEmbed (Server 1)",
provider: "anyembed",
serverIndex: 1,
supportsEvents: false,
supportsProgress: false,
},
{
id: 'anyembed-2',
name: 'AnyEmbed (Server 2)',
provider: 'anyembed',
id: "anyembed-2",
name: "AnyEmbed (Server 2)",
provider: "anyembed",
serverIndex: 2,
supportsEvents: false,
supportsProgress: false,
},
{
id: 'anyembed-3',
name: 'AnyEmbed (Server 3)',
provider: 'anyembed',
id: "anyembed-3",
name: "AnyEmbed (Server 3)",
provider: "anyembed",
serverIndex: 3,
supportsEvents: false,
supportsProgress: false,
},
{
id: 'anyembed-4',
name: 'AnyEmbed (Server 4)',
provider: 'anyembed',
id: "anyembed-4",
name: "AnyEmbed (Server 4)",
provider: "anyembed",
serverIndex: 4,
supportsEvents: false,
supportsProgress: false,
},
{
id: 'anyembed-5',
name: 'AnyEmbed (Server 5)',
provider: 'anyembed',
id: "anyembed-5",
name: "AnyEmbed (Server 5)",
provider: "anyembed",
serverIndex: 5,
supportsEvents: false,
supportsProgress: false,
@@ -44,8 +48,8 @@ const ANYEMBED_SERVERS: StreamingServer[] = [
];
export const anyembedProvider: StreamingProvider = {
id: 'anyembed',
name: 'AnyEmbed',
id: "anyembed",
name: "AnyEmbed",
servers: ANYEMBED_SERVERS,
getStreamUrl(request: StreamRequest, server: StreamingServer): string {
@@ -53,7 +57,7 @@ export const anyembedProvider: StreamingProvider = {
const id = request.imdbId || String(request.tmdbId);
let basePath: string;
if (request.type === 'movie') {
if (request.type === "movie") {
basePath = `/movie/${id}`;
} else {
basePath = `/tv/${id}/${request.season}/${request.episode}`;
@@ -61,18 +65,18 @@ export const anyembedProvider: StreamingProvider = {
const params = new URLSearchParams();
if (server.serverIndex) {
params.set('server', String(server.serverIndex));
params.set("server", String(server.serverIndex));
}
const query = params.toString();
return `https://anyembed.xyz${basePath}${query ? `?${query}` : ''}`;
return `https://anyembed.xyz${basePath}${query ? `?${query}` : ""}`;
},
getSandboxPolicy(): string {
return 'allow-scripts allow-same-origin allow-forms allow-popups allow-presentation';
return "allow-scripts allow-same-origin allow-forms allow-popups allow-presentation";
},
getAllowedFeatures(): string {
return 'autoplay; fullscreen; picture-in-picture; encrypted-media';
return "autoplay; fullscreen; picture-in-picture; encrypted-media";
},
};
@@ -1,3 +1,3 @@
export { vidlinkProvider } from './vidlink';
export { vidkingProvider } from './vidking';
export { anyembedProvider } from './anyembed';
export { vidlinkProvider } from "./vidlink";
export { vidkingProvider } from "./vidking";
export { anyembedProvider } from "./anyembed";
@@ -1,32 +1,36 @@
import type { StreamingProvider, StreamingServer, StreamRequest } from '../types';
import type {
StreamingProvider,
StreamingServer,
StreamRequest,
} from "../types";
const VIDKING_SERVERS: StreamingServer[] = [
{
id: 'vidking-default',
name: 'VidKing',
provider: 'vidking',
id: "vidking-default",
name: "VidKing",
provider: "vidking",
supportsEvents: true,
supportsProgress: true,
},
];
export const vidkingProvider: StreamingProvider = {
id: 'vidking',
name: 'VidKing',
id: "vidking",
name: "VidKing",
servers: VIDKING_SERVERS,
getStreamUrl(request: StreamRequest, _server: StreamingServer): string {
const params = new URLSearchParams();
params.set('autoPlay', 'true');
params.set('nextEpisode', 'true');
params.set('episodeSelector', 'true');
params.set("autoPlay", "true");
params.set("nextEpisode", "true");
params.set("episodeSelector", "true");
if (request.startAt && request.startAt > 0) {
params.set('progress', String(Math.floor(request.startAt)));
params.set("progress", String(Math.floor(request.startAt)));
}
let basePath: string;
if (request.type === 'movie') {
if (request.type === "movie") {
basePath = `/embed/movie/${request.tmdbId}`;
} else {
basePath = `/embed/tv/${request.tmdbId}/${request.season}/${request.episode}`;
@@ -36,10 +40,10 @@ export const vidkingProvider: StreamingProvider = {
},
getSandboxPolicy(): string {
return 'allow-scripts allow-same-origin allow-forms allow-popups allow-presentation';
return "allow-scripts allow-same-origin allow-forms allow-popups allow-presentation";
},
getAllowedFeatures(): string {
return 'autoplay; fullscreen; picture-in-picture; encrypted-media';
return "autoplay; fullscreen; picture-in-picture; encrypted-media";
},
};
@@ -1,17 +1,21 @@
import type { StreamingProvider, StreamingServer, StreamRequest } from '../types';
import type {
StreamingProvider,
StreamingServer,
StreamRequest,
} from "../types";
const VIDLINK_SERVERS: StreamingServer[] = [
{
id: 'vidlink-default',
name: 'VidLink (Default)',
provider: 'vidlink',
id: "vidlink-default",
name: "VidLink (Default)",
provider: "vidlink",
supportsEvents: true,
supportsProgress: true,
},
{
id: 'vidlink-jw',
name: 'VidLink (JW Player)',
provider: 'vidlink',
id: "vidlink-jw",
name: "VidLink (JW Player)",
provider: "vidlink",
serverIndex: 2,
supportsEvents: true,
supportsProgress: true,
@@ -19,27 +23,27 @@ const VIDLINK_SERVERS: StreamingServer[] = [
];
export const vidlinkProvider: StreamingProvider = {
id: 'vidlink',
name: 'VidLink',
id: "vidlink",
name: "VidLink",
servers: VIDLINK_SERVERS,
getStreamUrl(request: StreamRequest, server: StreamingServer): string {
const params = new URLSearchParams();
params.set('autoplay', 'true');
params.set('title', 'false');
params.set('poster', 'true');
params.set('nextbutton', 'true');
params.set("autoplay", "true");
params.set("title", "false");
params.set("poster", "true");
params.set("nextbutton", "true");
if (server.serverIndex === 2) {
params.set('player', 'jw');
params.set("player", "jw");
}
if (request.startAt && request.startAt > 0) {
params.set('startAt', String(Math.floor(request.startAt)));
params.set("startAt", String(Math.floor(request.startAt)));
}
let basePath: string;
if (request.type === 'movie') {
if (request.type === "movie") {
basePath = `/movie/${request.tmdbId}`;
} else {
basePath = `/tv/${request.tmdbId}/${request.season}/${request.episode}`;
@@ -49,10 +53,10 @@ export const vidlinkProvider: StreamingProvider = {
},
getSandboxPolicy(): string {
return 'allow-scripts allow-same-origin allow-forms allow-popups allow-presentation';
return "allow-scripts allow-same-origin allow-forms allow-popups allow-presentation";
},
getAllowedFeatures(): string {
return 'autoplay; fullscreen; picture-in-picture; encrypted-media';
return "autoplay; fullscreen; picture-in-picture; encrypted-media";
},
};
@@ -7,15 +7,19 @@ import type {
WatchProgressData,
AutoMarkWatchedConfig,
PlayerEvent,
} from './types';
import { vidlinkProvider, vidkingProvider, anyembedProvider } from './providers';
} from "./types";
import {
vidlinkProvider,
vidkingProvider,
anyembedProvider,
} from "./providers";
const STORAGE_KEYS = {
PREFERRED_SERVER: 'showy_preferred_server',
WATCH_PROGRESS: 'showy_watch_progress',
AUTO_MARK_WATCHED: 'showy_auto_mark_watched',
AUTO_MARK_PROMPT_SHOWN: 'showy_auto_mark_prompt_shown',
WATCH_LOGS: 'showy_watch_logs',
PREFERRED_SERVER: "showy_preferred_server",
WATCH_PROGRESS: "showy_watch_progress",
AUTO_MARK_WATCHED: "showy_auto_mark_watched",
AUTO_MARK_PROMPT_SHOWN: "showy_auto_mark_prompt_shown",
WATCH_LOGS: "showy_watch_logs",
} as const;
/** All registered streaming providers */
@@ -31,7 +35,9 @@ export function getAllServers(): StreamingServer[] {
}
/** Get a provider by server ID */
export function getProviderForServer(serverId: string): StreamingProvider | undefined {
export function getProviderForServer(
serverId: string,
): StreamingProvider | undefined {
return providers.find((p) => p.servers.some((s) => s.id === serverId));
}
@@ -41,13 +47,16 @@ export function getServerById(serverId: string): StreamingServer | undefined {
}
/** Build a stream URL for the given request and server */
export function getStreamUrl(request: StreamRequest, server: StreamingServer): StreamResponse | StreamError {
export function getStreamUrl(
request: StreamRequest,
server: StreamingServer,
): StreamResponse | StreamError {
const provider = getProviderForServer(server.id);
if (!provider) {
return {
server,
message: 'Provider not found for this server',
code: 'UNAVAILABLE',
message: "Provider not found for this server",
code: "UNAVAILABLE",
};
}
@@ -55,16 +64,16 @@ export function getStreamUrl(request: StreamRequest, server: StreamingServer): S
if (!request.tmdbId && !request.imdbId) {
return {
server,
message: 'A valid TMDB or IMDB ID is required',
code: 'INVALID_ID',
message: "A valid TMDB or IMDB ID is required",
code: "INVALID_ID",
};
}
if (request.type === 'tv' && (!request.season || !request.episode)) {
if (request.type === "tv" && (!request.season || !request.episode)) {
return {
server,
message: 'Season and episode numbers are required for TV shows',
code: 'MISSING_EPISODE',
message: "Season and episode numbers are required for TV shows",
code: "MISSING_EPISODE",
};
}
@@ -74,27 +83,29 @@ export function getStreamUrl(request: StreamRequest, server: StreamingServer): S
} catch {
return {
server,
message: 'Failed to build stream URL',
code: 'UNKNOWN',
message: "Failed to build stream URL",
code: "UNKNOWN",
};
}
}
/** Check if a response is an error */
export function isStreamError(result: StreamResponse | StreamError): result is StreamError {
return 'code' in result;
export function isStreamError(
result: StreamResponse | StreamError,
): result is StreamError {
return "code" in result;
}
/** Get iframe sandbox policy for a server */
export function getServerSandboxPolicy(serverId: string): string {
const provider = getProviderForServer(serverId);
return provider?.getSandboxPolicy() ?? 'allow-scripts allow-same-origin';
return provider?.getSandboxPolicy() ?? "allow-scripts allow-same-origin";
}
/** Get iframe allowed features for a server */
export function getServerAllowedFeatures(serverId: string): string {
const provider = getProviderForServer(serverId);
return provider?.getAllowedFeatures() ?? 'autoplay; fullscreen';
return provider?.getAllowedFeatures() ?? "autoplay; fullscreen";
}
// --- Persistence ---
@@ -140,7 +151,9 @@ export function getWatchProgress(): Record<string, WatchProgressData> {
}
/** Get watch progress for a specific entry */
export function getEntryWatchProgress(tmdbId: number): WatchProgressData | null {
export function getEntryWatchProgress(
tmdbId: number,
): WatchProgressData | null {
const progress = getWatchProgress();
return progress[String(tmdbId)] || null;
}
@@ -165,7 +178,7 @@ function getEpisodeKey(season: number, episode: number): string {
export function updateProgressFromEvent(
event: PlayerEvent,
title: string,
posterPath?: string
posterPath?: string,
): void {
const existing = getEntryWatchProgress(event.tmdbId);
@@ -180,7 +193,7 @@ export function updateProgressFromEvent(
...(existing?.showProgress ? { showProgress: existing.showProgress } : {}),
};
if (event.mediaType === 'tv' && event.season && event.episode) {
if (event.mediaType === "tv" && event.season && event.episode) {
data.lastSeasonWatched = event.season;
data.lastEpisodeWatched = event.episode;
const key = getEpisodeKey(event.season, event.episode);
@@ -213,7 +226,10 @@ export function getAutoMarkWatchedConfig(): AutoMarkWatchedConfig {
/** Save auto-mark-watched config */
export function setAutoMarkWatchedConfig(config: AutoMarkWatchedConfig): void {
try {
localStorage.setItem(STORAGE_KEYS.AUTO_MARK_WATCHED, JSON.stringify(config));
localStorage.setItem(
STORAGE_KEYS.AUTO_MARK_WATCHED,
JSON.stringify(config),
);
} catch {
// Storage not available
}
@@ -222,7 +238,7 @@ export function setAutoMarkWatchedConfig(config: AutoMarkWatchedConfig): void {
/** Check if the auto-mark prompt has been shown */
export function hasAutoMarkPromptBeenShown(): boolean {
try {
return localStorage.getItem(STORAGE_KEYS.AUTO_MARK_PROMPT_SHOWN) === 'true';
return localStorage.getItem(STORAGE_KEYS.AUTO_MARK_PROMPT_SHOWN) === "true";
} catch {
return false;
}
@@ -231,7 +247,7 @@ export function hasAutoMarkPromptBeenShown(): boolean {
/** Mark that the auto-mark prompt has been shown */
export function markAutoMarkPromptShown(): void {
try {
localStorage.setItem(STORAGE_KEYS.AUTO_MARK_PROMPT_SHOWN, 'true');
localStorage.setItem(STORAGE_KEYS.AUTO_MARK_PROMPT_SHOWN, "true");
} catch {
// Storage not available
}
@@ -241,7 +257,7 @@ export function markAutoMarkPromptShown(): void {
interface WatchLog {
tmdbId: number;
type: 'movie' | 'tv';
type: "movie" | "tv";
title: string;
season?: number;
episode?: number;
@@ -274,7 +290,11 @@ export function getWatchLogs(): WatchLog[] {
}
/** Check if an episode/movie is considered "watched" based on progress */
export function isConsideredWatched(watched: number, duration: number, threshold = 90): boolean {
export function isConsideredWatched(
watched: number,
duration: number,
threshold = 90,
): boolean {
if (duration <= 0) return false;
const percent = (watched / duration) * 100;
return percent >= threshold;
@@ -283,9 +303,9 @@ export function isConsideredWatched(watched: number, duration: number, threshold
// --- URL Validation ---
const ALLOWED_ORIGINS = [
'https://vidlink.pro',
'https://www.vidking.net',
'https://anyembed.xyz',
"https://vidlink.pro",
"https://www.vidking.net",
"https://anyembed.xyz",
];
/** Validate that an embed URL is from an allowed origin */
+18 -9
View File
@@ -1,6 +1,6 @@
// Streaming system types
export type MediaType = 'movie' | 'tv';
export type MediaType = "movie" | "tv";
export interface StreamingServer {
id: string;
@@ -34,11 +34,17 @@ export interface StreamResponse {
export interface StreamError {
server: StreamingServer;
message: string;
code: 'INVALID_ID' | 'MISSING_EPISODE' | 'TIMEOUT' | 'NETWORK' | 'UNAVAILABLE' | 'UNKNOWN';
code:
| "INVALID_ID"
| "MISSING_EPISODE"
| "TIMEOUT"
| "NETWORK"
| "UNAVAILABLE"
| "UNKNOWN";
}
export interface PlayerEvent {
event: 'play' | 'pause' | 'seeked' | 'ended' | 'timeupdate';
event: "play" | "pause" | "seeked" | "ended" | "timeupdate";
currentTime: number;
duration: number;
mediaType: MediaType;
@@ -61,12 +67,15 @@ export interface WatchProgressData {
lastSeasonWatched?: number;
lastEpisodeWatched?: number;
/** Per-episode progress for TV shows */
showProgress?: Record<string, {
season: number;
episode: number;
watched: number;
duration: number;
}>;
showProgress?: Record<
string,
{
season: number;
episode: number;
watched: number;
duration: number;
}
>;
lastUpdated: number;
}
+3 -3
View File
@@ -1,6 +1,6 @@
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
return twMerge(clsx(inputs));
}