Tag Archives: YouTube

Direct upload to YouTube through MediaWiki

Might be of interest for those who want to get more content into their YouTube EDU account.

We have have been experimenting with ways to get content into YouTube from a single app with a trusted user base. So that meant either MediaWiki or WordPress (only two apps we have with CWL right now). WordPress was the first choice but there was nothing out there, eventually found this great little extension from Travis Derouin of http://www.wikihow.com called YouTubeAuthSub which takes advantage of the YouTube AuthSub/ClientLogin features.

After quite a few email exchanges with Travis I managed to get it working (discovered someone mangled the SVN on MediaWiki.org hosting his extension without his knowledge) ended up finding a working copy from the Wikia SVN in the mean time…


You probably do not want all users in your wiki to access this extension so I recommend creating a YouTube group on your wiki install and assigning users to that group through the Special:UserRights . To add a group to MediaWiki add something like this to your LocalSettings.php:

## YouTube Namespace
define("NS_YOUTUBE", 116);
define("NS_YOUTUBE_TALK", 117);

$wgExtraNamespaces[NS_YOUTUBE] = "YouTube";
$wgExtraNamespaces[NS_YOUTUBE_TALK] = "YouTube_talk";

## Subpages has to be enabled explictly.
$wgNamespacesWithSubpages[NS_YOUTUBE] = false;
$wgNamespacesWithSubpages[NS_YOUTUBE_TALK] = false;

$wgContentNamespaces[] = NS_YOUTUBE;

You will also need to add this to the extension YouTubeAuthSub/YouTubeAuthSub_body.php after the $this->setHeaders(); in the function execute()

# Check permissions
/// OLT BEGIN ///
// Make sure the user is in the youtube OR sysop group
$isYouTubeEduGroup = ( in_array('youtube', $wgUser->getGroups()) || in_array('sysop', $wgUser->getGroups()) );
if(!$isYouTubeEduGroup ) {

if( !$wgUser->isLoggedIn() ) {
$wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
$wgOut->showErrorPage( 'badaccess', 'badaccess-groups', $result = array('YouTube') );
/// OLT END ///

Possible Bugs

We recently had issues with some accounts because of a change in the YouTube API which they did not warn users against! They basically decided to add “=” into some of the tokens. The original code used a split() to extract tokens so this broke. I recommend doing something really ugly like this to avoid failed tokens if you are having issues (for some reason not all accounts have issues).

Look for the foreach ($lines as $line) { in the YouTubeAuthSub_body.php and add and comment the following:

/// OLT BEGIN ///
// Check if string contains Auth
$authPat = '/^Auth/';
$token = substr($line, 5);

// Check if string contains YouTubeUser
$userPat = '/^YouTubeUser/';
if(!empty($userMatch)) {
$YouTubeUser = substr($line, 12);

/// OLT END ///

** This does not work. YouTube API decided to add = into token strings so split breaks.

$params = split("=", $line);

switch ($params[0]) {
case "Auth":
$token = $params[1];
case "YouTubeUser":
$YouTubeUser = $params[1];


Other change YouTube change the client login URL look for the:

$result = wfSpecialYouTubePost("https://www.google.com/youtube/accounts/ClientLogin?"

and change to:

$result = wfSpecialYouTubePost("https://www.google.com/accounts/ClientLogin?"

To Do
Add ability to add to playlists within the YouTube account, not sure when I will get to this but it is a “to do” maybe someone will to do it first 🙂

That’s it.

YouTube Edu

Interesting considering I just attended a group meeting on iTunes U which I think is complete garbage (but everyone has iTunes they scream) not really but everyone does have an internet browser…

YouTube Edu seems like it would be even better than iTunes U but we are bound by some sort of privacy act so cannot use… WordPress TV still looks like the best bet for self hosted video platform integrated with CWL etc.

via: RRW