3 const DATE_FORM
= 'mdY';
6 function parseEpisodePage(DomNodeList
$divs): array {
8 foreach ($divs as $div) {
9 if ($div->hasAttribute('class') && $div->getAttribute('class') === 'episode-music') {
11 foreach ($div->childNodes
as $row) {
12 $children = $row->childNodes
[0]->childNodes
;
14 'title' => $children[0]->nodeValue
,
15 'artist' => $children[1]->nodeValue
18 $episodePage[] = $songs;
28 * Go through the DOM elements provided and pull out the Dates of all marketplace
29 * pod episodes in the provided list.
31 * @param DomNodeList $headers The elements with a header tag from the DOM
32 * @param DateTime $lastDate The date of the most recent episode from the DB
34 function parseEpisodeDate(DomNodeList
$headers, DateTime
$lastDate): array {
36 foreach ($headers as $header) {
37 if ($header->hasAttribute('class') && $header->getAttribute('class') === 'river--hed') {
38 $episodeAnchorHref = $header->firstChild
->getAttribute('href');
39 $dateString = explode('/', $episodeAnchorHref)[3];
40 $episodeDate = DateTime
::createFromFormat(DATE_FORM
, $dateString);
41 if ($episodeDate < $lastDate) {
44 $episodeDates[] = $episodeDate;