Skip to content

Commit

Permalink
download through yt-dlp
Browse files Browse the repository at this point in the history
  • Loading branch information
vaaski committed Mar 15, 2024
1 parent fd81c35 commit bc9d4cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@grammyjs/parse-mode": "^1.9.0",
"@resync-tv/yt-dlp": "^0.2.1",
"@resync-tv/yt-dlp": "0.3.1",
"express": "^4.18.3",
"grammy": "^1.21.1"
}
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ADMIN_ID, WHITELISTED_IDS } from "./environment"
import { Queue } from "./queue"
import { bot } from "./setup"
import { removeHashtagsMentions } from "./textutil"
import { getInfo } from "@resync-tv/yt-dlp"
import { getInfo, streamFromInfo } from "@resync-tv/yt-dlp"

const queue = new Queue()

Expand Down Expand Up @@ -52,8 +52,10 @@ bot.on("message:text").on("::url", async (ctx, next) => {
const [download] = info.requested_downloads ?? []
if (!download || !download.url) throw new Error("No download available")

if (download.vcodec) {
await ctx.replyWithVideo(new InputFile({ url: download.url }), {
if (download.vcodec || download.ext === "mp4") {
const stream = streamFromInfo(info)

await ctx.replyWithVideo(new InputFile(stream.stdout), {
caption: removeHashtagsMentions(info.title),
supports_streaming: true,
reply_parameters: {
Expand Down

0 comments on commit bc9d4cd

Please sign in to comment.