PLEX, PHP, PCH A-200 and XML Sandbox

Some basic findings of how all this works
After searching many pages finding little bits and pieces of here and there I thought I would try to figure some of this PLEX stuff out in a simple form.
This comes from the need to have a PLEX client for my Popcornhour A-200 and not finding anything simple that I can muck around in.

So here we go for anyone interested.

I have a QNAP 809 pro, webserver, php and PCH. All the movies are set up on share called Animation.

The php script I have made up just reads the XML PLEX output and re-formats it into a listing of the movies. This files source can be saved in .htm format to the root of the share. The PCH A-200 can read this simple .htm listing and allow you to play a movie from the listing. Done.

Well kind of done. I plan to have the .htm automatically generated and saved to the share. I also plan on adding pages and more info from the PLEX data.

Here is the php code...


<?php<br />
<br />
$file = "http://10.0.0.7:32400/library/sections/1/all"; 												// set location of PLEX output<br />
$xml = simplexml_load_file($file) or die ("Unable to load XML file!"); 									// load file<br />
$x=0; 																									// set counter index to 1<br />
	foreach($xml->children() as $video){ 																// Gets the children of a specified node (Video)<br />
						$c =  $video['thumb'];															// set $c = the PLEX video thumbnail<br />
						foreach($video->children() as $media => $part){  								// Gets the children of a specified node (Media)<br />
							$a = rawurlencode(substr($part->Part['file'],44)); 							// Print the Attribute to the screen<br />
							$b = substr($part->Part['file'],44);										// Do a MID string of PLEX path and leave only the part we need<br />
								if ($a == null){														// check if $a is blank<br />
																										// print nothing<br />
								} else {																// Print something<br />
								$x=$x+1; 																// inc the index by one<br />
								echo $x . ' - <a class="link" href="file:///opt/sybhttpd/localhost.drives/NETWORK_SHARE/Animation/'; 		// create popcornhour links	(Animation is the PCH Share)<br />
								echo $a;																// $a = path is formated to be browser compatable<br />
								echo '" TVID="Play" zcd="2" vod="">' . $b . '</a><br>'; 				// Close PCH linkput a return on the end of the line<br />
								}																		// End of Else statement<br />
							}																			// End of nested Loop<br />
	}																									// End of main Loop<br />
?>



Feel free to modify or add whatever you like. I have tried to make this dead simple, to start.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.