3 users online. Create an account or sign in to join them.Users
Dynamic XML datasource with multiple entries
This is an open discussion with 4 replies, filed under General.
Search
Sounds like you’ll need to customize your dynamic XML DS to iterate over the available Youtube keys and fetch the XML data one-by-one. Then you can build the XML however you like.
Sorry to bring up this old post but i've ran into the same situation.
I've readed at stackoverflow i can query several videos info by id using a query like:
http://gdata.youtube.com/feeds/api/videos?q=videoid-1|videoid-2|videoid-3
If i could simply add a replace funcion in the DS, something like this imaginary dynamic XML datasource.
http://gdata.youtube.com/feeds/api/videos?q={replace($param,', ','|')}
Is this doable? I know you can do some advanced regexp and filtering in DS filter fields, that's why i ask.
If this can't be done i guess i need to create a custom datasource. This datasource would take as param a videos id list and perform the youtube batch api operation. I guess that would be much better than 30 or 40 unique requests for a video list page.
To be honest, i readed the datasources related code and i'm not sure on how to proceed "correctly", any tip, just a pointer on how to get started will be much apreciated.
My final goal is to easily use youtube stored data, things like publish date, thumbnails, duration, etc.
First attempt:
I edited the dynamic xml datasource and changed the default include in the grab function:
try{
include(TOOLKIT . '/data-sources/datasource.youtube_dynamic_xml.php');
}
datasource.youtube_dynamic_xml.php is a copy of datasource.dynamic_xml.php where i added a str_replace line:
if(isset($this->dsParamURL)){
$params = findParametersInString($this->dsParamURL);
foreach($params as $key => $info){
$replacement = $this->__processParametersInString($info['param'], $this->_env, false);
if($info['encode'] == true){
$replacement = urlencode($replacement);
}
$this->dsParamURL = str_replace("{{$key}}", $replacement, $this->dsParamURL);
//custom line.
$this->dsParamURL = str_replace(",", "|", $this->dsParamURL);
}
}
While i achieved what i wanted it feels a bit dirty. Also, it did not solve my problem since the suggested youtube query using "|" and video ids is not very trustable, it breaks when a video id has a "-" character.
Just wanted to explain the dirty hack i tried so i may get corrected.
My next step is diggin more into youtube api.
I've found this "Youtube Videos" extension. It solves all my needs.
Create an account or sign in to comment.
Hi,
I have the following problem I am trying to solve. I store mulitple youtube videos, by storing their key. Now I use the Youtube API to get some XML data about the videos according to their key. So I have an entry with key XXXXXXXX, and I use a parameter output wich creates a {$ds-youtube}-parameter. This parameter I use in another datasource which loads a dynamic URL located at http://gdata.youtube.com/feeds/api/videos/{$ds-youtube}
This works when I only have one entry, because then {$ds-youtube} will be ‘XXXXXXXX’.
But… when I have multiple entries, {$ds-youtube} will be ‘XXXXXXX1, XXXXXXX2, XXXXXXX3, etc’
Also, in both cases, the XML-output will be:
<youtube> <entry> ... </entry> </youtube> <youtube-detail> ... </youtube-detail>Where I want the output to be similar to:
<youtube> <entry> ... <youtube-detail> ... </youtube-detail> </entry> </youtube>Does anyone know how I can achieve this?
Thanks in advance!