diff --git a/parse_rss.php b/parse_rss.php
index e8b8c91..63e47a3 100644
--- a/parse_rss.php
+++ b/parse_rss.php
@@ -1,34 +1,100 @@
channel->title;
- $feeds = array();
+ // Check if the provided URL is a YouTube RSS feed
+ if (strpos($rssUrl, 'youtube.com/feeds/videos.xml') !== false) {
+ // Load the YouTube RSS feed
+ $feedContent = file_get_contents($rssUrl);
- foreach ($feed->channel->item as $item) {
- $title = (string) $item->title;
- $date = (string) $item->pubDate;
- $content = (string) $item->description;
+ // Extract the channel title
+ preg_match('/
(.*?)<\/title>/i', $feedContent, $titleMatches);
+ $channelTitle = $titleMatches[1];
- $feeds[] = array(
- 'title' => $title,
- 'date' => $date,
- 'content' => $content
+ // Extract the videos
+ preg_match_all('/(.*?)<\/entry>/is', $feedContent, $videoMatches);
+ $videoData = $videoMatches[1];
+
+ if (!empty($videoData)) {
+ $feeds = array();
+
+ foreach ($videoData as $video) {
+ // Extract the video title
+ preg_match('/]*>(.*?)<\/title>/i', $video, $titleMatches);
+ $title = $titleMatches[1];
+
+ // Extract the published date
+ preg_match('/(.*?)<\/published>/i', $video, $dateMatches);
+ $date = $dateMatches[1];
+
+ // Extract the video ID
+ preg_match('/(.*?)<\/yt:videoId>/i', $video, $videoIdMatches);
+ $videoId = $videoIdMatches[1];
+
+ // Build the video URL
+ $videoUrl = 'https://www.youtube.com/watch?v=' . $videoId;
+
+ // Extract the video descriptions
+ preg_match_all('/(.*?)<\/media:description>/is', $video, $descriptionMatches);
+ $descriptions = $descriptionMatches[1];
+
+ // Generate the video content
+ $content = '';
+ foreach ($descriptions as $description) {
+ $content .= '' . $description . '
';
+ }
+
+ $feeds[] = array(
+ 'title' => $title,
+ 'date' => $date,
+ 'content' => $content
+ );
+ }
+
+ $feedTitle = 'YouTube Channel: ' . $channelTitle;
+
+ $response = array(
+ 'success' => true,
+ 'feedTitle' => $feedTitle,
+ 'feeds' => $feeds
+ );
+ } else {
+ $response = array(
+ 'success' => false,
+ 'message' => 'No videos found for the provided YouTube channel.'
);
}
-
- $response = array(
- 'success' => true,
- 'feedTitle' => $feedTitle,
- 'feeds' => $feeds
- );
} else {
- $response = array(
- 'success' => false,
- 'message' => 'Failed to parse RSS feed.'
- );
+ // Handle standard RSS and Atom feeds as before
+ $feed = simplexml_load_file($rssUrl);
+
+ if ($feed) {
+ $feedTitle = (string) $feed->channel->title;
+ $feeds = array();
+
+ foreach ($feed->channel->item as $item) {
+ $title = (string) $item->title;
+ $date = (string) $item->pubDate;
+ $content = (string) $item->description;
+
+ $feeds[] = array(
+ 'title' => $title,
+ 'date' => $date,
+ 'content' => $content
+ );
+ }
+
+ $response = array(
+ 'success' => true,
+ 'feedTitle' => $feedTitle,
+ 'feeds' => $feeds
+ );
+ } else {
+ $response = array(
+ 'success' => false,
+ 'message' => 'Failed to parse RSS feed.'
+ );
+ }
}
} else {
$response = array(