Create a backup list of my favourite YouTube videos, extract audio

I am using youtube-dl utility almost daily. I have directory with by favourite YouTube videos and I want to create a backup of this list. Not the actual content but only the YouTube ID's

Here is the thinking steps to actually get to solution:
List all files in directory by showing only filename and file extension:
ls -1
Monster Winer - Kerwin Du Bois & Lil Rick - Marlon Alves Dance MAs-CX-dRfhbzpA.mp4
My Songs know What You Did In The Dark (Light Em Up) - Fall Out Boy - Marlon Alves Dance MAs-ulgtWbARfV4.mp4
grep only mp4 files which suposed to be a youtube content:
ls -1 | grep '\-.\{11\}\.mp4$'
Cut off the mp4 file extension:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g'
This will now show:
Monster Winer - Kerwin Du Bois & Lil Rick - Marlon Alves Dance MAs-CX-dRfhbzpA
My Songs know What You Did In The Dark (Light Em Up) - Fall Out Boy - Marlon Alves Dance MAs-ulgtWbARfV4
Reverse the content of characters:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev
This will show:
ApzbhfRd-XC-sAM ecnaD sevlA nolraM - kciR liL & sioB uD niwreK - reniW retsnoM
4VfRAbWtglu-sAM ecnaD sevlA nolraM - yoB tuO llaF - )pU mE thgiL( kraD ehT nI diD uoY tahW wonk sgnoS yM
Now I cut the first 11 characters:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev | cut -c 1-11
This will show:
ApzbhfRd-XC
4VfRAbWtglu
But I need to reverse back the line content:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev | cut -c 1-11 | rev
The output is:
CX-dRfhbzpA
ulgtWbARfV4
Now I can actually put ID's in file:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev | cut -c 1-11 | rev > ~/favourite.videos.list
To create backup just exactly for youtube-dl utility I use:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev | cut -c 1-11 | rev | sed 's/^/youtube /g' > ~/git/rpi-stretch/home/.config/youtube-dl/boost.list
If I want to send these video ID's in email it is a good thing to add full url:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev | cut -c 1-11 | rev | sed 's/^/https:\/\/www\.youtube\.com\/watch?v=/g'
The output is:
https://www.youtube.com/watch?v=CX-dRfhbzpA
https://www.youtube.com/watch?v=ulgtWbARfV4
Appendix:
If I want to extract only audio for those videos and put it on the phone then I use:
ls -1 | grep '\-.\{11\}\.mp4$' | sed 's/\.mp4//g' | rev | cut -c 1-11 | rev | sed 's/^/https:\/\/www\.youtube\.com\/watch?v=/g' | xargs youtube-dl -f140
redownload:
grep youtube files.log | sed 's/^youtube /https:\/\/www\.youtube\.com\/watch?v=/g' | xargs youtube-dl -f140
Another:
grep youtube files.log | sed 's/^youtube /https:\/\/www\.youtube\.com\/watch?v=/g' | xargs youtube-dl -i --config-location youtube-dl.conf

No comments: