alexta69 / metube

Self-hosted YouTube downloader (web UI for youtube-dl / yt-dlp)
GNU Affero General Public License v3.0
3.97k stars 264 forks source link

TEMP_DIR also in /downloads #330

Closed DavidHenryThoreau closed 8 months ago

DavidHenryThoreau commented 8 months ago

I've set docker-compose.yml :

version: "3"
services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
      - DELETE_FILE_ON_TRASHCAN=true
      - TEMP_DIR=/tmp/metube-temp
      - STATE_DIR=/tmp/
      - OUTPUT_TEMPLATE=%(playlist)s/%(title)s.%(ext)s
      - 'YTDL_OPTIONS={"add-metadata":true}'
    volumes:
      - /data/metube-dl:/downloads
    ports:
      - 8081:8081
    restart: unless-stopped

TEMP_DIR is set to /tmp/metube-temp but it also written to /downloads but I would like metube moves files to /downloads when download is finished not during downloading.

PikuZheng commented 8 months ago

have you tried to set TEMP_DIR to /tmp ?

DavidHenryThoreau commented 8 months ago

Yes, and also change AUDIO_DOWNLOAD_DIR same issue :

version: "3" 
services:
  metube:
    image: ghcr.io/alexta69/metube
    container_name: metube
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
      - DELETE_FILE_ON_TRASHCAN=true
      - TEMP_DIR=/tmp
      - AUDIO_DOWNLOAD_DIR=/mnt
      - STATE_DIR=/tmp
      - OUTPUT_TEMPLATE=%(playlist)s/%(title)s.%(ext)s
      - 'YTDL_OPTIONS={"add-metadata":true}'
    volumes:
      - /data/metube-dl/dl:/downloads
      - /data/metube-dl/audio:/mnt
    ports:
      - 8081:8081
    restart: unless-stopped
PikuZheng commented 8 months ago

well... TEMP_DIR=/tmp works for me. As far as I know, it will only be unusable if /tmp does not exist.

DavidHenryThoreau commented 8 months ago

I mean the folder is creating before download ends but.

root@debian-12:~/metube# ls /data/metube-dl/audio/
None
root@debian-12:~/metube# ls /data/metube-dl/audio/*

Right It might be good

DavidHenryThoreau commented 8 months ago

Another test :

