Created
April 13, 2020 19:43
-
-
Save Pyrolistical/eb3ab96fdde43b28f7fcf9c59ff2b568 to your computer and use it in GitHub Desktop.
Sophek Tounn question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
const audioDataCount = await axios.post(netlifyConfig().DOMAIN + 'get-scene-audio-count', { | |
email: value.email, | |
sourceID: value.sourceID, | |
source: value.source | |
}) | |
console.log('audioDataCount', audioDataCount) | |
const res = { | |
count: audioDataCount.data.audioScenesList.count, | |
data: audioDataCount.data.audioScenesList.items | |
} | |
console.log('res count', res) | |
if (res.count > 0) { | |
return sendResponse({ | |
message: 'from 8base', | |
filterCount: res.count, | |
result: res.data[0].audioData | |
}) | |
} | |
const resData= await axios.get(value.fileURL) | |
const audioDataToInsert = value.ccFileType == 'dfxp' ? parseTTMLOrDFXP(resData.data, 'tt:body', 'tt:p').filter(i => i.isOffensive == true) : parseTTMLOrDFXP(resData.data).filter(i => i.isOffensive == true); | |
const dataToInsert = { | |
'sourceID': value.sourceID, | |
'audioData': audioDataToInsert, | |
'email': value.email, | |
'source': value.source | |
} | |
await axios.post(netlifyConfig().DOMAIN + 'audio-create', dataToInsert) | |
return sendResponse({ | |
message: 'newly created', | |
filterCount: dataToInsert.audioData.length, | |
result: dataToInsert.audioData | |
}) | |
} catch (err) { | |
return sendResponse({ | |
message: err, | |
filterCount: 0, | |
result: [] | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f1() { | |
return axios.post(netlifyConfig().DOMAIN + 'get-scene-audio-count', { | |
email: value.email, | |
sourceID: value.sourceID, | |
source: value.source | |
}) | |
.then(audioDataCount => { | |
console.log('audioDataCount', audioDataCount) | |
return { | |
count: audioDataCount.data.audioScenesList.count, | |
data: audioDataCount.data.audioScenesList.items | |
} | |
}) | |
} | |
function f2() { | |
return axios.get(value.fileURL) | |
.then(resData => { | |
let filteredData = value.ccFileType == 'dfxp' ? parseTTMLOrDFXP(resData.data, 'tt:body', 'tt:p').filter(i => i.isOffensive == true) : parseTTMLOrDFXP(resData.data).filter(i => i.isOffensive == true); | |
return filteredData | |
}) | |
.then(audioDataToInsert => { | |
let dataToInsert = { | |
'sourceID': value.sourceID, | |
'audioData': audioDataToInsert, | |
'email': value.email, | |
'source': value.source | |
} | |
return axios.post(netlifyConfig().DOMAIN + 'audio-create', dataToInsert) | |
}) | |
} | |
f1() | |
.then(res => { | |
console.log('res count', res) | |
if (res.count > 0) { | |
return sendResponse({ | |
message: 'from 8base', | |
filterCount: res.count, | |
result: res.data[0].audioData | |
}) | |
} | |
return f2() | |
.then(item => { | |
return sendResponse({ | |
message: 'newly created', | |
filterCount: dataToInsert.audioData.length, | |
result: dataToInsert.audioData | |
}) | |
}) | |
}) | |
.catch(err => { | |
return sendResponse({ | |
message: err, | |
filterCount: 0, | |
result: [] | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment