frostpv 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/npm-publish.yml +33 -0
- package/README.md +0 -0
- package/gofile.js +44 -0
- package/index.js +1490 -0
- package/package.json +28 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [created]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v3
|
|
16
|
+
with:
|
|
17
|
+
node-version: 16
|
|
18
|
+
- run: npm ci
|
|
19
|
+
- run: npm test
|
|
20
|
+
|
|
21
|
+
publish-npm:
|
|
22
|
+
needs: build
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v3
|
|
27
|
+
with:
|
|
28
|
+
node-version: 16
|
|
29
|
+
registry-url: https://registry.npmjs.org/
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm publish
|
|
32
|
+
env:
|
|
33
|
+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/README.md
ADDED
|
File without changes
|
package/gofile.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const MediaDownloader = require("./index.js"); // Ajuste o caminho
|
|
2
|
+
const fs = require("fs"); // Importe o módulo fs
|
|
3
|
+
const path = require("path"); // Importe o módulo path
|
|
4
|
+
|
|
5
|
+
// Dentro do seu comando do Discord...
|
|
6
|
+
try {
|
|
7
|
+
// Supondo que 'videoUrl' seja a URL do vídeo a ser baixado
|
|
8
|
+
// Supondo que 'message' seja o objeto da mensagem do Discord
|
|
9
|
+
const result = await MediaDownloader(videoUrl, { /* suas opções */ });
|
|
10
|
+
|
|
11
|
+
if (result.type === "gofile") {
|
|
12
|
+
// Arquivo > 10MB, enviar link GoFile
|
|
13
|
+
message.channel.send(`O vídeo excede 10MB. Baixe aqui: ${result.value}`);
|
|
14
|
+
if (result.error) {
|
|
15
|
+
console.warn("GoFile upload error occurred but link was provided:", result.error);
|
|
16
|
+
}
|
|
17
|
+
} else if (result.type === "local") {
|
|
18
|
+
// Arquivo <= 10MB, ler e enviar arquivo local como Buffer
|
|
19
|
+
try {
|
|
20
|
+
const fileBuffer = fs.readFileSync(result.value);
|
|
21
|
+
const fileName = path.basename(result.value); // Obter nome do arquivo para Discord
|
|
22
|
+
await message.channel.send({
|
|
23
|
+
files: [{
|
|
24
|
+
attachment: fileBuffer,
|
|
25
|
+
name: fileName
|
|
26
|
+
}]
|
|
27
|
+
});
|
|
28
|
+
console.log(`Arquivo local ${fileName} enviado com sucesso.`);
|
|
29
|
+
// Opcional: deletar o arquivo local após envio para o Discord
|
|
30
|
+
// fs.unlinkSync(result.value);
|
|
31
|
+
} catch (fileError) {
|
|
32
|
+
console.error(`Erro ao ler ou enviar o arquivo local ${result.value}:`, fileError);
|
|
33
|
+
message.channel.send(`Erro ao enviar o arquivo local: ${fileError.message}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (result.error) {
|
|
37
|
+
// Erro no upload GoFile, mas arquivo local foi retornado como fallback
|
|
38
|
+
message.channel.send(`(Houve uma falha ao tentar enviar para o GoFile: ${result.error})`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error("Erro no MediaDownloader:", error);
|
|
43
|
+
message.channel.send(`Ocorreu um erro ao baixar o vídeo: ${error.message}`);
|
|
44
|
+
}
|