-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprocessImages.ts
55 lines (52 loc) · 1.3 KB
/
processImages.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { createClient } from 'https://esm.sh/@supabase/supabase-js';
const client = createClient(
'https://hdabbjaktgetmyexzjtf.supabase.co',
Deno.env.get('SECRET')!
);
const devices = client.storage.from('devices');
const codenames = new Set(
(await devices.list('', {
limit: 5000,
}))!.data!.map((x) => x.name.split('.')[0])
);
const paths = [
'./ota/oaspk/images/devices',
'./ota/pixelexperience/images',
'./ota/lineageos/images/devices',
];
paths.forEach(async (path) => {
for await (const file of Deno.readDir(path)) {
if (file.isDirectory) continue;
const codename = file.name.toLowerCase().split('.')[0];
if (codenames.has(codename)) continue;
else codenames.add(codename);
console.log(
path,
await devices.upload(
file.name.toLowerCase(),
await Deno.readFile(`${path}/${file.name}`),
{
contentType: 'image/png',
}
)
);
}
});
const specs = await fetch('https://nowrom.deno.dev/specs').then((r) =>
r.json()
);
specs.forEach(async (x: Record<string, string>) => {
if (!codenames.has(x.codename.toLowerCase())) {
codenames.add(x.codename.toLowerCase());
console.log(
`GSMARENA ${x.codename}`,
await devices.upload(
`${x.codename.toLowerCase()}.png`,
await (await fetch(x.image)).arrayBuffer(),
{
contentType: 'image/png',
}
)
);
}
});