ppvm.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class VideoEntry {
  3. public $type = null;
  4. public $label = null;
  5. public $filename = null;
  6. public $metadata = array();
  7. public function from_string($str) {
  8. $parts = explode(":", $str, 2);
  9. $data = explode(",", $parts[1], 3);
  10. $this->type = trim($parts[0]);
  11. $this->label = trim($data[0]);
  12. $this->filename = trim($data[1]);
  13. $meta = trim($data[2]);
  14. $properties = explode("\";", $meta);
  15. foreach ($properties as $property) {
  16. if($property == ""){
  17. continue;
  18. }
  19. $entry = explode("=\"", $property, 2);
  20. $this->metadata[trim($entry[0])] = trim($entry[1]);
  21. }
  22. }
  23. }
  24. class Ppvm {
  25. public $entries = array();
  26. public $metadata = array();
  27. public function from_string($str) {
  28. $parts = explode("\n\n", $str, 2);
  29. $lines = explode("\n", $parts[0]);
  30. foreach ($lines as $line) {
  31. if($line != "PPVM"){
  32. $entry = explode(":", $line, 2);
  33. $this->metadata[$entry[0]] = trim($entry[1]);
  34. }
  35. }
  36. $lines = explode("\n", $parts[1]);
  37. foreach ($lines as $line) {
  38. if($line == "" or $line[0] == "#") {
  39. continue;
  40. }
  41. $entry = new VideoEntry();
  42. $entry->from_string($line);
  43. array_push($this->entries, $entry);
  44. }
  45. }
  46. }
  47. ?>