diff --git a/README.md b/README.md index ade0789..a57dc34 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# **Aruppi API** (v3.0.0) +# **Aruppi API** (v3.0.1) > This API has everything about Japan, from anime, music, radio, images, videos ... to japanese culture > diff --git a/package.json b/package.json index bc226fe..2a1b26e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aruppi", - "version": "3.0.0", + "version": "3.0.1", "description": "Aruppi is a custom API to obtain data from the Japanese culture for the mobile app", "main": "./src/api/api.js", "scripts": { diff --git a/src/utils/index.js b/src/utils/index.js index a6856a3..51de79c 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -134,24 +134,54 @@ const animeflvInfo = async (id) => { let $ = await homgot(`${BASE_ANIMEFLV}anime/${id}`, { scrapy: true }); let scripts = $('script').toArray(); - for (const pata in scripts) { - if (scripts[pata].children.length > 0) { - if (scripts[pata].children[0].data.includes('var episodes')){ - - let scriptInnerHTML = scripts[pata].children[0].data.trim() - const startIndex = scriptInnerHTML.indexOf('var episodes') + 'var episodes'.length - const endIndex = scriptInnerHTML.indexOf(';', startIndex) - - const episodesJSON = JSON.parse(scriptInnerHTML.substring(startIndex, endIndex).split('=')[1].trim()) - return episodesJSON.map(item => ({ - index: item[0], - id: `${item[1]}/${id}-${item[0]}`, - })) + const anime_info_ids = []; + const anime_eps_data = []; + + Array.from({length: scripts.length}, (v, k) => { + const $script = $(scripts[k]); + const contents = $script.html(); + if ((contents || '').includes('var anime_info = [')) { + let anime_info = contents.split('var anime_info = ')[1].split(';\n')[0]; + let dat_anime_info = JSON.parse(anime_info); + anime_info_ids.push(dat_anime_info); + } + if ((contents || '').includes('var episodes = [')) { + let episodes = contents.split('var episodes = ')[1].split(';')[0]; + let eps_data = JSON.parse(episodes) + anime_eps_data.push(eps_data); + } + }); + const animeId = id; + let nextEpisodeDate - } + if (anime_info_ids.length > 0) { + if (anime_info_ids[0].length === 4) { + nextEpisodeDate = anime_info_ids[0][3] + } else { + nextEpisodeDate = null } + } + const amimeTempList = []; + for (const [key, value] of Object.entries(anime_eps_data)) { + let episode = anime_eps_data[key].map(x => x[0]); + let episodeId = anime_eps_data[key].map(x => x[1]); + amimeTempList.push(episode, episodeId); } + const animeListEps = [{nextEpisodeDate: nextEpisodeDate}]; + Array.from({length: amimeTempList[1].length}, (v, k) => { + let data = amimeTempList.map(x => x[k]); + let episode = data[0]; + let id = data[1]; + let link = `${id}/${animeId}-${episode}` + + animeListEps.push({ + episode: episode, + id: link, + }) + }) + + return animeListEps };