-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Valkyr-JS/initial-build
Initial build
- Loading branch information
Showing
28 changed files
with
9,189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# plugin-performer-popular-meta | ||
Displays metadata about frequent scene partners, most prominent tags, etc., on performer pages in Stash. | ||
# Performer Details Extended | ||
A plugin for Stash. Displays metadata about frequent scene partners, most prominent tags, etc. in your library, on performer pages. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** Converts the given seconds into a uniform string showing an amount of time. | ||
* */ | ||
export const createDuration = (seconds: number): string => { | ||
const inMinutes = Math.floor(seconds / 60); | ||
const inHours = Math.floor(inMinutes / 60); | ||
const inDays = Math.floor(inHours / 24); | ||
|
||
let output = ""; | ||
|
||
const totalHours = inHours % 60; | ||
const totalMinutes = inMinutes % 60; | ||
const totalSeconds = seconds % 60; | ||
|
||
if (inDays > 0) output += inDays + " days "; | ||
if (!!totalHours || !!output.length) output += totalHours + "h "; | ||
if (!!totalMinutes || !!output.length) output += totalMinutes + "m "; | ||
|
||
// Round down to match native | ||
output += Math.floor(totalSeconds) + "s "; | ||
|
||
return output; | ||
}; | ||
|
||
/** Converts the given bytes into a uniform string showing a filesize, from | ||
* bytes to terabytes. */ | ||
export const createFilesize = (bytes: number): string => { | ||
const b = roundToTwo(bytes); | ||
const kb = roundToTwo(bytes / 1024); | ||
if (kb < 1) return b + "B"; | ||
const mb = roundToTwo(kb / 1024); | ||
if (mb < 1) return kb + "KB"; | ||
const gb = roundToTwo(mb / 1024); | ||
if (gb < 1) return mb + "MB"; | ||
const tb = roundToTwo(gb / 1024); | ||
if (tb < 1) return gb + "GB"; | ||
return tb + "TB"; | ||
}; | ||
|
||
/** Returns the associated string GenderEnum as a human-readable value. */ | ||
export const getGenderFromEnum = (gender: GenderEnum): string | null => { | ||
switch (gender) { | ||
case "MALE": | ||
return "Male"; | ||
case "FEMALE": | ||
return "Female"; | ||
case "TRANSGENDER_MALE": | ||
return "Transgender male"; | ||
case "TRANSGENDER_FEMALE": | ||
return "Transgender female"; | ||
case "INTERSEX": | ||
return "Intersex"; | ||
case "NON_BINARY": | ||
return "Non-binary"; | ||
} | ||
return null; | ||
}; | ||
|
||
/** Round the provided number to two decimal places. */ | ||
const roundToTwo = (number: number): number => | ||
Math.round((number + Number.EPSILON) * 100) / 100; |
Oops, something went wrong.