mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-01 01:12:39 +00:00
36 lines
817 B
JavaScript
36 lines
817 B
JavaScript
//--- Modules/Imports ---//
|
|
import { Http } from '@capacitor-community/http';
|
|
|
|
//--- Logger Function ---//
|
|
function logger(func, data) {
|
|
module.logs.push({
|
|
name: func,
|
|
time: Date.now(),
|
|
data: data
|
|
})
|
|
}
|
|
|
|
const module = {
|
|
logs: new Array(),
|
|
|
|
//--- Get YouTube's Search Auto Complete ---//
|
|
async autoComplete(text, callback) {
|
|
const res = await Http.request({
|
|
method: 'GET',
|
|
url: 'https://suggestqueries-clients6.youtube.com/complete/search',
|
|
params: { client: 'youtube', q: text }
|
|
})
|
|
.catch((err) => {
|
|
logger("autoComplete", err);
|
|
callback(err);
|
|
});
|
|
logger("autoComplete", res);
|
|
callback(res);
|
|
}
|
|
}
|
|
|
|
//--- Start ---//
|
|
export default ({ app }, inject) => {
|
|
inject('youtube', module)
|
|
}
|
|
logger("Initialize","Program Started");
|