but it won't stop the linkrot
we need to get the title of the videos listed in text in posts.
i asked chatgpt:
To scrape metadata from YouTube using PHP, you can use the YouTube Data API provided by Google. Here's a basic script to retrieve metadata (title, description, and thumbnail) for a YouTube video:
php
Code:
<?php
// Replace with your own API key
$api_key = 'YOUR_API_KEY';
// Replace with the video ID you want to retrieve metadata for
$video_id = 'VIDEO_ID';
// Build the API URL
$url = 'https://www.googleapis.com/youtube/v3/videos?id=' . $video_id . '&key=' . $api_key . '&part=snippet';
// Make a GET request to the API and parse the response
$response = file_get_contents($url);
$json = json_decode($response, true);
// Extract the metadata
$title = $json['items'][0]['snippet']['title'];
$description = $json['items'][0]['snippet']['description'];
$thumbnail = $json['items'][0]['snippet']['thumbnails']['medium']['url'];
// Output the metadata
echo 'Title: ' . $title . '<br>';
echo 'Description: ' . $description . '<br>';
echo 'Thumbnail: <img src="' . $thumbnail . '">';
?>
Note that you need to obtain an API key from the Google Cloud Console and enable the YouTube Data API for your project. Also, this script only retrieves metadata for one video at a time. If you want to scrape metadata for multiple videos, you need to use the API's search or playlist endpoints and loop through the results.
so we'd just need to somehow convert that to a plugin for this type of forum and bob's your uncle, maybe i'll ask ANdy B