YouTube Connector | Version 4

YouTube Upload Configuration

Learn how to configure the YouTube Connector to upload videos from Sophora.

This page describes step by step how to configure the YouTube Connector to upload video files to YouTube. For a full reference see YouTube Connector Guide.


You need:

  • A document type in Sophora that references video files and its metadata. The metadata may be augmented by a script which uses other documents as additional source (like a broadcast or asset document).
  • A binary video file that YouTube supports. Select a video format that best fits your needs.
  • A YouTube channel. You need the credentials to access the YouTube API. See section "Authentication (OAuth)" in YouTube Connector Guide.

1. Configure node type

The document type of the video must be known to the YouTube Connector. Make sure your mediaconfig.xml contains something like the following block:

	<!-- List of document types -->
	<util:list id="documentDescriptionList">
		<!-- Video -->
		<bean class="com.subshell.sophora.avtool.api.MediaDocumentDescription">
 			<property name="nodeTypeName" value="example-nt:video" />
			<property name="formats">
			<!-- Optional: Name of a playout channel. The presence of a document on this channel corresponds to the visibility of
				the media files on YouTube. -->
			<property name="playoutChannelName" value="YouTube" />
			<!-- Optional: Name of property that has the duration of the video. Format must be [[hours:]minutes:]seconds[.SSS]. Only 
				used for captions if an intro/opener of this type is prepended to the video to be uploaded. -->
			<property name="durationPropertyName" value="example:duration" />

The "formats" define different resolutions or codecs for the same file. It is a free form text that is used as key to match other configurations and values in a document. So best use what is already available as video format in your documents.

2. Binary file source server

The YouTube connector must download the files from a server to be able to upload them to YouTube. The source server is named "media server" as it holds all media files. There are different protocols for the transport to choose from:

  • SFTP (default)
  • FTP(S)
  • local file system
  • Akamai NetStorage Usage API

You need to configure the credentials for accessing the server. Normally a username and password will be set.

The folder on the server which contains the files must be set as "basedir". The media files can be organised in sub folders with a pattern that contains placeholders like a date. Such patterns can be configured per format in the map "formatDirectoryMapping".

	<util:list id="mediaServerDescriptionList">
		<bean class="com.subshell.sophora.avtool.api.ServerDescription">
			<!-- pre-defined: defaultTransporterFactory (SFTP), ftpTransporterFactory, ftpsTransporterFactory, localTransporterFactory, akamaiNetStorageTransporterFactory (HTTP) -->
			<property name="transporterFactory" ref="defaultTransporterFactory" />
			<!-- Server name from which the video files should be retrieved. When local file transfer is used, this field is only
				used for logging. -->
			<property name="host" value="" />
			<property name="port" value="22" />
			<property name="user" value="sophora-avtool" />
			<property name="password" value="changeMe" />
			<property name="keyfile" value="" />
			<property name="basedir" value="/data/mediasource" />
			<property name="formatDirectoryMapping">
					<entry key="youtube" value="." />
			<!-- Optional: A regex to parse the date from a file's name, which will then be applied to all entries in the formatDirecoryMapping
				that contain format specifiers, e.g. "%1$tY/%1$tm%1$td". The date in the file name must be written in the format "yyyyMMdd". -->
			<property name="dateRegex" value="#?.{3}(\\d{8}).+" />

3. Global YouTube configuration

There are some settings that are common for all videos and all YouTube channels that are used. Those properties are set in the mediaconfig.xml as "youtubeGlobalConfig".

The most important setting is the "youtubeAccountPropertyName". The value of this property determines if and to what YouTube channel the video will be uploaded. The value must be the ID of a channel configuration (see below).

	<!-- YouTube settings for all channels -->
	<bean id="youtubeGlobalConfig" class="">
		<!-- Property of the document that indicates which channel to use. -->
		<property name="youtubeAccountPropertyName" value="example:youtubeChannel" />
		<!-- The YouTube action to take when a video document is deleted or set offline. Options are DELETE, SET_PRIVATE, and DO_NOTHING. -->
		<property name="deleteEventAction" value="DELETE" />
		<property name="offlineEventAction" value="SET_PRIVATE" />
		<!-- Application for adding opener and closer to the beginning/end of video. The specific videos are configured per channel. -->
		<property name="concatVideosScript"
			value="/cms-install-directory/ytc_opener_und_closer/" />

4. YouTube channel configuration

You must configure all your YouTube channels to be able to upload videos to them. The configuration is best done in Sophora as system document in the administration area, but can also be defined in the mediaconfig.xml as Spring bean.

See the YouTube Connector Guide for all parameters. For the "Video format" enter the same as in the first step i.e. "youtube" and make sure that a child node of the video has that format (normally done via a preprocessor script).

Last modified on 7/5/22

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.