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)
|
if(_itemid > 0)
|
||||||
items = await sql('items').where('id', _itemid);
|
items = await sql('items').where('id', _itemid);
|
||||||
else
|
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 count = 1;
|
||||||
let total = items.length;
|
let total = items.length;
|
||||||
|
|
||||||
|
@ -35,14 +35,15 @@ for(let item of items) {
|
||||||
await exec(`convert ./public/b/${filename} ./tmp/${itemid}.png`);
|
await exec(`convert ./public/b/${filename} ./tmp/${itemid}.png`);
|
||||||
else if(mime.startsWith('audio/')) {
|
else if(mime.startsWith('audio/')) {
|
||||||
if(link.match(/soundcloud/)) {
|
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/)) {
|
if(!cover.match(/default_avatar/)) {
|
||||||
|
cover = cover.replace(/-(large|original)\./, '-t500x500.');
|
||||||
try {
|
try {
|
||||||
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
||||||
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
||||||
if(size >= 0) {
|
if(size >= 0) {
|
||||||
await exec(`convert ./tmp/${itemid}.jpg ./tmp/${itemid}.png`);
|
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) {
|
} catch(err) {
|
||||||
//console.log(err);
|
//console.log(err);
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default async bot => {
|
||||||
// generate uuid
|
// generate uuid
|
||||||
const uuid = (await sql.select(sql.raw("gen_random_uuid() as uuid")))[0].uuid.substring(0, 8);
|
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;
|
let meta;
|
||||||
// read metadata
|
// read metadata
|
||||||
|
@ -137,14 +137,15 @@ export default async bot => {
|
||||||
await exec(`convert ./public/b/${filename} ./tmp/${itemid}.png`);
|
await exec(`convert ./public/b/${filename} ./tmp/${itemid}.png`);
|
||||||
else if(mime.startsWith('audio/')) {
|
else if(mime.startsWith('audio/')) {
|
||||||
if(link.match(/soundcloud/)) {
|
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/)) {
|
if(!cover.match(/default_avatar/)) {
|
||||||
|
cover = cover.replace(/-(large|original)\./, '-t500x500.');
|
||||||
try {
|
try {
|
||||||
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
await exec(`wget "${cover}" -O ./tmp/${itemid}.jpg`);
|
||||||
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
const size = (await fs.promises.stat(`./tmp/${itemid}.jpg`)).size;
|
||||||
if(size >= 0) {
|
if(size >= 0) {
|
||||||
await exec(`convert ./tmp/${itemid}.jpg ./tmp/${itemid}.png`);
|
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) {}
|
} catch(err) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user