mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-03 01:35:08 +02:00
Add:Podcast iTunes search api and iTunes provider
This commit is contained in:
parent
2a4cbd48b8
commit
43f48b65f8
7 changed files with 81 additions and 14 deletions
33
server/providers/iTunes.js
Normal file
33
server/providers/iTunes.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const axios = require('axios')
|
||||
const Logger = require('../Logger')
|
||||
|
||||
class iTunes {
|
||||
constructor() { }
|
||||
|
||||
// https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/iTuneSearchAPI/Searching.html
|
||||
search(options) {
|
||||
if (!options.term) {
|
||||
Logger.error('[iTunes] Invalid search options - no term')
|
||||
return []
|
||||
}
|
||||
var query = {
|
||||
term: options.term,
|
||||
media: options.media,
|
||||
entity: options.entity,
|
||||
lang: options.lang,
|
||||
limit: options.limit,
|
||||
country: options.country
|
||||
}
|
||||
console.log('Query', query)
|
||||
|
||||
return axios.get('https://itunes.apple.com/search', { params: query }).then((response) => {
|
||||
var data = response.data
|
||||
console.log('data', data)
|
||||
return data.results || []
|
||||
}).catch((error) => {
|
||||
Logger.error(`[iTunes] search request error`, error)
|
||||
return []
|
||||
})
|
||||
}
|
||||
}
|
||||
module.exports = iTunes
|
Loading…
Add table
Add a link
Reference in a new issue