Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 29, 2012, 11:21 AM   #1
newtoiphonesdk
macrumors 6502a
 
Join Date: Jul 2010
PHP to parse podcast

I use FeedForAll RSS 2 HTML PHP Script, and am having some issues. The podcast I am parsing has two different URL links in it. One goes to their website with details about the episode, and the other goes to the actual mp3. They are labeled link, and guid respectively in the xml. The issue I have is this: On click of the episode, the browser is going to the link URL and I would like for it go to to the GUID URL. I have looked through the script, but cannot figure out where to make the change. Here is the script in its entirety.:
script.zip

Last edited by newtoiphonesdk; Mar 30, 2012 at 05:56 PM. Reason: Resolved
newtoiphonesdk is offline   0 Reply With Quote
Old Mar 29, 2012, 04:07 PM   #2
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Quote:
Originally Posted by newtoiphonesdk View Post
I use FeedForAll RSS 2 HTML PHP Script, and am having some issues. The podcast I am parsing has two different URL links in it. One goes to their website with details about the episode, and the other goes to the actual mp3. They are labeled link, and guid respectively in the xml. The issue I have is this: On click of the episode, the browser is going to the link URL and I would like for it go to to the GUID URL. I have looked through the script, but cannot figure out where to make the change. Here is the script in its entirety.:
Attachment 333015
That why would the URL not be what you want, but instead GUID is right? In this context I would guess that GUID stands for "Globally unique identifier" and is usually 32 hex digits.

Where does the data come from? Do you have control over it?

EDIT: Ok maybe I should read better. For my misunderstanding I'll look at the script you uploaded.
jared_kipe is offline   0 Reply With Quote
Old Mar 29, 2012, 05:07 PM   #3
newtoiphonesdk
Thread Starter
macrumors 6502a
 
Join Date: Jul 2010
Quote:
Originally Posted by jared_kipe View Post
That why would the URL not be what you want, but instead GUID is right? In this context I would guess that GUID stands for "Globally unique identifier" and is usually 32 hex digits.

Where does the data come from? Do you have control over it?

EDIT: Ok maybe I should read better. For my misunderstanding I'll look at the script you uploaded.
Thanks, also, here is a snippet from the XML Source. The item "LINK" is what is now being opened when you click the episode on the php script I had uploaded. I need to open the url from the "ENCLOSURE" or the "GUID" item.
Code:
		<title>The Big Hunt</title>
		<link>http://www.smcoc.net/index.php?option=com_biblestudy&amp;view=studydetails&amp;id=301&amp;templatemenuid=20&amp;Itemid=1</link>
		<comments>http://www.smcoc.net/index.php?option=com_biblestudy&amp;view=studydetails&amp;id=301&amp;templatemenuid=20&amp;Itemid=1</comments>

		<itunes:author>Dale Jenkins</itunes:author>
		<dc:creator>Dale Jenkins</dc:creator>
		<description>SUNDAY AM: Jesus: The Parables and the People</description>
		<content:encoded>SUNDAY AM: Jesus: The Parables and the People</content:encoded>
		<pubDate>Sun, 11 Mar 2012 11:43:33 -0400</pubDate>
		<itunes:subtitle>The Big Hunt</itunes:subtitle>

		<itunes:summary>SUNDAY AM: Jesus: The Parables and the People</itunes:summary>
		<itunes:keywords>church of christ, sermon, spring meadows</itunes:keywords>
		<itunes:duration>00:34:46</itunes:duration><enclosure url="http://www.smcoc.net/content/audio/sermons/2012/2012_03_11am_the_big_hunt.mp3" length="7644119" type="" />
				<guid>http://www.smcoc.net/content/audio/sermons/2012/2012_03_11am_the_big_hunt.mp3</guid>
newtoiphonesdk is offline   0 Reply With Quote
Old Mar 29, 2012, 05:23 PM   #4
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Ok, this was non trivial given the fact that I had to write my own implementation for FeedForAll_scripts_readFile($file, $notused) and comment out a lot of other stuff that doesn't work without whatever supporting files need to be in place.

Find the line that looks like this.
Code:
$template = FeedForAll_rss2html_str_replace("~~~FeedLink~~~", FeedForAll_rss2html_EscapeLink($rss_parser->FeedLink), $template);
Replace it with this.
Code:
$start = strpos($XML, '<guid>');
$end = strpos($XML, '</guid>');
$guidValue = null;
if ($start !== false && $end !== false) {
	$guidValue = substr($XML, $start + 6, $end - $start - 6);
	//die($guidValue);
} 
$link = ($guidValue)?$guidValue:FeedForAll_rss2html_EscapeLink($rss_parser->FeedLink);
$template = FeedForAll_rss2html_str_replace("~~~FeedLink~~~", $link, $template);
//$template = FeedForAll_rss2html_str_replace("~~~FeedLink~~~", FeedForAll_rss2html_EscapeLink($rss_parser->FeedLink), $template);
Note that this is best guess based on me not being able to run the script to completion and just relying on die()'s and var_dump()'s to work out what is supposed to happen. For example, the rss container class "baseParserClass()" doesn't seem to implemented in this file and doesn't seem to be a stock php class.

This solution will gracefully fail on anything that doesn't have <guid> elements, but will not gracefully fail on things that have <guid> elements that are not the links you are looking for.

Last edited by jared_kipe; Mar 29, 2012 at 05:34 PM.
jared_kipe is offline   0 Reply With Quote
Old Mar 29, 2012, 06:02 PM   #5
newtoiphonesdk
Thread Starter
macrumors 6502a
 
