mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-24 20:59:38 +00:00
Remove LibGen provider and package
This commit is contained in:
parent
354cefb9f4
commit
6fc70b8656
4 changed files with 5 additions and 2247 deletions
|
|
@ -1,57 +0,0 @@
|
|||
var libgen = require('libgen')
|
||||
|
||||
class LibGen {
|
||||
constructor() {
|
||||
this.mirror = null
|
||||
}
|
||||
|
||||
async init() {
|
||||
this.mirror = await libgen.mirror()
|
||||
console.log(`${this.mirror} is currently fastest`)
|
||||
}
|
||||
|
||||
async search(queryTitle) {
|
||||
if (!this.mirror) {
|
||||
await this.init()
|
||||
}
|
||||
queryTitle = queryTitle.replace(/'/g, '')
|
||||
queryTitle = encodeURIComponent(queryTitle);
|
||||
var options = {
|
||||
mirror: this.mirror,
|
||||
query: queryTitle,
|
||||
search_in: 'title'
|
||||
}
|
||||
var httpsMirror = this.mirror
|
||||
if (httpsMirror.startsWith('http:')) {
|
||||
httpsMirror = httpsMirror.replace('http:', 'https:')
|
||||
}
|
||||
// console.log('LibGen Search Options', options)
|
||||
try {
|
||||
const data = await libgen.search(options)
|
||||
let n = data.length
|
||||
// console.log(`${n} results for "${options.query}"`)
|
||||
var cleanedResults = []
|
||||
while (n--) {
|
||||
var resultObj = {
|
||||
id: data[n].id,
|
||||
title: data[n].title,
|
||||
author: data[n].author,
|
||||
publisher: data[n].publisher,
|
||||
description: data[n].descr,
|
||||
cover: `${httpsMirror}/covers/${data[n].coverurl}`,
|
||||
year: data[n].year
|
||||
}
|
||||
if (!resultObj.title) continue;
|
||||
cleanedResults.push(resultObj)
|
||||
}
|
||||
return cleanedResults
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
return {
|
||||
errorCode: 500
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LibGen
|
||||
Loading…
Add table
Add a link
Reference in a new issue