Alright, I've posted a similar post in the RSS and XML forums, but I've come to the realization that we are going to need some programming. Problem: Using MagpieRSS I have parsed an RSS feed like this one (YouTube video feed): http://youtube.com/rss/global/recently_added.rss Now I know how to use MagpieRSS. (It's relatively simple). Notice the description of one item: <description> <img src="[B]http://sjc-static9.sjc.youtube.com/vi/Dbxi3I1Uh1Y/2.jpg[/B]" align="right" border="0" width="120" height="90" vspace="4" hspace="4" /> <p>[B]Brenda doing the lean back[/B]</p> <p>Author: <a href="http://youtube.com/profile?user=atl4lyfe06">atl4lyfe06</a><br/> Keywords: <a href="/results?search_query=lean">lean</a> <a href="/results?search_query=back">back</a> <a href="/results?search_query=brenda">brenda</a> <a href="/results?search_query=funny">funny</a> <a href="/results?search_query=lol">lol</a><br/> Added: February 23, 2007<br/> </p> </description> Code (markup): Stuff in Bold is what I want to extract. If I strip tags from the description I lose all this. Secondly there is also media tags that are in here as well. I want to extract what's bold. <guid isPermaLink="true">[B]http://youtube.com/?v=Dbxi3I1Uh1Y[/B]</guid> <media:player url="[B]http://youtube.com/?v=Dbxi3I1Uh1Y[/B]" /> <media:thumbnail url="[B]http://sjc-static9.sjc.youtube.com/vi/Dbxi3I1Uh1Y/2.jpg[/B]" width="120" height="90" /> <media:title>[B]Brenda's Lean Back[/B]</media:title> <media:category label="Tags">[B]lean back brenda funny lol[/B]</media:category> <media:credit>atl4lyfe06</media:credit> Code (markup): This has the similar information to what I wanted on top. GOAL: I want to be able to display (eg. a YouTube Feed) Like So: ---------------------- | Video Thumbnail | | | ---------------------- title (got this part don't need help with this) Then when someone clicks on the title or Thumbnail I want to have send them to a window where I can embed the YouTube Player and use the URL to do so. Then the viewer can view it. CONCLUSION: Can I somehow using CSS or PHP extract the following from the RSS description: Video Thumbnail SRC Video File SRC Description How do I go about doing this? (Excuse the long post). Skinny
You need a bit of REGular EXPressions: http://php.net/manual/en/function.preg-match.php For example to extract the thumbnail from the first block of code you provided you can do: if (preg_match('/<img src="([^"])+/', $description, $matches)) { $thumbnail = $matches[1]; } PHP: HTH, cheers!
Thanks picouli I found this code and it works: preg_match('/img src="(.*)\.jpg"/',$item["description"],$imgUrlMatches); $imgurl = $imgUrlMatches[0]; echo "<$imgurl>"; Code (markup): There's only one problem since images in Google Videos Feed are in this format <img src="http://video.google.com/ThumbnailServer2?app=vss&contentid=9510d63ef67c20ad&offsetms=1305000&itag=w320&lang=en&sigh=Mzx5bZhRZ3UGvIUsnn90Q1OPdEE"> Code (markup): I tried to get edit my code like this so that it didn't rely on the .jpg. But it doesn't work. Do you know how to just get img src = "http://video.google.com/ThumbnailServer2?app=vss&contentid=9510d63ef67c20ad&offsetms=1305000&itag=w320&lang=en&sigh=Mzx5bZhRZ3UGvIUsnn90Q1OPdEE" Code (markup): I did get it once (I'm trying to fool around with it). but for some reason after displaying the image it also displayed the description underneath the image, which was odd. I'm trying to find that little editing I did. I'll post it if I cand duplicate it. Skinny
Try this: preg_match('/img src="([^"]+)"/',$item["description"],$imgUrlMatches); PHP: let me know if it helps...
picouli you are a genius. BTW can you explain it in english exactly what you are doing. I get what the preg_ match does in it's basic form, but I don't get what you are doing. And I'd like to learn. (You can PM me if you like.) Edit: I'd rep you but I'm forced to spread it around . Skinny
Skinny the preg uses regular expressions to match the string google regular expressions for a tutorial on what they mean, but basically it reads something like this: /img src="([^"]+)"/' match the string starting img src=" then match any letters that are NOT " up until it reaches a " So basically it extract the bit in the middle where it needs to, read up on it for a definitive answer as I was just freestyling there What you may want to do next [which ive done in an rss reader i made] is to actually download the image off googles server, resize it to your needs and save it on your local server. To do this you need a php download script [again you can google this] using fread or sockopen. Then you may want to resize and save the image in php This means that if the google severs are down you will have a local copy. It also means you can save the image using an search engine optimized filename i.e. img/thumbs/video_of_man_falling.png Anyway I am kinda off point, but the possibility is there if you want to do it.