Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #this will take a file of youtube links and convert them into a playlist of invidious audio links complete with the thumbnail as album art
- invidious='https://invidio.us';
- playlistoutputfile='./playlist.xspf';
- echo "creating $playlistoutputfile";
- cat >$playlistoutputfile <<EOT
- <?xml version="1.0" encoding="UTF-8"?>
- <playlist xmlns="http://xspf.org/ns/0/" xmlns:vlc="http://www.videolan.org/vlc/playlist/ns/0/" version="1">
- <title>Playlist</title>
- <trackList>
- EOT
- if [ -f "$1" ]; then
- for i in $(cat $1); do
- unset video audio title lengthinseconds lengthinmiliseconds image;
- video=$(echo $i |awk -F'/watch\\?v=' '{ print $2 }');
- audio="$invidious/latest_version?id=$video&itag=140";
- title=$(curl -k -s $invidious/api/v1/videos/$video|awk -F'"title":"' '{ print $2 }' |awk -F'","videoId":' '{ print $1 }'|sed 's/&/&/g');
- lengthinseconds=$(curl -s -k https://192.168.1.150/api/v1/videos/$video|awk -F'"lengthSeconds":' '{ print $2 }' |awk -F',"allowRatings":' '{ print $1 }');
- lengthinmiliseconds=$(($lengthinseconds*1000));
- image="$invidious/vi/$video/maxres.jpg";
- cat >>$playlistoutputfile <<EOT
- <track>
- <location>$audio</location>
- <title>$title</title>
- <duration>$lengthinmiliseconds</duration>
- <image>$image</image>
- <extension application="http://www.videolan.org/vlc/playlist/0">
- <vlc:id>0</vlc:id>
- <vlc:option>network-caching=1000</vlc:option>
- </extension>
- </track>
- EOT
- sleep 1;
- done
- fi
- cat >>$playlistoutputfile <<EOT
- </trackList>
- </playlist>
- EOT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement