mirror of
https://github.com/nexus-stc/hyperboria
synced 2025-01-10 18:56:03 +01:00
8e8a92f1b1
2 internal commit(s) GitOrigin-RevId: bdefcb9130693f1bc6c56d23d44fc4e41ff4672d
43 lines
904 B
JavaScript
43 lines
904 B
JavaScript
import dateFormat from 'dateformat'
|
|
|
|
export function getMegabytes (bytes) {
|
|
try {
|
|
if (bytes) {
|
|
return (bytes / (1024 * 1024)).toFixed(2) + ' Mb'
|
|
}
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
export function getIssuedDate (unixtime) {
|
|
if (!unixtime) return null
|
|
try {
|
|
return dateFormat(new Date(unixtime * 1000), 'yyyy')
|
|
} catch (e) {
|
|
console.error(e)
|
|
return null
|
|
}
|
|
}
|
|
|
|
export function getCoverUrl (cu, fictionId, libgenId, cuSuf, md5) {
|
|
if (cu) return cu
|
|
let r = ''
|
|
if (libgenId || fictionId) {
|
|
if (libgenId) {
|
|
const bulkId = (libgenId - (libgenId % 1000))
|
|
r = `covers/${bulkId}/${md5}`
|
|
} else if (fictionId) {
|
|
const bulkId = (fictionId - (fictionId % 1000))
|
|
r = `fictioncovers/${bulkId}/${md5}`
|
|
} else {
|
|
return null
|
|
}
|
|
}
|
|
if (cuSuf) {
|
|
r = r + `-${cuSuf}`
|
|
return `http://gen.lib.rus.ec/${r}.jpg`
|
|
}
|
|
return null
|
|
}
|