The playlist tracks (https://www.youtube.com/watch?v=lC-DDR4_NUE&list=PLmYFCjq3FIY0E0y6EdWDsDWebXHCxI79Q) are added in /mnt => /data/metube-dl/audio/ instead of putting them during download in /tmp

root@debian-12:~/metube# ll /data/metube-dl/audio/zero-project\ -\ Metamorphosis/*
-rw-r--r-- 1   25K 23 oct.  10:53 '/data/metube-dl/audio/zero-project - Metamorphosis/zero-project - Metamorphosis.jpg'
-rw-r--r-- 1 4,1M 13 févr.  2022 '/data/metube-dl/audio/zero-project - Metamorphosis/zero-project - The crossroads of change.mp3'
-rw-r--r-- 13,9M 13 févr.  2022 '/data/metube-dl/audio/zero-project - Metamorphosis/zero-project - The preparation.mp3'
PikuZheng commented 8 months ago

image well... /tmp works for me

DavidHenryThoreau commented 8 months ago

We may have confusion about temp_dir for me temp directory is used during downloading and move to AUDIO_DOWNLOAD_DIR or /donwloads when download is finished, because I want to watch if download directory change to post processor script.

It that possible to move files when download is finished to a directory ?

PikuZheng commented 8 months ago

TEMP_DIR means part of file while downloading. after download finished, yt-dlp will use ffmpeg to convert them to destination format, then move it to DOWNLOAD_DIR. you don't need MoveFilesAfterDownload in postprocessor by default. I think you need to specify the running time in postprocessor, such as after_move or post_process (which is default) if you mean

DavidHenryThoreau commented 8 months ago

You mean like that ?

      - 'YTDL_OPTIONS={"add-metadata":true,"MoveFilesAfterDownloadPP":false,"postprocessors":[{"key":"Exec","exec_cmd":"mv /mnt/* /downloads","when":"after_move"}}'
root@debian-12:~/metube# docker logs metube -f
Setting umask to 022
Creating download directory (/downloads), state directory (/tmp), and temp dir (/tmp)
Changing ownership of download and state directories to 1000:1000
Running MeTube as user 1000:1000
YTDL_OPTIONS is invalid
PikuZheng commented 8 months ago

'YTDL_OPTIONS={"add-metadata":true,"MoveFilesAfterDownloadPP":false, <----MoveFilesAfterDownload is a part of postprocessors "postprocessors":[{"key":"Exec","exec_cmd":"mv /mnt/* /downloads","when":"after_move"}]}' <---------- "]" missing

but which is your final dir? /mnt or /downloads ?

please try

- DOWNLOAD_DIR=your final dir
- TEMP_DIR=/tmp
- YTDL_OPTIONS={"add-metadata":true}
DavidHenryThoreau commented 8 months ago

I'd like to add separate directory audio/video like mentioned in the documentation. Like :

      - DELETE_FILE_ON_TRASHCAN=true
      - TEMP_DIR=/tmp
      - STATE_DIR=/tmp
      - AUDIO_DOWNLOAD_DIR=/mnt
      - DOWNLOAD_DIR=/downloads
      - OUTPUT_TEMPLATE=%(playlist)s/%(title)s.%(ext)s
   volumes:
      - /data/metube-dl/dl:/downloads
      - /data/metube-dl/audio:/mnt    

I'm testing your settings

      - TEMP_DIR=/tmp
      - STATE_DIR=/tmp
      - DOWNLOAD_DIR=/downloads
      - OUTPUT_TEMPLATE=%(playlist)s/%(title)s.%(ext)s
      - 'YTDL_OPTIONS={"add-metadata":true}'
    volumes:
      - /data/metube-dl/dl:/downloads

But mp3 are added to /data/metube-dl/dl/ during download

PikuZheng commented 8 months ago

i see. the issue is AUDIO_DOWNLOAD_DIR not work.

but is AUDIO_DOWNLOAD_DIR a legal option? I don't know.

DavidHenryThoreau commented 8 months ago
      - DELETE_FILE_ON_TRASHCAN=true
      - TEMP_DIR=/tmp
      - STATE_DIR=/tmp
      - DOWNLOAD_DIR=/downloads
        #- AUDIO_DOWNLOAD_DIR=/mnt
      - OUTPUT_TEMPLATE=%(playlist)s/%(title)s.%(ext)s
      - 'YTDL_OPTIONS={"add-metadata":true}'
    volumes:
      - /data/metube-dl/dl:/downloads
        #- /data/metube-dl/audio:/mnt

Still add mp3 to /data/metube-dl/dl in the host during download not when download is finished

PikuZheng commented 8 months ago

and what's more, I don't think {"add-metadata":true} is a legal option, too.

so, try

      - TEMP_DIR=/tmp
      - DOWNLOAD_DIR=/downloads
      - 'YTDL_OPTIONS={"postprocessors":[{"key":"FFmpegMetadata","add_metadata":"True"}, {"key":"Exec","exec_cmd":"mv /downloads/*.mp3 /mnt/","when":"after_move"}] }'
      - ......other options
DavidHenryThoreau commented 8 months ago
mv: target '/downloads/zero-project - Metamorphosis/zero-project - The crossroads of change.mp3': Not a directory
ERROR: Postprocessing: Command returned error code 1
INFO:ytdl:waiting for item to download
PikuZheng commented 8 months ago

exec_cmd will add download file name to the end of command. sorry.

these should works:

"exec_cmd":"sh /downloads/movefile.sh" in file /downloads/movefile.sh

if [[ "$1" == "*.mp3" ]]; then
mv $1 /mnt/ || true
fi
DavidHenryThoreau commented 8 months ago
/bin/sh: syntax error: unexpected end of file (expecting "fi")
ERROR: Postprocessing: Command returned error code 2
PikuZheng commented 8 months ago
if [[ "$1" == "*.mp3" ]]; then
mv "$1" /mnt/ || true
fi
DavidHenryThoreau commented 8 months ago
/bin/sh: syntax error: unexpected word
ERROR: Postprocessing: Command returned error code 2
PikuZheng commented 8 months ago

I tried it on my computer and it works. I have already done my best ╮(╯_╰)╭

DavidHenryThoreau commented 8 months ago

Thanks for help