diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml new file mode 100644 index 0000000..8b0f457 --- /dev/null +++ b/.github/workflows/docker-build.yaml @@ -0,0 +1,38 @@ +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 + if: steps.current.outputs.version != steps.latest.outputs.version + run: echo ${{ steps.latest.outputs.version }} > version.txt + + - name: Build and push docker image + if: steps.current.outputs.version != steps.latest.outputs.version + uses: docker/build-push-action@v5 + with: + push: true + tags: eulaly/youdis:latest,eulaly/youdis:${{ steps.latest.outputs.version }} diff --git a/.gitignore b/.gitignore index 63975df..6f695fb 100644 Binary files a/.gitignore and b/.gitignore differ diff --git a/dockerfile b/dockerfile index ecc4a71..b8d769e 100644 --- a/dockerfile +++ b/dockerfile @@ -5,7 +5,6 @@ RUN apk update && \ apk add --no-cache build-base ffmpeg && \ rm -rf /var/cache/apk/* COPY requirements.txt requirements.txt -COPY data.json data.json RUN python3 -m pip install --no-cache-dir -r requirements.txt COPY youdis.py youdis.py CMD ["python3", "youdis.py"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5143233..ee440f0 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/unraid-ca-template.xml b/unraid-ca-template.xml new file mode 100644 index 0000000..bbcb667 --- /dev/null +++ b/unraid-ca-template.xml @@ -0,0 +1,27 @@ + + + youdis + spoonvacuum/youdis + https://hub.docker.com/r/spoonvacuum/youdis/ + bridge + + sh + false + https://github.com/eulaly/youdis + https://github.com/eulaly/youdis + Discord bot-based wrapper for yt-dlp. Supports playlists. Requires a configured Discord bot. + Downloaders: Tools: + + + https://raw.githubusercontent.com/yt-dlp/yt-dlp/master/.github/banner.svg + + + + 1737955166 + + + + + + + diff --git a/youdis.py b/youdis.py index 099fdfc..bd40cac 100644 --- a/youdis.py +++ b/youdis.py @@ -14,8 +14,10 @@ import json import asyncio import threading +user_file = '/config/users.json' + bot = interactions.Client(intents=interactions.Intents.DEFAULT,default_scope=2147491904) -with open('./data.json', 'r') as f: +with open(user_file, 'r') as f: authorized_users = json.load(f).get('authorized_users') print(f'authorized_users:{authorized_users}') title = '' @@ -61,12 +63,12 @@ async def youtube(ctx: interactions.SlashContext, url:str): 'format':'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best', 'fragment_tries': 10, 'restrictfilenames':True, - 'paths': {'home':'/unraid'}, + 'paths': {'home':'/downloads'}, 'retries':10, 'writeinfojson':False, 'allow_playlist_files':True, 'noplaylist':True, - 'download_archive':'/unraid/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':'', @@ -75,7 +77,7 @@ async def youtube(ctx: interactions.SlashContext, url:str): if ctx.author.id not in authorized_users: if ctx.author.id == 127831327012683776: await ctx.author.send('potato stop') - await ctx.author.send('you are not authorized to use this command. message Ben to be added.') + await ctx.author.send('you are not authorized to use this command. message my owner to be added.') return else: await ctx.channel.send(f'Downloading from <{url}>. Status updates via DM.') @@ -112,7 +114,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('./data.json','w') as f: #overwrite file - fix later if other params come up + with open(user_file,'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('✅') diff --git a/yt-dlp.conf b/yt-dlp.conf deleted file mode 100644 index c40f24d..0000000 --- a/yt-dlp.conf +++ /dev/null @@ -1,19 +0,0 @@ -# yt-dlp configuration file -# order matters. yt-dlp always reads this conf -# and runs the first -o that matches the condition - -# Save videos as MP4 --f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best - -# Restrict filenames to be Windows-safe ---restrict-filenames - ---match-filter "channel != null" --o a:/youtube/%(uploader)s/%(title)s.%ext(s) - -# Output template for playlists ---match-filter "playlist_title != null" --o a:/youtube/%(uploader)s-%(playlist_title)s/%(playlist_index)s-%(title)s.%(ext)s - -# Default output template --o %(title)s.%(ext)s