Compare commits
2 Commits
87a0a78a9c
...
17cd735d1c
| Author | SHA1 | Date | |
|---|---|---|---|
| 17cd735d1c | |||
| f26222b4e7 |
11
default-yt-dlp.conf
Normal file
11
default-yt-dlp.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
# yt-dlp config file (yt-dlp.conf or .config/yt-dlp/config)
|
||||
--simulate
|
||||
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best"
|
||||
--embed-chapters
|
||||
--embed-info-json
|
||||
--write-playlist-metafiles
|
||||
#--paths "{"home":"./downloads"}"
|
||||
--download-archive "/config/archive.txt"
|
||||
--restrict-filenames
|
||||
--output "/downloads/%(uploader)s/%(playlist_title)s/%(playlist_index)s%(playlist_index& - )s%(title)s.%(ext)s"
|
||||
# --split-chapters
|
||||
@@ -5,6 +5,9 @@ RUN apk update && \
|
||||
apk add --no-cache build-base ffmpeg && \
|
||||
rm -rf /var/cache/apk/*
|
||||
COPY requirements.txt requirements.txt
|
||||
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
||||
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
||||
COPY youdis.py youdis.py
|
||||
COPY default-yt-dlp.conf /app/default-yt-dlp.conf
|
||||
COPY create-ytdlp-conf.sh /app/create-ytdlp-conf.sh
|
||||
ENTRYPOINT ["/app/create-ytdlp-conf.sh"]
|
||||
CMD ["python3", "youdis.py"]
|
||||
17
youdis.py
17
youdis.py
@@ -9,17 +9,24 @@ discord-py-interactions 5.11.0 has new option
|
||||
|
||||
import interactions
|
||||
from os import getenv
|
||||
from pathlib import Path
|
||||
import yt_dlp
|
||||
import json
|
||||
import asyncio
|
||||
import threading
|
||||
|
||||
user_file = '/config/users.json'
|
||||
userFile = Path('/config/users.json')
|
||||
|
||||
bot = interactions.Client(intents=interactions.Intents.DEFAULT,default_scope=2147491904)
|
||||
with open(user_file, 'r') as f:
|
||||
|
||||
userFile.parent.mkdir(exist_ok=True, parents=True)
|
||||
try:
|
||||
with open(userFile, 'x') as f:
|
||||
print(f'users.json not found; saving to {userFile}')
|
||||
except FileExistsError:
|
||||
authorized_users = json.load(f).get('authorized_users')
|
||||
print(f'authorized_users:{authorized_users}')
|
||||
print(f'authorized_users:{authorized_users}')
|
||||
|
||||
title = ''
|
||||
|
||||
async def send_message(ctx, message):
|
||||
@@ -68,7 +75,7 @@ async def youtube(ctx: interactions.SlashContext, url:str):
|
||||
'writeinfojson':False,
|
||||
'allow_playlist_files':True,
|
||||
'noplaylist':True,
|
||||
'download_archive':'/config/archive.txt',
|
||||
'download_archive':'./config/archive.txt',
|
||||
'progress_hooks':[hook],
|
||||
'outtmpl': '%(uploader)s/%(playlist_title)s/%(playlist_index)s%(playlist_index& - )s%(title)s.%(ext)s',
|
||||
'outtmpl_na_placeholder':'',
|
||||
@@ -114,7 +121,7 @@ async def _interrupt(ctx):
|
||||
async def _adduser(ctx: interactions.SlashContext, user:interactions.OptionType.USER):
|
||||
if str(user.id) not in authorized_users:
|
||||
authorized_users.append(str(user.id))
|
||||
with open(user_file,'w') as f: #overwrite file - fix later if other params come up
|
||||
with open(userFile,'w') as f: #overwrite file - fix later if other params come up
|
||||
json.dump({'authorized_users':authorized_users})
|
||||
print('react:checkmark')
|
||||
await ctx.message.add_reaction('✅')
|
||||
|
||||
Reference in New Issue
Block a user