Update README because I forgot how to develop this app.
[Marketplaylister.git] / mpfuncs.php
index a35c89f..d5be144 100644 (file)
@@ -1,26 +1,16 @@
-<?php\r
-    \r
-    function parseEpisodePage(DomNodeList $divs, int &$numDays): array {\r
-        $episodePage = [];\r
-        foreach ($divs as $div) {\r
-            if ($div->hasAttribute('class') && $div->getAttribute('class') === 'episode-music') {\r
-                if (!$numDays) {\r
-                    break;\r
-                }\r
-                $songs = [];\r
-                foreach ($div->childNodes as $row) {\r
-                    $children = $row->childNodes[0]->childNodes;\r
-                    $songs[] = [\r
-                        'title' => $children[0]->nodeValue,\r
-                        'artist' => $children[1]->nodeValue\r
-                    ];\r
-                }\r
-                $numDays--;\r
-                $episodePage[] = $songs;\r
-            }\r
-            \r
-        }\r
-        \r
-        return $episodePage;\r
-        \r
-    }
\ No newline at end of file
+<?php
+
+const DATE_FORM = 'mdY';
+
+function findChildWithClass(/** iterable */ $children, string $class)/**: array*/ {
+    if ($children instanceof Traversable) {
+        $children = iterator_to_array($children);
+    }
+    return array_filter(
+        $children,
+        function($child) use ($class) {
+            return $child->hasAttributes()
+                && $child->attributes->getNamedItem('class')->value == $class;
+        }
+    );
+}