Script to find Youtube video id.

Dingo001

New Member
I have been using a script to find the last video uploaded to my account for a few years. For about the last week I have had to manually add the video id to am embed code because the code did not find the video ID.

Has there been a change that I missed. The code I use is below.

Code:
#!/bin/bash
#
# Script to find last video id from my channel and create an embed code to put in a file.
# Need to replace the Working directory and Your channel id for this to work
#

date

# work from
cd working directory
# Define RSS feed for your channel
URL="https://www.youtube.com/feeds/videos.xml?channel_id=Your Channel ID
videoid=$(curl -s $URL | grep "/watch?v=" | head -1 | sed "s/.*\?v=\([^\"]*\)\".*/\1/g")
echo $videoid
echo Last Video ID = $videoid
s="<center><iframe width=\"640\" height=\"480\""
s="$s src=\"https://www.youtube.com/embed/${videoid}?feature=player_embedded\""
s="$s frameborder=\"0\" allowfullscreen></iframe></center>"

echo "$s" > youtube-iframe.php

echo Copy complete and Youtube-iframe file copied over to html
date
cp youtube-iframe.php web site folder
 
Back
Top