mirror of
https://codeberg.org/godmaire/sergei.git
synced 2024-09-20 00:08:25 +00:00
Switch to using yt-dlp via subprocess
This commit is contained in:
parent
824e818888
commit
99faecabd9
2 changed files with 9 additions and 10 deletions
12
Dockerfile
12
Dockerfile
|
@ -1,16 +1,14 @@
|
||||||
FROM python:3
|
FROM python:3
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pip3 install python-dotenv
|
RUN apt update
|
||||||
RUN pip3 install discord.py
|
RUN apt install -y ffmpeg
|
||||||
RUN pip3 install pynacl
|
RUN pip3 install discord.py python-dotenv pynacl
|
||||||
RUN pip3 install youtube_dl
|
|
||||||
RUN pip3 install git+https://github.com/Cupcakus/pafy
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN apt update
|
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
|
||||||
RUN apt install -y ffmpeg
|
RUN chmod a+rx /usr/local/bin/yt-dlp
|
||||||
|
|
||||||
CMD ["python3", "main.py"]
|
CMD ["python3", "main.py"]
|
||||||
|
|
7
main.py
7
main.py
|
@ -1,9 +1,10 @@
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import pafy
|
|
||||||
|
|
||||||
class Client(discord.Client):
|
class Client(discord.Client):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -28,8 +29,8 @@ class Client(discord.Client):
|
||||||
user = message.channel.recipient.id
|
user = message.channel.recipient.id
|
||||||
|
|
||||||
# Download file if it doesn't exist already
|
# Download file if it doesn't exist already
|
||||||
if not os.path.exists(url):
|
if not os.path.exists(v_id):
|
||||||
pafy.new(url).getbestaudio().download(filepath=v_id)
|
subprocess.run(["yt-dlp", "-f", "ba/b", "-o", v_id, url])
|
||||||
|
|
||||||
for chan in self.get_all_channels():
|
for chan in self.get_all_channels():
|
||||||
# Check if Channel is Voice Channel
|
# Check if Channel is Voice Channel
|
||||||
|
|
Loading…
Reference in a new issue