Rebstrike
Posts: 1
Joined: Wed Jul 17, 2019 10:21 pm

Need Help Making a Program that Detects When a YouTuber Uploads a Video

Wed Jul 17, 2019 11:36 pm

I'm trying to make a program where it will check if a YouTuber has uploaded a video, and if they have, turn on an LED. I'm just having a hard time figuring out the code. If any of you guys can help me, please let me know.

Andyroo
Posts: 3832
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Need Help Making a Program that Detects When a YouTuber Uploads a Video

Thu Jul 18, 2019 12:12 am

Try looking at the page for the YouTubers videos e.g.
https://www.youtube.com/user/bensdmkII/ ... pp=desktop (link safe for work and home)
Then use Beautiful Soup to scrape the page

Look for the

Code: Select all

<a id="video-title"
and if the first one does not match the last time you looked it’s a new video.

So the process becomes:
1) Create a ‘last video’ file with nothing in it
2) Use Python ‘requests’ module to get the page of the YouTuber you are watching
3) Use Beautiful Soup to extract the video titles
4) If first title matches file contents exit the program
5) Save the new title to the ‘last video’ file
6) Light the LED
7) Exit

You will also need a little program to turn off the LED and maybe launch the video...

Note this will fail if the last video is deleted (as the second will become the ‘new’ first) or YouTube changes layout...
Need Pi spray - these things are breeding in my house...

Return to “Automation, sensing and robotics”