Join Date: Jul 2010
Quote:
Originally Posted by jared_kipe View Post
Ok, this was non trivial given the fact that I had to write my own implementation for FeedForAll_scripts_readFile($file, $notused) and comment out a lot of other stuff that doesn't work without whatever supporting files need to be in place.
Note that this is best guess based on me not being able to run the script to completion and just relying on die()'s and var_dump()'s to work out what is supposed to happen. For example, the rss container class "baseParserClass()" doesn't seem to implemented in this file and doesn't seem to be a stock php class.
Sorry about that, I forgot that there was another .php that it relied upon to complete. That .php is attached to this reply. I tried the solution you had posted, but it still was referencing the LINK of the XML and not the GUID element URL.FeedForAll_XMLParser.inc.php.zip

EDIT: These May also be needed alsoneeded.zip

Last edited by newtoiphonesdk; Mar 29, 2012 at 06:07 PM. Reason: Also needed
newtoiphonesdk is offline   0 Reply With Quote
Old Mar 29, 2012, 11:57 PM   #6
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
Quote:
Originally Posted by newtoiphonesdk View Post
Sorry about that, I forgot that there was another .php that it relied upon to complete. That .php is attached to this reply. I tried the solution you had posted, but it still was referencing the LINK of the XML and not the GUID element URL.Attachment 333095

EDIT: These May also be needed Attachment 333096
Uncomment out the //die line and see if you get the first GUID link.
jared_kipe is offline   0 Reply With Quote
Old Mar 30, 2012, 12:30 AM   #7
newtoiphonesdk
Thread Starter
macrumors 6502a
 
Join Date: Jul 2010
Quote:
Originally Posted by jared_kipe View Post
Uncomment out the //die line and see if you get the first GUID link.
Yes, uncommented it, uploaded it, and then navigated in browser and it displayed the URL for the first GUID link.
newtoiphonesdk is offline   0 Reply With Quote
Old Mar 30, 2012, 11:25 AM   #8
jared_kipe
macrumors 68030
 
jared_kipe's Avatar
 
Join Date: Dec 2003
Location: Seattle
Send a message via AIM to jared_kipe
In the more recent file you uploaded, that includes the XML parser.

Find:
Code:
case "GUID":
$this->currentItem->guid .= $data;
break;
Make it:
Code:
case "GUID":
$this->currentItem->guid .= $data;
$this->currentItem->link = $data;
break;
This will work. Though I'm honestly not sure why the original fix didn't work. That code path must not be taken due to some newer code or something.

EDIT: Ok I see why my original fix didn't work, it was replacing FeedLink which is not the same as the individual ITEMLinks. The actual parsing of individual items is left 100% up to that second file you uploaded. Also oddly, it seems that it at least partially supports using <guid> tags as the links given the setting of the ivar $guidIsPermaLink which it sets based on an attribute of the <guid> tag itself (that isn't there on this feed). However this original base class does not in fact ever use this attribute/ivar for any calculation of the item link. It must be intended for one to subclass the parser to implement that feature. (not that it would help since its not set on this feed).

EDIT2: Oh and I forgot to mention, you can remove the earlier code change. Just roll back to the original file you uploaded, and implement the change in the second one.

Last edited by jared_kipe; Mar 30, 2012 at 11:45 AM.
jared_kipe is offline   0 Reply With Quote
Old Mar 30, 2012, 05:55 PM   #9
newtoiphonesdk
Thread Starter
macrumors 6502a
 
Join Date: Jul 2010
Quote:
Originally Posted by jared_kipe View Post
In the more recent file you uploaded, that includes the XML parser.

Find:
Code:
case "GUID":
$this->currentItem->guid .= $data;
break;
Make it:
Code:
case "GUID":
$this->currentItem->guid .= $data;
$this->currentItem->link = $data;
break;
This will work. Though I'm honestly not sure why the original fix didn't work. That code path must not be taken due to some newer code or something.

EDIT: Ok I see why my original fix didn't work, it was replacing FeedLink which is not the same as the individual ITEMLinks. The actual parsing of individual items is left 100% up to that second file you uploaded. Also oddly, it seems that it at least partially supports using <guid> tags as the links given the setting of the ivar $guidIsPermaLink which it sets based on an attribute of the <guid> tag itself (that isn't there on this feed). However this original base class does not in fact ever use this attribute/ivar for any calculation of the item link. It must be intended for one to subclass the parser to implement that feature. (not that it would help since its not set on this feed).

EDIT2: Oh and I forgot to mention, you can remove the earlier code change. Just roll back to the original file you uploaded, and implement the change in the second one.
Brilliant! Thank you SOOO Much! Works perfect!
newtoiphonesdk is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
[php] - php problems os x mountain lion 10.8.2 cakas6933 OS X 10.8 Mountain Lion 4 Jun 10, 2014 08:08 AM
iPhone: Unable to parse IPSW Hackills Jailbreaks and iOS Hacks 7 May 14, 2014 10:34 PM
How should I parse HTML5? ArtOfWarfare iPhone/iPad Programming 2 Aug 21, 2013 06:20 PM
C++ include and parse issues dmatter Mac Programming 0 Feb 7, 2013 05:18 PM
Parse Local Weather newtoiphonesdk iPhone/iPad Programming 1 Sep 1, 2012 05:30 PM

Forum Jump

All times are GMT -5. The time now is 01:40 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC