X-Git-Url: https://git.jacobcasper.com/?p=Marketplaylister.git;a=blobdiff_plain;f=mpfuncs.php;h=d5be1440dc8def28a135c6f97a62ef9f5011744a;hp=870acafb22a0685509587c103f729e671d46513b;hb=HEAD;hpb=29d84c29eac4bafa7aa1370578bce9e8e0a8f2bc diff --git a/mpfuncs.php b/mpfuncs.php index 870acaf..d5be144 100644 --- a/mpfuncs.php +++ b/mpfuncs.php @@ -1,48 +1,16 @@ -hasAttribute('class') && $div->getAttribute('class') === 'episode-music') { - $songs = []; - foreach ($div->childNodes as $row) { - $children = $row->childNodes[0]->childNodes; - $songs[] = [ - 'title' => $children[0]->nodeValue, - 'artist' => $children[1]->nodeValue - ]; - } - $episodePage[] = $songs; - } - - } - - return $episodePage; - - } - - /** - * Go through the DOM elements provided and pull out the Dates of all marketplace - * pod episodes in the provided list. - * - * @param DomNodeList $headers The elements with a header tag from the DOM - * @param DateTime $lastDate The date of the most recent episode from the DB - */ - function parseEpisodeDate(DomNodeList $headers, DateTime $lastDate): array { - $episodeDates = []; - foreach ($headers as $header) { - if ($header->hasAttribute('class') && $header->getAttribute('class') === 'river--hed') { - $episodeAnchorHref = $header->firstChild->getAttribute('href'); - $dateString = explode('/', $episodeAnchorHref)[3]; - $episodeDate = DateTime::createFromFormat(DATE_FORM, $dateString); - if ($episodeDate < $lastDate) { - break; - } - $episodeDates[] = $episodeDate; - } - } - return $episodeDates; - } +hasAttributes() + && $child->attributes->getNamedItem('class')->value == $class; + } + ); +}