Compare commits
33 Commits
87a0a78a9c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| a399a91ab0 | |||
| ec72c5657b | |||
| f8f625f0bf | |||
| 22fb495e0d | |||
| 33d5de6a77 | |||
| d539915486 | |||
| f173c64b70 | |||
| 750dc265ca | |||
| 846d07f099 | |||
| adca108376 | |||
| 748e3fb22a | |||
| 0968aa84b8 | |||
| b74f70c42e | |||
| 07cdae823a | |||
| 81619074d7 | |||
| 690f97ed82 | |||
| b772383d14 | |||
| 53fbcc5a8a | |||
| 713f316679 | |||
| 08bcc3d3bd | |||
| 0abf3a5adb | |||
| 32ed9bc81b | |||
| b37e943a8a | |||
| 7ada5c6bb9 | |||
| d94b63b1f0 | |||
| 1d6e9bac6f | |||
| 460efe192a | |||
| 18a95da9b1 | |||
| 05b05e6725 | |||
| a09dbc4687 | |||
| b0c0bb1d21 | |||
| 17cd735d1c | |||
| f26222b4e7 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.sh text eol=lf
|
||||
@@ -1,7 +1,8 @@
|
||||
name: Check yt-dlp weekly and rebuild if new
|
||||
name: push new builds to gitea, dockerhub
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 0'
|
||||
push:
|
||||
branches: ["master"]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -10,35 +11,62 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get current version
|
||||
id: current
|
||||
- name: Get youdis version
|
||||
id: youdis
|
||||
run: |
|
||||
CURRENT=$(cat version.txt || echo "none")
|
||||
echo "version=$CURRENT" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check latest version
|
||||
id: latest
|
||||
run: |
|
||||
LATEST=$(curl -s https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest | jq -r .tag_name || echo "error")
|
||||
if [ "$LATEST" == "error" ]; then
|
||||
echo "failed to fetch latest version" >&2
|
||||
YOUDIS_VER=$(cat youdis-version.txt)
|
||||
if [ -z "$YOUDIS_VER" ]; then
|
||||
echo "youdis version empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "version=$LATEST" >> $GITHUB_OUTPUT
|
||||
echo "youdis-version=$YOUDIS_VER" >> $GITHUB_OUTPUT
|
||||
echo "shortsha=${GITHUB_SHA::5}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update version file if changed
|
||||
run: echo ${{ steps.latest.outputs.version }} > version.txt
|
||||
if: ${{ steps.current.outputs.version != steps.latest.outputs.version }}
|
||||
- name: Decide if build needed
|
||||
id: check_build
|
||||
run: |
|
||||
SHOULD_BUILD=false
|
||||
if [ "${{ steps.youdis.outputs.youdis-version }}" != "$(docker inspect --format='{{ index .Config.Labels "YOUDIS_VERSION" }}' eulaly/youdis:latest || echo none)" ]; then
|
||||
SHOULD_BUILD=true
|
||||
fi
|
||||
echo "should_build=$SHOULD_BUILD" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v2
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push docker image
|
||||
- name: Build and push to Dockerhub
|
||||
if: ${{ steps.check_build.outputs.should_build == 'true' }}
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: eulaly/youdis:latest,eulaly/youdis:${{ steps.latest.outputs.version }}
|
||||
if: ${{ steps.current.outputs.version != steps.latest.outputs.version }}
|
||||
tags: |
|
||||
eulaly/youdis:latest
|
||||
eulaly/youdis:${{ steps.youdis.outputs.shortsha }}
|
||||
labels: |
|
||||
YOUDIS_VERSION=${{ steps.youdis.outputs.youdis-version }}
|
||||
|
||||
- name: Login to Gitea
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.hgsky.me
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.YOUDIS_PASSWORD }}
|
||||
|
||||
- name: Build and push to Gitea
|
||||
if: ${{ steps.check_build.outputs.should_build == 'true' }}
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: |
|
||||
git.hgsky.me/ben/youdis:latest
|
||||
git.hgsky.me/ben/youdis:${{ steps.youdis.outputs.shortsha }}
|
||||
labels: |
|
||||
YOUDIS_VERSION=${{ steps.youdis.outputs.youdis-version }}
|
||||
|
||||
- name: link container in gitea
|
||||
run: |
|
||||
curl -X POST -H "Authorization: token ${{ secrets.SUPER }}" https://git.hgsky.me/api/v1/packages/ben/container/youdis/-/link/youdis
|
||||
|
||||
|
||||
44
.github/workflows/docker-build.yaml
vendored
44
.github/workflows/docker-build.yaml
vendored
@@ -1,44 +0,0 @@
|
||||
name: Check yt-dlp and rebuild if new
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 0'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get current version
|
||||
id: current
|
||||
run: |
|
||||
CURRENT=$(cat version.txt || echo "none")
|
||||
echo "version=$CURRENT" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check latest version
|
||||
id: latest
|
||||
run: |
|
||||
LATEST=$(curl -s https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest | jq -r .tag_name || echo "error")
|
||||
if [ "$LATEST" == "error" ]; then
|
||||
echo "failed to fetch latest version" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "version=$LATEST" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Update version file if changed
|
||||
run: echo ${{ steps.latest.outputs.version }} > version.txt
|
||||
if: ${{ steps.current.outputs.version != steps.latest.outputs.version }}
|
||||
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: eulaly/youdis:latest,eulaly/youdis:${{ steps.latest.outputs.version }}
|
||||
if: ${{ steps.current.outputs.version != steps.latest.outputs.version }}
|
||||
BIN
.gitignore
vendored
BIN
.gitignore
vendored
Binary file not shown.
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
|
||||
12
dockerfile
12
dockerfile
@@ -4,7 +4,13 @@ WORKDIR /app
|
||||
RUN apk update && \
|
||||
apk add --no-cache build-base ffmpeg && \
|
||||
rm -rf /var/cache/apk/*
|
||||
COPY requirements.txt requirements.txt
|
||||
COPY requirements.txt .
|
||||
RUN python3 -m pip install --no-cache-dir -r requirements.txt
|
||||
COPY youdis.py youdis.py
|
||||
CMD ["python3", "youdis.py"]
|
||||
|
||||
COPY youdis.py default-yt-dlp.conf update-ytdlp.sh run-youdis.sh /app/
|
||||
RUN chmod +x /app/update-ytdlp.sh /app/run-youdis.sh
|
||||
|
||||
COPY weekly-restart /etc/cron.d/
|
||||
RUN chmod 0644 /etc/cron.d/weekly-restart
|
||||
|
||||
ENTRYPOINT ["/app/run-youdis.sh"]
|
||||
|
||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
21
run-youdis.sh
Normal file
21
run-youdis.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
#start crond in bg
|
||||
crond -l 2
|
||||
|
||||
echo "checking for /config/yt-dlp.conf"
|
||||
#copy yt-dlp.conf if missing
|
||||
mkdir -p /config
|
||||
if [ ! -f /config/yt-dlp.conf ]; then
|
||||
echo "yt-dlp.conf not found, setting default"
|
||||
cp /app/default-yt-dlp.conf /config/yt-dlp.conf
|
||||
echo "created yt-dlp.conf"
|
||||
fi
|
||||
|
||||
python3 -m pip install --no-cache-dir --upgrade --pre "yt-dlp[default]"
|
||||
VERSION=$(python3 -m pip show yt-dlp 2>/dev/null | awk '/Version:/ {print $2}')
|
||||
echo "updated yt-dlp to $VERSION"
|
||||
|
||||
echo "starting youdis"
|
||||
exec python3 /app/youdis.py
|
||||
12
update-ytdlp.sh
Normal file
12
update-ytdlp.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "updating yt-dlp"
|
||||
echo "killing youdis"
|
||||
pkill -f youdis.py || true
|
||||
python3 -m pip install --no-cache-dir --upgrade --pre "yt-dlp[default]"
|
||||
VERSION=$(python3 -m pip show yt-dlp 2>/dev/null | awk '/Version:/ {print $2}')
|
||||
|
||||
echo "updated yt-dlp to $VERSION"
|
||||
echo "restarting youdis"
|
||||
python3 /app/youdis.py &
|
||||
1
weekly-restart
Normal file
1
weekly-restart
Normal file
@@ -0,0 +1 @@
|
||||
0 3 * * 0 root /app/update-ytdlp.sh
|
||||
1
youdis-version.txt
Normal file
1
youdis-version.txt
Normal file
@@ -0,0 +1 @@
|
||||
20250829-ec72c56
|
||||
17
youdis.py
17
youdis.py
@@ -9,17 +9,26 @@ 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')
|
||||
userFile.touch(exist_ok=True)
|
||||
|
||||
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:
|
||||
with open(userFile, 'r') as f:
|
||||
authorized_users = json.load(f).get('authorized_users')
|
||||
print(f'authorized_users:{authorized_users}')
|
||||
|
||||
title = ''
|
||||
|
||||
async def send_message(ctx, message):
|
||||
@@ -34,7 +43,7 @@ def create_hook(ctx,loop):
|
||||
global title
|
||||
status = d.get('status')
|
||||
if status == 'error':
|
||||
msg = f'error; video probably already exists'
|
||||
msg = f'error; video probably already exists, have you checked archive.txt'
|
||||
asyncio.run_coroutine_threadsafe(send_message(ctx,msg),loop)
|
||||
elif d.get('info_dict').get('title') != title:
|
||||
title = d.get('info_dict').get('title')
|
||||
@@ -114,7 +123,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