Fix unsupported name of files
This commit is contained in:
parent
dc96a61358
commit
9e6c74fde7
@ -6,6 +6,7 @@ const https = require("https");
|
|||||||
const config = require("./config");
|
const config = require("./config");
|
||||||
const { DownloadVideo, YtdlUpdater, downloadFile } = require("./download");
|
const { DownloadVideo, YtdlUpdater, downloadFile } = require("./download");
|
||||||
const { MTProtoUser } = require("./mtproto");
|
const { MTProtoUser } = require("./mtproto");
|
||||||
|
const utils = require("./utils");
|
||||||
|
|
||||||
async function getImage(url) {
|
async function getImage(url) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -212,9 +213,9 @@ class TgBotSender {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
//filename: `downloaded.${downloaded.format.exc}`,
|
//filename: `downloaded.${downloaded.format.exc}`,
|
||||||
filename: `${
|
filename:
|
||||||
videoInfo.title
|
utils.setupCorrectFilename(videoInfo.title) +
|
||||||
}.mp3`,
|
".mp3",
|
||||||
contentType: downloaded.format.mime,
|
contentType: downloaded.format.mime,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -261,6 +261,9 @@ class DownloadVideo {
|
|||||||
async download(cb, isStream = false) {
|
async download(cb, isStream = false) {
|
||||||
const signal = new EventEmitter();
|
const signal = new EventEmitter();
|
||||||
const isPath = typeof isStream === "string";
|
const isPath = typeof isStream === "string";
|
||||||
|
if (isPath) {
|
||||||
|
console.debug({ isStream });
|
||||||
|
}
|
||||||
if (!this.parent.updater.lock(signal)) {
|
if (!this.parent.updater.lock(signal)) {
|
||||||
await new Promise((rs => {
|
await new Promise((rs => {
|
||||||
this.parent.updater.once("finish", () => {
|
this.parent.updater.once("finish", () => {
|
||||||
|
|||||||
@ -52,4 +52,8 @@ async function verifyThumbUrl (fileUrl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { downloadFile, verifyThumbUrl };
|
function setupCorrectFilename (filename) {
|
||||||
|
return filename.replace(/[\/\\\s\.+]{1,}/g, "_");
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { downloadFile, verifyThumbUrl, setupCorrectFilename };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user