@ -6,7 +6,6 @@ const {
homgot
homgot
} = require ( '../api/apiCall' ) ;
} = require ( '../api/apiCall' ) ;
function btoa ( str ) {
function btoa ( str ) {
let buffer ;
let buffer ;
if ( str instanceof Buffer ) {
if ( str instanceof Buffer ) {
@ -26,11 +25,11 @@ async function videoServersJK(id) {
const $ = await homgot ( ` ${ BASE _JKANIME } ${ id } ` , options ) ;
const $ = await homgot ( ` ${ BASE _JKANIME } ${ id } ` , options ) ;
const scripts = $ ( 'script' ) ;
const scripts = $ ( 'script' ) ;
const totalEps = $ ( 'div#container div#reproductor-box div ul li' ) . length ;
const episodes = $ ( 'div#reproductor-box li' ) ;
const serverNames = [ ] ;
const serverNames = [ ] ;
let servers = [ ] ;
let servers = [ ] ;
$( 'div#container div#reproductor-box div ul li' ) . each ( ( index , element ) => {
episodes . each ( ( index , element ) => {
const $element = $ ( element ) ;
const $element = $ ( element ) ;
const serverName = $element . find ( 'a' ) . text ( ) ;
const serverName = $element . find ( 'a' ) . text ( ) ;
serverNames . push ( serverName ) ;
serverNames . push ( serverName ) ;
@ -40,9 +39,8 @@ async function videoServersJK(id) {
const $script = $ ( scripts [ i ] ) ;
const $script = $ ( scripts [ i ] ) ;
const contents = $script . html ( ) ;
const contents = $script . html ( ) ;
try {
try {
if ( ( contents || '' ) . includes ( 'var video = [];' ) ) {
if ( ( contents || '' ) . includes ( 'var video = [];' ) ) {
Array . from ( { length : totalEps } , ( v , k ) => {
Array . from ( { length : episodes. length } , ( v , k ) => {
let index = Number ( k + 1 ) ;
let index = Number ( k + 1 ) ;
let videoPageURL = contents . split ( ` video[ ${ index } ] = \' <iframe class="player_conte" src=" ` ) [ 1 ] . split ( '"' ) [ 0 ] ;
let videoPageURL = contents . split ( ` video[ ${ index } ] = \' <iframe class="player_conte" src=" ` ) [ 1 ] . split ( '"' ) [ 0 ] ;
servers . push ( { iframe : videoPageURL } ) ;
servers . push ( { iframe : videoPageURL } ) ;
@ -52,24 +50,17 @@ async function videoServersJK(id) {
return null ;
return null ;
}
}
}
}
let serverList = [ ] ;
let serverList = [ ] ;
let serverTempList = [ ] ;
for ( let server in servers ) {
for ( const [ key , value ] of Object . entries ( servers ) ) {
let video = await getVideoURL ( value . iframe )
serverTempList . push ( video ) ;
}
Array . from ( { length : serverTempList . length } , ( v , k ) => {
let name = serverNames [ k ] ;
let video = serverTempList [ k ] ;
serverList . push ( {
serverList . push ( {
id : name . toLowerCase ( ) ,
id : serverNames [ server ] . toLowerCase ( ) ,
url : video ,
url : await getVideoURL ( servers [ server ] . iframe ) ,
direct : true
direct : true
} ) ;
} ) ;
} ) ;
}
serverList = serverList . filter ( function ( obj ) {
return obj . id !== 'xtreme s' ;
serverList = serverList . filter ( x => x . id !== 'xtreme s' && x . id !== 'desuka' ) ;
} ) ;
return await Promise . all ( serverList ) ;
return await Promise . all ( serverList ) ;
}
}
@ -304,127 +295,145 @@ const animeflvInfo = async (id, index) => {
const getAnimeCharacters = async ( title ) => {
const getAnimeCharacters = async ( title ) => {
let options = { parse : true }
try {
let options = { parse : true }
const res = await homgot ( ` ${ BASE _JIKAN } search/anime?q= ${ title } ` , options ) ;
const res = await homgot ( ` ${ BASE _JIKAN } search/anime?q= ${ title } ` , options ) ;
const matchAnime = res . results . filter ( x => x . title === title ) ;
const matchAnime = res . results . filter ( x => x . title === title ) ;
const malId = matchAnime [ 0 ] . mal _id ;
const malId = matchAnime [ 0 ] . mal _id ;
if ( typeof matchAnime [ 0 ] . mal _id === 'undefined' ) return null ;
if ( typeof matchAnime [ 0 ] . mal _id === 'undefined' ) return null ;
const data = await homgot ( ` ${ BASE _JIKAN } anime/ ${ malId } /characters_staff ` , options ) ;
const data = await homgot ( ` ${ BASE _JIKAN } anime/ ${ malId } /characters_staff ` , options ) ;
let body = data . characters ;
let body = data . characters ;
if ( typeof body === 'undefined' ) return null ;
if ( typeof body === 'undefined' ) return null ;
const charactersId = body . map ( doc => {
const charactersId = body . map ( doc => {
return doc . mal _id
return doc . mal _id
} )
} )
const charactersNames = body . map ( doc => {
const charactersNames = body . map ( doc => {
return doc . name ;
return doc . name ;
} ) ;
} ) ;
const charactersImages = body . map ( doc => {
const charactersImages = body . map ( doc => {
return doc . image _url
return doc . image _url
} ) ;
} ) ;
let characters = [ ] ;
let characters = [ ] ;
Array . from ( { length : charactersNames . length } , ( v , k ) => {
Array . from ( { length : charactersNames . length } , ( v , k ) => {
const id = charactersId [ k ] ;
const id = charactersId [ k ] ;
let name = charactersNames [ k ] ;
let name = charactersNames [ k ] ;
let characterImg = charactersImages [ k ] ;
let characterImg = charactersImages [ k ] ;
characters . push ( {
characters . push ( {
id : id ,
id : id ,
name : name ,
name : name ,
image : characterImg
image : characterImg
} ) ;
} ) ;
} ) ;
} ) ;
return Promise . all ( characters ) ;
return Promise . all ( characters ) ;
} catch ( e ) {
console . log ( e . message )
}
} ;
} ;
const getAnimeVideoPromo = async ( title ) => {
const getAnimeVideoPromo = async ( title ) => {
let options = { parse : true }
try {
const res = await homgot ( ` ${ BASE _JIKAN } search/anime?q= ${ title } ` , options ) ;
let options = { parse : true }
const matchAnime = res . results . filter ( x => x . title === title ) ;
const res = await homgot ( ` ${ BASE _JIKAN } search/anime?q= ${ title } ` , options ) ;
const malId = matchAnime [ 0 ] . mal _id ;
const matchAnime = res . results . filter ( x => x . title === title ) ;
const malId = matchAnime [ 0 ] . mal _id ;
if ( typeof matchAnime [ 0 ] . mal _id === 'undefined' ) return null ;
if ( typeof matchAnime [ 0 ] . mal _id === 'undefined' ) return null ;
const data = await homgot ( ` ${ BASE _JIKAN } anime/ ${ malId } /videos ` , options ) ;
const data = await homgot ( ` ${ BASE _JIKAN } anime/ ${ malId } /videos ` , options ) ;
const body = data . promo ;
const body = data . promo ;
const promises = [ ] ;
const promises = [ ] ;
body . map ( doc => {
body . map ( doc => {
promises . push ( {
promises . push ( {
title : doc . title ,
title : doc . title ,
previewImage : doc . image _url ,
previewImage : doc . image _url ,
videoURL : doc . video _url
videoURL : doc . video _url
} ) ;
} ) ;
} ) ;
} ) ;
return Promise . all ( promises ) ;
return Promise . all ( promises ) ;
} catch ( e ) {
console . log ( e . message )
}
} ;
} ;
const animeExtraInfo = async ( title ) => {
const animeExtraInfo = async ( title ) => {
let options = { parse : true }
try {
const res = await homgot ( ` ${ BASE _JIKAN } search/anime?q= ${ title } ` , options ) ;
const matchAnime = res . results . filter ( x => x . title === title ) ;
const malId = matchAnime [ 0 ] . mal _id ;
if ( typeof matchAnime [ 0 ] . mal _id === 'undefined' ) return null ;
let options = { parse : true }
const res = await homgot ( ` ${ BASE _JIKAN } search/anime?q= ${ title } ` , options ) ;
const matchAnime = res . results . filter ( x => x . title === title ) ;
const malId = matchAnime [ 0 ] . mal _id ;
if ( typeof matchAnime [ 0 ] . mal _id === 'undefined' ) return null ;
const data = await homgot ( ` ${ BASE _JIKAN } anime/ ${ malId } ` , options ) ;
const body = Array ( data ) ;
const promises = [ ] ;
body . map ( doc => {
let airDay = {
'mondays' : 'Lunes' ,
'monday' : 'Lunes' ,
'tuesdays' : 'Martes' ,
'tuesday' : 'Martes' ,
'wednesdays' : 'Miércoles' ,
'wednesday' : 'Miércoles' ,
'thursdays' : 'Jueves' ,
'thursday' : 'Jueves' ,
'fridays' : 'Viernes' ,
'friday' : 'Viernes' ,
'saturdays' : 'Sábados' ,
'saturday' : 'Sábados' ,
'sundays' : 'Domingos' ,
'sunday' : 'Domingos' ,
'default' : 'Sin emisión'
} ;
let broadcast
if ( doc . broadcast === null ) {
broadcast = null
} else {
broadcast = airDay [ doc . broadcast . split ( 'at' ) [ 0 ] . replace ( " " , "" ) . toLowerCase ( ) ]
}
const data = await homgot ( ` ${ BASE _JIKAN } anime/ ${ malId } ` , options ) ;
promises . push ( {
const body = Array ( data ) ;
titleJapanese : doc . title _japanese ,
const promises = [ ] ;
source : doc . source ,
totalEpisodes : doc . episodes ,
aired : {
from : doc . aired . from ,
to : doc . aired . to
} ,
duration : doc . duration . split ( 'per' ) [ 0 ] ,
rank : doc . rank ,
broadcast : broadcast ,
producers : doc . producers . map ( x => x . name ) || null ,
licensors : doc . licensors . map ( x => x . name ) || null ,
studios : doc . studios . map ( x => x . name ) || null ,
openingThemes : doc . opening _themes || null ,
endingThemes : doc . ending _themes || null
} ) ;
} ) ;
return Promise . all ( promises ) ;
} catch ( e ) {
console . log ( e . message )
}
body . map ( doc => {
let airDay = {
'mondays' : 'Lunes' ,
'monday' : 'Lunes' ,
'tuesdays' : 'Martes' ,
'tuesday' : 'Martes' ,
'wednesdays' : 'Miércoles' ,
'wednesday' : 'Miércoles' ,
'thursdays' : 'Jueves' ,
'thursday' : 'Jueves' ,
'fridays' : 'Viernes' ,
'friday' : 'Viernes' ,
'saturdays' : 'Sábados' ,
'saturday' : 'Sábados' ,
'sundays' : 'Domingos' ,
'sunday' : 'Domingos' ,
'default' : 'Sin emisión'
} ;
let broadcast
if ( doc . broadcast === null ) {
broadcast = null
} else {
broadcast = airDay [ doc . broadcast . split ( 'at' ) [ 0 ] . replace ( " " , "" ) . toLowerCase ( ) ]
}
promises . push ( {
titleJapanese : doc . title _japanese ,
source : doc . source ,
totalEpisodes : doc . episodes ,
aired : {
from : doc . aired . from ,
to : doc . aired . to
} ,
duration : doc . duration . split ( 'per' ) [ 0 ] ,
rank : doc . rank ,
broadcast : broadcast ,
producers : doc . producers . map ( x => x . name ) || null ,
licensors : doc . licensors . map ( x => x . name ) || null ,
studios : doc . studios . map ( x => x . name ) || null ,
openingThemes : doc . opening _themes || null ,
endingThemes : doc . ending _themes || null
} ) ;
} ) ;
return Promise . all ( promises ) ;
} ;
} ;
const imageUrlToBase64 = async ( url ) => {
const imageUrlToBase64 = async ( url ) => {
@ -441,7 +450,8 @@ const searchAnime = async (query) => {
const jkAnimeTitles = [
const jkAnimeTitles = [
{ title : 'BNA' , search : 'BNA' } ,
{ title : 'BNA' , search : 'BNA' } ,
{ title : 'The God of High School' , search : 'The god' }
{ title : 'The God of High School' , search : 'The god' } ,
{ title : 'Ansatsu Kyoshitsu' , search : 'Assassination Classroom' } ,
] ;
] ;
let jkanime = false
let jkanime = false