File size: 1,110 Bytes
0d81ded
 
 
 
 
 
 
 
 
 
 
 
 
b16295e
0d81ded
 
 
 
 
 
b16295e
0d81ded
 
 
 
 
 
b9b84a7
0d81ded
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
};