Zend_Gdata_YouTube insertEntry check if the entry is uploaded

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Zend_Gdata_YouTube insertEntry check if the entry is uploaded

whisher

Hi.

I should upload multiple flv files into youtube service

in the script the moderator can decide if a video can be upload

if no movie with flag no_put

if yes a xhr request mark the video (to_put)

than with a cron (the script retrieve video with flag to_put onsuccess flag put )

on error log_put and log the error

so I started with a snippet like this

$yt = new Zend_Gdata_YouTube(getAuthSubHttpClient());
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

$filesource = $yt->newMediaFileSource('intro.flv');

$filesource->setContentType('video/x-flv');
$filesource->setSlug('intro.flv');


$myVideoEntry->setMediaSource($filesource);

$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// Note that category must be a valid YouTube category !
$myVideoEntry->setVideoCategory('Comedy');

// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');

// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag',
                                           'anotherdevelopertag'));

// Optionally set the video's location
$yt->registerPackage('Zend_Gdata_Geo');
$yt->registerPackage('Zend_Gdata_Geo_Extension');
$where = $yt->newGeoRssWhere();
$position = $yt->newGmlPos('37.0 -122.0');
$where->point = $yt->newGmlPoint($position);
$myVideoEntry->setWhere($where);

// Upload URI for the currently authenticated user
$uploadUrl =
    'http://uploads.gdata.youtube.com/feeds/users/default/uploads';

// Try to upload the video, catching a Zend_Gdata_App_HttpException
// if availableor just a regular Zend_Gdata_App_Exception

try {
    $newEntry = $yt->insertEntry($myVideoEntry,
                                 $uploadUrl,
                                 'Zend_Gdata_YouTube_VideoEntry');
   echo "
";
   print_r($newEntry);
}
 
catch (Zend_Gdata_App_HttpException $httpException) {
    echo $httpException->getRawResponseBody();
} 
catch (Zend_Gdata_App_Exception $e) {
    echo $e->getMessage();
}

put it in a loop with a checking on $newEntry but I retrieve only NULL so

What's the way to check an upload ?

Is there a better way to set up the task ?

Thanks in advance

Bye

Thanks in advance

Reply | Threaded
Open this post in threaded view
|

Re: Zend_Gdata_YouTube insertEntry check if the entry is uploaded

whisher

Is it right to manage error in the catch scope like this

catch (Zend_Gdata_App_HttpException $httpException) { /* Manage Error */ echo $httpException->getRawResponseBody(); } catch (Zend_Gdata_App_Exception $e) { /* Manage Error */ echo $e->getMessage(); }

I also need to retrieve the video entry like in Browser-based upload

and I don't find the way :(

Help me, please ;)

Bye.
whisher wrote

Hi.

I should upload multiple flv files into youtube service

in the script the moderator can decide if a video can be upload

if no movie with flag no_put

if yes a xhr request mark the video (to_put)

than with a cron (the script retrieve video with flag to_put onsuccess flag put )

on error log_put and log the error

so I started with a snippet like this

$yt = new Zend_Gdata_YouTube(getAuthSubHttpClient());
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

$filesource = $yt->newMediaFileSource('intro.flv');

$filesource->setContentType('video/x-flv');
$filesource->setSlug('intro.flv');


$myVideoEntry->setMediaSource($filesource);

$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// Note that category must be a valid YouTube category !
$myVideoEntry->setVideoCategory('Comedy');

// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');

// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag',
                                           'anotherdevelopertag'));

// Optionally set the video's location
$yt->registerPackage('Zend_Gdata_Geo');
$yt->registerPackage('Zend_Gdata_Geo_Extension');
$where = $yt->newGeoRssWhere();
$position = $yt->newGmlPos('37.0 -122.0');
$where->point = $yt->newGmlPoint($position);
$myVideoEntry->setWhere($where);

// Upload URI for the currently authenticated user
$uploadUrl =
    'http://uploads.gdata.youtube.com/feeds/users/default/uploads';

// Try to upload the video, catching a Zend_Gdata_App_HttpException
// if availableor just a regular Zend_Gdata_App_Exception

try {
    $newEntry = $yt->insertEntry($myVideoEntry,
                                 $uploadUrl,
                                 'Zend_Gdata_YouTube_VideoEntry');
   echo "
";
   print_r($newEntry);
}
 
catch (Zend_Gdata_App_HttpException $httpException) {
    echo $httpException->getRawResponseBody();
} 
catch (Zend_Gdata_App_Exception $e) {
    echo $e->getMessage();
}

put it in a loop with a checking on $newEntry but I retrieve only NULL so

What's the way to check an upload ?

Is there a better way to set up the task ?

Thanks in advance

Bye

Thanks in advance

Reply | Threaded
Open this post in threaded view
|

Re: Zend_Gdata_YouTube insertEntry check if the entry is uploaded

whisher
Zend_Debug::dump($newEntry-> getVideoId ());



whisher wrote
<p>Is it right to manage error in the catch scope
like this </p>
<p>catch (Zend_Gdata_App_HttpException $httpException) {
/* Manage Error */
    echo $httpException->getRawResponseBody();
}
catch (Zend_Gdata_App_Exception $e) {
/* Manage Error */
    echo $e->getMessage();
}
</p>
<p>I also need to retrieve the video entry like in  Browser-based upload</p>
<p>and I don't find the way :( </p>
<p>Help me, please ;)</p>
Bye.
whisher wrote
<p>Hi.</p>
<p>I should upload multiple flv files into youtube service </p>
<p>in the script the moderator can decide if a video can be upload</p>
<p>if no movie with flag no_put</p>
<p>if yes a xhr request mark the video (to_put)</p>
<p>than with a cron
(the script retrieve video with flag to_put onsuccess flag put )</p>
<p>on error log_put and log the error</p>
<p>so I started with a snippet like this</p>
<pre>
$yt = new Zend_Gdata_YouTube(getAuthSubHttpClient());
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

$filesource = $yt->newMediaFileSource('intro.flv');

$filesource->setContentType('video/x-flv');
$filesource->setSlug('intro.flv');


$myVideoEntry->setMediaSource($filesource);

$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// Note that category must be a valid YouTube category !
$myVideoEntry->setVideoCategory('Comedy');

// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');

// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag',
                                           'anotherdevelopertag'));

// Optionally set the video's location
$yt->registerPackage('Zend_Gdata_Geo');
$yt->registerPackage('Zend_Gdata_Geo_Extension');
$where = $yt->newGeoRssWhere();
$position = $yt->newGmlPos('37.0 -122.0');
$where->point = $yt->newGmlPoint($position);
$myVideoEntry->setWhere($where);

// Upload URI for the currently authenticated user
$uploadUrl =
    'http://uploads.gdata.youtube.com/feeds/users/default/uploads';

// Try to upload the video, catching a Zend_Gdata_App_HttpException
// if availableor just a regular Zend_Gdata_App_Exception

try {
    $newEntry = $yt->insertEntry($myVideoEntry,
                                 $uploadUrl,
                                 'Zend_Gdata_YouTube_VideoEntry');
   echo "<pre>";
   print_r($newEntry);
}
 
catch (Zend_Gdata_App_HttpException $httpException) {
    echo $httpException->getRawResponseBody();
}
catch (Zend_Gdata_App_Exception $e) {
    echo $e->getMessage();
}
<p>put it in a loop with a checking on $newEntry
but I retrieve only NULL so</p>


<p>What's the way to check an upload ?</p>

<p>Is there a better way to set up the task ?</p>

<p>Thanks in advance</p>
<p>Bye</p>


<p>Thanks in advance</p>