ChandimaPrabath's picture
player patch
b16295e
export const getFileNameWithoutExtension = (episodeFile) => {
if (!episodeFile) return null;
// Regular expression to match the file extension and common video quality suffixes
const regex = /\s*(HDTV-720p|HDTV-1080p|HDTV|720p|1080p|WEB-DL|WEBRip|BluRay|BRRip|DVDRip|CAM|TS|HDRip|BDRip|DVDScr)?(\.[^.]+)?$/i;
// Remove the matched part (file extension and video quality suffixes if present)
return episodeFile.replace(regex, '').trim();
};
export const formatTime = (seconds) => {
if (isNaN(seconds)) {
return "0:00:00";
}
const wholeSeconds = Math.floor(seconds);
const hours = Math.floor(wholeSeconds / 3600);
const minutes = Math.floor((wholeSeconds % 3600) / 60);
const secs = wholeSeconds % 60;
const formattedHours = String(hours).padStart(1, "0");
const formattedMinutes = String(minutes).padStart(2, "0");
const formattedSeconds = String(secs).padStart(2, "0");
return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`;
};
export const getStorageKey = (type, title, episode) => {
return type === "tvshow" ? `${episode}` : title;
};