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
|
||||||
@@ -7,4 +7,7 @@ RUN apk update && \
|
|||||||
COPY requirements.txt requirements.txt
|
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 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"]
|
CMD ["python3", "youdis.py"]
|
||||||
15
youdis.py
15
youdis.py
@@ -9,17 +9,24 @@ discord-py-interactions 5.11.0 has new option
|
|||||||
|
|
||||||
import interactions
|
import interactions
|
||||||
from os import getenv
|
from os import getenv
|
||||||
|
from pathlib import Path
|
||||||
import yt_dlp
|
import yt_dlp
|
||||||
import json
|
import json
|
||||||
import asyncio
|
import asyncio
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
user_file = '/config/users.json'
|
userFile = Path('/config/users.json')
|
||||||
|
|
||||||
bot = interactions.Client(intents=interactions.Intents.DEFAULT,default_scope=2147491904)
|
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')
|
authorized_users = json.load(f).get('authorized_users')
|
||||||
print(f'authorized_users:{authorized_users}')
|
print(f'authorized_users:{authorized_users}')
|
||||||
|
|
||||||
title = ''
|
title = ''
|
||||||
|
|
||||||
async def send_message(ctx, message):
|
async def send_message(ctx, message):
|
||||||
@@ -68,7 +75,7 @@ async def youtube(ctx: interactions.SlashContext, url:str):
|
|||||||
'writeinfojson':False,
|
'writeinfojson':False,
|
||||||
'allow_playlist_files':True,
|
'allow_playlist_files':True,
|
||||||
'noplaylist':True,
|
'noplaylist':True,
|
||||||
'download_archive':'/config/archive.txt',
|
'download_archive':'./config/archive.txt',
|
||||||
'progress_hooks':[hook],
|
'progress_hooks':[hook],
|
||||||
'outtmpl': '%(uploader)s/%(playlist_title)s/%(playlist_index)s%(playlist_index& - )s%(title)s.%(ext)s',
|
'outtmpl': '%(uploader)s/%(playlist_title)s/%(playlist_index)s%(playlist_index& - )s%(title)s.%(ext)s',
|
||||||
'outtmpl_na_placeholder':'',
|
'outtmpl_na_placeholder':'',
|
||||||
@@ -114,7 +121,7 @@ async def _interrupt(ctx):
|
|||||||
async def _adduser(ctx: interactions.SlashContext, user:interactions.OptionType.USER):
|
async def _adduser(ctx: interactions.SlashContext, user:interactions.OptionType.USER):
|
||||||
if str(user.id) not in authorized_users:
|
if str(user.id) not in authorized_users:
|
||||||
authorized_users.append(str(user.id))
|
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})
|
json.dump({'authorized_users':authorized_users})
|
||||||
print('react:checkmark')
|
print('react:checkmark')
|
||||||
await ctx.message.add_reaction('✅')
|
await ctx.message.add_reaction('✅')
|
||||||
|
|||||||
Reference in New Issue
Block a user