Switch to using yt-dlp via subprocess

This commit is contained in:
Roman 2023-06-06 17:01:17 -04:00
parent 824e818888
commit 99faecabd9
2 changed files with 9 additions and 10 deletions

View file

@ -1,16 +1,14 @@
FROM python:3
# Install dependencies
RUN pip3 install python-dotenv
RUN pip3 install discord.py
RUN pip3 install pynacl
RUN pip3 install youtube_dl
RUN pip3 install git+https://github.com/Cupcakus/pafy
RUN apt update
RUN apt install -y ffmpeg
RUN pip3 install discord.py python-dotenv pynacl
WORKDIR /usr/src/app
COPY . .
RUN apt update
RUN apt install -y ffmpeg
RUN curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
RUN chmod a+rx /usr/local/bin/yt-dlp
CMD ["python3", "main.py"]

View file

@ -1,9 +1,10 @@
import os
import subprocess
from dotenv import load_dotenv
from functools import partial
import discord
import pafy
class Client(discord.Client):
def __init__(self):
@ -28,8 +29,8 @@ class Client(discord.Client):
user = message.channel.recipient.id
# Download file if it doesn't exist already
if not os.path.exists(url):
pafy.new(url).getbestaudio().download(filepath=v_id)
if not os.path.exists(v_id):
subprocess.run(["yt-dlp", "-f", "ba/b", "-o", v_id, url])
for chan in self.get_all_channels():
# Check if Channel is Voice Channel