# Time to archive

#### How to archive an entire YouTube channel

1. Create a directory where you want your files to be
2. [Download](https://gitea.hopeless-cloud.xyz/Hopeless-cloud/Scripts) or create the necessary files to create directories, move files and download videos. Examples: ```bash
    #!/bin/sh
    
    if [ ! -d "video" ] ; then
    mkdir video && mkdir metadata && mkdir thumbnails && mkdir descriptions && echo "Created directories"
    fi
    ```
    
    ```bash
    #!/bin/bash
    
    if compgen -G "*.mkv" > /dev/null ; then
    mv *.mkv video/ && mv *.webp thumbnails/ && mv *.description descriptions/ && mv *.info.json metadata/ && echo "Moved files"
    fi
    ```
    
    ```bash
    #!/bin/bash
    yt-dlp --config-location /srv/dev-disk-by-uuid-fa1e36be-9ccc-4549-8734-fe6117b30317/croni/andre/andre/Archive/yt-dlp/yt-dlp_video.conf --download-archive youtube_backup_downloaded.txt --yes-playlist 'https://youtube.com/playlist?list=PLeEbifL6wH9okMEgTQP459RcTrjBWkF_b'
    ```
3. Execute these files however you want. I personally would recommend to set up a cron job to periodically download new videos. Example: ```bash
    nohup ./backup.sh > backup.log &
    ```
4. If you execute the command above your only way to know what yt-dlp is currently doing is to tail the log with `tail -f backup.log`
5. While waiting for the download to finish you can create the necessary directories to organize all your downloaded files. Example: ```bash
    #!/bin/sh
    
    if [ ! -d "video" ] ; then
    mkdir video && mkdir metadata && mkdir thumbnails && mkdir descriptions && echo "Created directories"
    fi
    ```
6. When the download is finished an you created the directories it is time to move them to their dedicated directory. Example: ```bash
    #!/bin/bash
    
    if compgen -G "*.mkv" > /dev/null ; then
    mv *.mkv video/ && mv *.webp thumbnails/ && mv *.description descriptions/ && mv *.info.json metadata/ && echo "Moved files"
    fi
    ```
7. You successfully archived an entire YouTube channel <span aria-label="rocket" class="emoji">🚀</span>

#### <span aria-label="rocket" class="emoji">Tips</span>

- <span aria-label="rocket" class="emoji">Make your files executable with `sudo chmod +x file.sh`</span>
- <span aria-label="rocket" class="emoji">You can execute the files with `./file.sh`</span>
- <span aria-label="rocket" class="emoji">This guide can be adapted to download playlist and even single videos</span>
    - <span aria-label="rocket" class="emoji">If you only want to download one video then remove `--yes-playlist`</span>