itunes-web-api
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "itunes-web-api", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "iTunes WEB API Scrapper", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,8 +0,9 @@ | ||
## WELCOME TO ITUNES API MODULE! BUGS ARE FIXED SORRY FOR THAT (IF U ARE USING VER 1.0.2 or LOWER PLS UPDATE YOUR MODULE) | ||
#### EXAMPLE USES TO GET REQUIRED INFORMATION; | ||
## WELCOME TO ITUNES WEB API! | ||
## WARNING!! (IF U ARE USING VER 1.0.3 or LOWER PLEASE UPDATE YOUR MODULE) | ||
### EXAMPLE FOR NEW VERSION (OPTIONS UPDATE) | ||
### NOTE: OPTIONS ARE OPTIONAL NOT NECESSARY | ||
````js | ||
//##### USAGE FOR TRACK INFO #####\\ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.track(songName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.track(songName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data)//track infos in resulst array | ||
@@ -13,3 +14,3 @@ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.album(albumName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.album(albumName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data) //album infos in resulst array | ||
@@ -20,3 +21,3 @@ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.app(songName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.app(songName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data)//app infos in resulst array | ||
@@ -27,3 +28,3 @@ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.movie(movieName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.movie(movieName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data)//movie infos in resulst array | ||
@@ -34,3 +35,3 @@ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.book(bookName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.book(bookName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data)//book infos in resulst array | ||
@@ -41,3 +42,3 @@ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.voicebook(voicebookName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.voicebook(voicebookName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data)//voice-book infos in resulst array | ||
@@ -48,3 +49,3 @@ | ||
const itunes = require('itunes-api'); | ||
let data = await itunes.voicebook(voicebookName, limit(optional), lang(optional), country(optional)) | ||
let data = await itunes.voicebook(voicebookName, {limit: Number, lang: 'lang-code', country: 'country-code'}) | ||
console.log(data)//podcast infos in resulst array | ||
@@ -51,0 +52,0 @@ ```` |
const fetch = require("node-fetch"); | ||
module.exports = { | ||
async track(songName, limit, lang, country){ | ||
if(!songName) return console.log('You must enter a Valid Song Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(songName)}&media=music&limit=${limit}&lang=${lang}&country=${country}`); | ||
async track(songName, options = {}){ | ||
if(!songName) return console.log('ERROR: You must enter a Valid Song Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(songName)}&media=music&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This Song is doesn't exist."); | ||
console.error("ERROR: This Song is doesn't exist."); | ||
return undefined; | ||
@@ -21,11 +24,14 @@ } | ||
}, | ||
async album(albumName, limit, lang, country){ | ||
if(!albumName) return console.log('You must enter a Valid Album Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(albumName)}&entity=album&limit=${limit}&lang=${lang}&country=${country}`); | ||
async album(albumName, options = {}){ | ||
if(!albumName) return console.log('ERROR: You must enter a Valid Album Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(albumName)}&entity=album&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This Album is doesn't exist."); | ||
console.error("ERROR: This Album is doesn't exist."); | ||
return undefined; | ||
@@ -39,11 +45,14 @@ } | ||
}, | ||
async app(appName, limit, lang, country){ | ||
if(!appName) return console.log('You must enter a Valid App Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(appName)}&entity=software&limit=${limit}&lang=${lang}&country=${country}`); | ||
async app(appName, options = {}){ | ||
if(!appName) return console.log('ERROR: You must enter a Valid App Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(appName)}&entity=software&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This App is doesn't exist."); | ||
console.error("ERROR: This App is doesn't exist."); | ||
return undefined; | ||
@@ -57,11 +66,14 @@ } | ||
}, | ||
async movie(movieName, limit, lang, country){ | ||
if(!movieName) return console.log('You must enter a Valid Movie Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(movieName)}&entity=movie&limit=${limit}&lang=${lang}&country=${country}`); | ||
async movie(movieName, options = {}){ | ||
if(!movieName) return console.log('ERROR: You must enter a Valid Movie Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(movieName)}&entity=movie&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This Movie is doesn't exist."); | ||
console.error("ERROR: This Movie is doesn't exist."); | ||
return undefined; | ||
@@ -75,11 +87,14 @@ } | ||
}, | ||
async book(bookName, limit, lang, country){ | ||
if(!bookName) return console.log('You must enter a Valid Book Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(bookName)}&entity=ebook&limit=${limit}&lang=${lang}&country=${country}`); | ||
async book(bookName, options = {}){ | ||
if(!bookName) return console.log('ERROR: You must enter a Valid Book Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(bookName)}&entity=ebook&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This Book is doesn't exist."); | ||
console.error("ERROR: This Book is doesn't exist."); | ||
return undefined; | ||
@@ -93,11 +108,14 @@ } | ||
}, | ||
async voicebook(voicebookName, limit, lang, country){ | ||
if(!voicebookName) return console.log('You must enter a Valid Voice Book Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(voicebookName)}&entity=audiobook&limit=${limit}&lang=${lang}&country=${country}`); | ||
async voicebook(voicebookName, options = {}){ | ||
if(!voicebookName) return console.log('ERROR: You must enter a Valid Voice Book Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(voicebookName)}&entity=audiobook&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This Voice Book is doesn't exist."); | ||
console.error("ERROR: This Voice Book is doesn't exist."); | ||
return undefined; | ||
@@ -111,11 +129,14 @@ } | ||
}, | ||
async podcast(podcastName, limit, lang, country){ | ||
if(!podcastName) return console.log('You must enter a Valid Podcast Name Name!') | ||
if(!limit || limit === null || limit === undefined || limit === 0) limit = 1 | ||
if(!lang || lang === null || lang === undefined || lang === 0) lang = 'en' | ||
if(!country || country === null || country === undefined || country === 0) country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(podcastName)}&entity=podcast&limit=${limit}&lang=${lang}&country=${country}`); | ||
async podcast(podcastName, options = {}){ | ||
if(!podcastName) return console.log('ERROR: You must enter a Valid Podcast Name!') | ||
if(options.limit > 200) return console.log("ERROR: Limit number cannot be more than 200.") | ||
if(!options.limit || options.limit === null || options.limit === undefined || options.limit === 0) options.limit = 1 | ||
if(isNaN(options.lang) === false) return console.log("ERROR: Language cannot be number.") | ||
if(!options.lang || options.lang === null || options.lang === undefined || options.lang === 0) options.lang = 'en' | ||
if(isNaN(options.country) === false) return console.log("ERROR: Country cannot be number.") | ||
if(!options.country || options.country === null || options.country === undefined || options.country === 0) options.country = 'US' | ||
const res = await fetch(`https://itunes.apple.com/search?term=${encodeURI(podcastName)}&entity=podcast&limit=${options.limit}&lang=${options.lang}&country=${options.country}`); | ||
const response = await res.json(); | ||
if(response.resultCount === 0) { | ||
console.error("This Podcast Name is doesn't exist."); | ||
console.error("ERROR: This Podcast is doesn't exist."); | ||
return undefined; | ||
@@ -122,0 +143,0 @@ } |
const itunes = require('itunes-web-api'); | ||
(async() => { | ||
let data = await itunes.track('Lil Nas Rodeo') | ||
let data = await itunes.track('Lil Nas Rodeo', {limit: 1, lang: 'en', country: 'US'}) | ||
console.log(data)})() |
14662
145
95