Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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.:
View attachment script.zip
 
Last edited:

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
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.:
View 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.
 

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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&view=studydetails&id=301&templatemenuid=20&Itemid=1</link>
		<comments>http://www.smcoc.net/index.php?option=com_biblestudy&view=studydetails&id=301&templatemenuid=20&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>
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
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:

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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. View attachment FeedForAll_XMLParser.inc.php.zip

EDIT: These May also be needed View attachment alsoneeded.zip
 
Last edited:

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
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. View attachment 333095

EDIT: These May also be needed View attachment 333096

Uncomment out the //die line and see if you get the first GUID link.
 

jared_kipe

macrumors 68030
Dec 8, 2003
2,967
1
Seattle
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:

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
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!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.