Here is a Bourne shell script which I use to automaticly download youtube and dailymotion videos from chanels that I like. It needs youtube-dl and curl to work.


#! /bin/bash
# version 1.0
# 2016.02.22 first version
# this script automaticly download videos from youtube and dailymotion
#youtube-dl update
youtube-dl -U

DATE=$(/bin/date --date='1 days ago' '+%Y%m%d')
DATECHROMA=$(/bin/date --date='3 days ago' '+%Y%m%d')

$PROG --playlist-end 10 --dateafter $DATECHROMA -o '/data/%(uploader)s/%(upload_date)s_%(title)s-%(id)s.%(ext)s'
#france inter
$PROG --playlist-end 20 --match-title "Le Zoom de La Rédaction" --dateafter $DATE -o '/data/franceinter/%(upload_date)s.%(title)s-%(id)s.%(ext)s'
$PROG --playlist-end 20 --match-title "Le.*Zoom.*" --dateafter $DATE -o '/data/franceinter/%(upload_date)s.%(title)s-%(id)s.%(ext)s'

$PROG --playlist-end 5 --dateafter $DATE -o '/data/%(uploader)s/%(upload_date)s_%(title)s-%(id)s.%(ext)s'
$PROG --playlist-end 5 --dateafter $DATE -o '/data/antoinedaniel/%(uploader)s/%(upload_date)s_%(title)s-%(id)s.%(ext)s'
$PROG --playlist-end 5 --dateafter $DATE -o '/data/antoinedaniel/%(uploader)s/%(upload_date)s_%(title)s-%(id)s.%(ext)s'
$PROG --playlist-end 10 --dateafter $DATE -o '/data/%(uploader)s/%(upload_date)s.%(title)s-%(id)s.%(ext)s'

JOUR=$(/bin/date --date='1 days ago' '+%d' | sed 's/^0//')
JOUR2=$(/bin/date '+%d' | sed 's/^0//')
MOIS=$(/bin/date '+%B' | sed -e 's/é/e/' -e 's/û/u/')
MOIS2=$(/bin/date '+%m')
ANNEE=$(/bin/date '+%Y')
#I don't know why but sometimes youtube-dl fails to download the videos, so I have to repeat the process
for i in $(seq 10)
        curl | grep "h2.*post.*$JOUR.*$MOIS.*$ANNEE" && $PROG -o /data/zap-tele/$ANNEE$MOIS2$JOUR'.%(title)s-%(id)s.%(ext)s'$(curl | grep "h2.*post.*$JOUR.*$MOIS.*$ANNEE" | sed -e 's/.*="//' -e 's/">.*//')
        curl | grep "h2.*post.*$JOUR2.*$MOIS.*$ANNEE" && $PROG -o /data/zap-tele/$ANNEE$MOIS2$JOUR2'.%(title)s-%(id)s.%(ext)s'$(curl | grep "h2.*post.*$JOUR2.*$MOIS.*$ANNEE" | sed -e 's/.*="//' -e 's/">.*//')
        sleep 1

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Contact :