mirror of
https://github.com/VueTubeApp/VueTube
synced 2024-11-07 20:15:05 +00:00
36 lines
820 B
JavaScript
36 lines
820 B
JavaScript
//--- Modules/Imports ---//
|
|
import { Http } from '@capacitor-community/http';
|
|
|
|
//--- Logger Function ---//
|
|
function logger(func, data) {
|
|
module.logs.unshift({
|
|
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");
|