Skip to content

Commit

Permalink
fix: youtube stream link
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaddeusJiang committed Jul 22, 2024
1 parent e6e6db4 commit d981c7f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ aier_bot-*.tar
/tmp/
.DS_Store
.local
run.sh
dev.sh
start.sh
run.sh
nohup.out
21 changes: 21 additions & 0 deletions docs/dev_readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dev Readme

## Dev

```sh
./dev
```

## Prod

```sh
./start
```

Stop

```bash
ps aux | grep mix

kill -9 <pid>
```
3 changes: 1 addition & 2 deletions lib/aier_bot/bot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ defmodule AierBot.Bot do

command("start")
command("help", description: "Print the bot's help")
command("image", description: "Generate image from text")

middleware(ExGram.Middleware.IgnoreUsername)

def bot(), do: @bot

def handle({:command, :start, _msg}, context) do
answer(context, "Hi!")
answer(context, "Hi! I'm a bot that can download images and videos, just give me a link.")
end

def handle({:command, :help, _msg}, context) do
Expand Down
12 changes: 9 additions & 3 deletions lib/aier_bot/file_helper.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
defmodule AierBot.FileHelper do
use Tesla

# youtube video download url: "https://olly.imput.net/api/stream?id=WpsLJCeQ24MBD_xM_3uwu&exp=1721625834931&sig=4UvjCvFD57jU7yrLdwmzRmfsPgPb8KhFIE1DwmnOj14&sec=C1Hty_eEXvswFhzdrDfDZ4cmkSUDgex1aV6mzDSK0dc&iv=ozku3rLJzeV_rVRSzWVlFw"
def download("https://olly.imput.net/api/stream" <> _ = url) do
def download(url) do
cond do
String.contains?(url, "/api/stream") -> download_streaming(url)
true -> download_file(url)
end
end

defp download_streaming(url) do
IO.inspect(url, label: "Download URL")

case get(url) do
Expand All @@ -20,7 +26,7 @@ defmodule AierBot.FileHelper do
end
end

def download(url) do
defp download_file(url) do
IO.inspect(url, label: "Download URL")

case get(url) do
Expand Down

0 comments on commit d981c7f

Please sign in to comment.