3 const DATE_FORM
= 'm/d/Y';
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 $dateStringParts = explode('/', explode(':', $header->nodeValue
)[0]);
39 if ( strlen($dateStringParts[2]) === 2 ) {
40 $dateStringParts[2] = '20' . $dateStringParts[2];
42 $episodeDate = DateTime
::createFromFormat(DATE_FORM
, implode("/", $dateStringParts));
43 if ($episodeDate < $lastDate) {
46 $episodeDates[] = $episodeDate;