To change this I first created a new branch in the Github repo. Then I made the simple change, which really just involved changing the part of the link from "highlights_es.xml" to "mobile.xml". However, this didn't work for the videos from 2015. This is because I looped through each highlight taking "$media->url" as the URL to save. The problem is that there are multiple "url" XML tags and it was just taking the first. For 2016 the mp4 "FLASH_1200K_640X360" is listed first, but was fourth in 2015. Thus I had to loop through each of the URLs, checking what the tag said and only adding the one that was the mp4 I wanted.
The code below does this. It starts by setting an indicator to zero meaning that it hasn't found the mp4. Then it loops through each one, saving it as books (I copied it from another example about books), and adding the URL that is the mp4. If it doesn't find any, or finds more than one, it will show an error.
$someurladded = 0;foreach($media->url as $books) {if ($books->attributes()[0] =="FLASH_1200K_640X360") { // If the attribute value is this, it adds itarray_push($urls,$books);$someurladded = $someurladded + 1; // keep of track whether or not one has been added}}if ($someurladded == 0) { // if it didn't find the mp4, just take the first onearray_push($urls,$media->url[0]);echo 'Error 987235 no mp4 found';}if ($someurladded >1) {echo 'Error 3873259 added more than one URL';}
Once again, you can check it out here, and I plan to keep working on it in the near future.
No comments:
Post a Comment