2022-03-06 23:32:04 +01:00
|
|
|
const Logger = require('../Logger')
|
|
|
|
const iTunes = require('../providers/iTunes')
|
|
|
|
|
|
|
|
class PodcastFinder {
|
|
|
|
constructor() {
|
|
|
|
this.iTunesApi = new iTunes()
|
|
|
|
}
|
|
|
|
|
|
|
|
async search(term, options = {}) {
|
|
|
|
if (!term) return null
|
|
|
|
Logger.debug(`[iTunes] Searching for podcast with term "${term}"`)
|
2022-03-07 02:02:06 +01:00
|
|
|
var results = await this.iTunesApi.searchPodcasts(term, options)
|
2022-03-06 23:32:04 +01:00
|
|
|
Logger.debug(`[iTunes] Podcast search for "${term}" returned ${results.length} results`)
|
|
|
|
return results
|
|
|
|
}
|
2022-04-14 01:13:39 +02:00
|
|
|
|
|
|
|
async findCovers(term) {
|
|
|
|
if (!term) return null
|
|
|
|
Logger.debug(`[iTunes] Searching for podcast covers with term "${term}"`)
|
|
|
|
var results = await this.iTunesApi.searchPodcasts(term)
|
|
|
|
if (!results) return []
|
|
|
|
return results.map(r => r.cover).filter(r => r)
|
|
|
|
}
|
2022-03-06 23:32:04 +01:00
|
|
|
}
|
2023-09-04 23:33:55 +02:00
|
|
|
module.exports = new PodcastFinder()
|