sc: use 500x500 as ca instead of original
This commit is contained in:
parent
2f0e2c5070
commit
f679e03677
@ -19,7 +19,7 @@ let items;
|
||||
if(_itemid > 0)
|
||||
items = await sql('items').where('id', _itemid);
|
||||
else
|
||||
items = await sql('items').orderBy('id', 'asc')/*.whereNot('src', 'like', '%soundcloud%')*/.where('mime', 'like', 'audio/%');
|
||||
items = await sql('items').orderBy('id', 'asc').where('src', 'like', '%soundcloud%').where('mime', 'like', 'audio/%');
|
||||
let count = 1;
|
||||
let total = items.length;
|
||||
|
||||
@ -35,14 +35,15 @@ for(let item of items) {
|
||||
await exec(`convert ./public/b/${filename} ./tmp/${itemid}.png`);
|
||||
else if(mime.startsWith('audio/')) {
|
||||
if(link.match(/soundcloud/)) {
|
||||
const cover = (await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --get-thumbnail "${link}"`)).stdout.trim();
|
||||
let cover = (await exec(`yt-dlp --get-thumbnail "${link}"`)).stdout.trim();
|
||||
if(!cover.match(/default_avatar/)) {
|
||||
cover = cover.replace(/-(large|original)\./, '-t500x500.');
|
||||
try {
|
||||
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
||||
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
||||
if(size >= 0) {
|
||||
await exec(`convert ./tmp/${itemid}.jpg ./tmp/${itemid}.png`);
|
||||
await exec(`convert ./tmp/${itemid}.jpg -resize 50% ./public/ca/${itemid}.webp`);
|
||||
await exec(`convert ./tmp/${itemid}.jpg ./public/ca/${itemid}.webp`);
|
||||
}
|
||||
} catch(err) {
|
||||
//console.log(err);
|
||||
|
@ -52,7 +52,7 @@ export default async bot => {
|
||||
// generate uuid
|
||||
const uuid = (await sql.select(sql.raw("gen_random_uuid() as uuid")))[0].uuid.substring(0, 8);
|
||||
|
||||
const maxfilesize = (getLevel(e.user).level > 50 ? cfg.main.maxfilesize * 3.5 : cfg.main.maxfilesize) / 1024;
|
||||
const maxfilesize = (getLevel(e.user).level > 50 ? cfg.main.maxfilesize * cfg.main.adminmultiplier : cfg.main.maxfilesize) / 1024;
|
||||
|
||||
let meta;
|
||||
// read metadata
|
||||
@ -137,14 +137,15 @@ export default async bot => {
|
||||
await exec(`convert ./public/b/${filename} ./tmp/${itemid}.png`);
|
||||
else if(mime.startsWith('audio/')) {
|
||||
if(link.match(/soundcloud/)) {
|
||||
const cover = (await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --get-thumbnail "${link}"`)).stdout.trim();
|
||||
let cover = (await exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --get-thumbnail "${link}"`)).stdout.trim();
|
||||
if(!cover.match(/default_avatar/)) {
|
||||
cover = cover.replace(/-(large|original)\./, '-t500x500.');
|
||||
try {
|
||||
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
||||
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
||||
if(size >= 0) {
|
||||
await exec(`convert ./tmp/${itemid}.jpg ./tmp/${itemid}.png`);
|
||||
await exec(`convert ./tmp/${itemid}.jpg -resize 50% ./public/ca/${itemid}.webp`);
|
||||
await exec(`convert ./tmp/${itemid}.jpg ./public/ca/${itemid}.webp`);
|
||||
}
|
||||
} catch(err) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user