GDataYouTubeService

## GDataYouTubeService GDataYouTubeService — GData YouTube service object |

## Stability Level

Unstable, unless otherwise indicated

## Synopsis

    #include <gdata/services/youtube/gdata-youtube-service.h>

                        GDataYouTubeService;
                        GDataYouTubeServiceClass;
    enum                GDataYouTubeServiceError;
    enum                GDataYouTubeStandardFeedType;
    GDataYouTubeService * gdata_youtube_service_new         (const gchar *developer_key,
                                                             const gchar *client_id);
    GDataFeed *         gdata_youtube_service_query_videos  (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GError **error);
    void                gdata_youtube_service_query_videos_async
                                                            (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GDataYouTubeVideo * gdata_youtube_service_query_single_video
                                                            (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             const gchar *video_id,
                                                             GCancellable *cancellable,
                                                             GError **error);
    void                gdata_youtube_service_query_single_video_async
                                                            (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             const gchar *video_id,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GDataYouTubeVideo * gdata_youtube_service_query_single_video_finish
                                                            (GDataYouTubeService *self,
                                                             GAsyncResult *async_result,
                                                             GError **error);
    GDataFeed *         gdata_youtube_service_query_related (GDataYouTubeService *self,
                                                             GDataYouTubeVideo *video,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GError **error);
    void                gdata_youtube_service_query_related_async
                                                            (GDataYouTubeService *self,
                                                             GDataYouTubeVideo *video,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GDataFeed *         gdata_youtube_service_query_standard_feed
                                                            (GDataYouTubeService *self,
                                                             GDataYouTubeStandardFeedType feed_type,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GError **error);
    void                gdata_youtube_service_query_standard_feed_async
                                                            (GDataYouTubeService *self,
                                                             GDataYouTubeStandardFeedType feed_type,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    GDataYouTubeVideo * gdata_youtube_service_upload_video  (GDataYouTubeService *self,
                                                             GDataYouTubeVideo *video,
                                                             GFile *video_file,
                                                             GCancellable *cancellable,
                                                             GError **error);
    const gchar *       gdata_youtube_service_get_developer_key
                                                            (GDataYouTubeService *self);
    const gchar *       gdata_youtube_service_get_youtube_user
                                                            (GDataYouTubeService *self);

## Object Hierarchy

      GObject
       +----GDataService
             +----GDataYouTubeService

## Properties

      "developer-key"            gchar*                : Read / Write / Construct Only
      "youtube-user"             gchar*                : Read

## Description

GDataYouTubeService is a subclass of GDataService for communicating with the GData API of YouTube. It supports querying for and uploading videos.

For more details of YouTube's GData API, see the online documentation.

## Details

### GDataYouTubeService

    typedef struct _GDataYouTubeService GDataYouTubeService;

All the fields in the GDataYouTubeService structure are private and should never be accessed directly.

### GDataYouTubeServiceClass

    typedef struct {
    } GDataYouTubeServiceClass;

All the fields in the GDataYouTubeServiceClass structure are private and should never be accessed directly.

### enum GDataYouTubeServiceError

    typedef enum {
    	GDATA_YOUTUBE_SERVICE_ERROR_API_QUOTA_EXCEEDED,
    	GDATA_YOUTUBE_SERVICE_ERROR_ENTRY_QUOTA_EXCEEDED
    } GDataYouTubeServiceError;

Error codes for GDataYouTubeService operations.

`GDATA_YOUTUBE_SERVICE_ERROR_API_QUOTA_EXCEEDED` | the API request quota for this developer account has been exceeded
`GDATA_YOUTUBE_SERVICE_ERROR_ENTRY_QUOTA_EXCEEDED` | the entry (e.g. video) quota for this user account has been exceeded

### enum GDataYouTubeStandardFeedType

    typedef enum {
    	GDATA_YOUTUBE_TOP_RATED_FEED,
    	GDATA_YOUTUBE_TOP_FAVORITES_FEED,
    	GDATA_YOUTUBE_MOST_VIEWED_FEED,
    	GDATA_YOUTUBE_MOST_POPULAR_FEED,
    	GDATA_YOUTUBE_MOST_RECENT_FEED,
    	GDATA_YOUTUBE_MOST_DISCUSSED_FEED,
    	GDATA_YOUTUBE_MOST_LINKED_FEED,
    	GDATA_YOUTUBE_MOST_RESPONDED_FEED,
    	GDATA_YOUTUBE_RECENTLY_FEATURED_FEED,
    	GDATA_YOUTUBE_WATCH_ON_MOBILE_FEED
    } GDataYouTubeStandardFeedType;

Standard feed types for standard feed queries with `gdata_youtube_service_query_standard_feed()`. For more information, see the online documentation.

`GDATA_YOUTUBE_TOP_RATED_FEED` | This feed contains the most highly rated YouTube videos.
`GDATA_YOUTUBE_TOP_FAVORITES_FEED` | This feed contains videos most frequently flagged as favorite videos.
`GDATA_YOUTUBE_MOST_VIEWED_FEED` | This feed contains the most frequently watched YouTube videos.
`GDATA_YOUTUBE_MOST_POPULAR_FEED` | This feed contains the most popular YouTube videos, selected using an algorithm that combines many different signals to determine overall popularity.
`GDATA_YOUTUBE_MOST_RECENT_FEED` | This feed contains the videos most recently submitted to YouTube.
`GDATA_YOUTUBE_MOST_DISCUSSED_FEED` | This feed contains the YouTube videos that have received the most comments.
`GDATA_YOUTUBE_MOST_LINKED_FEED` | This feed contains the YouTube videos that receive the most links from other websites.
`GDATA_YOUTUBE_MOST_RESPONDED_FEED` | This feed contains YouTube videos that receive the most video responses.
`GDATA_YOUTUBE_RECENTLY_FEATURED_FEED` | This feed contains videos recently featured on the YouTube home page or featured videos tab.
`GDATA_YOUTUBE_WATCH_ON_MOBILE_FEED` | This feed contains videos suitable for playback on mobile devices.

### gdata_youtube_service_new ()

    GDataYouTubeService * gdata_youtube_service_new         (const gchar *developer_key,
                                                             const gchar *client_id);

Creates a new GDataYouTubeService. The `developer_key` and `client_id` must be unique for your application, and as registered with Google.

`developer_key` : | your application's developer API key
`client_id` : | your application's client ID
Returns : | a new GDataYouTubeService, or `NULL`

### gdata_youtube_service_query_videos ()

    GDataFeed *         gdata_youtube_service_query_videos  (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GError **error);

Queries the service for videos matching the parameters set on the GDataQuery. This searches site-wide, and imposes no other restrictions or parameters on the query.

Parameters and errors are as for `gdata_service_query()`.

`self` : | a GDataYouTubeService
`query` : | a GDataQuery with the query parameters, or `NULL`. [allow-none]
`cancellable` : | optional GCancellable object, or `NULL`
`progress_callback` : | a GDataQueryProgressCallback to call when an entry is loaded, or `NULL`. [scope call]
`progress_user_data` : | data to pass to the `progress_callback` function. [closure]
`error` : | a GError, or `NULL`
Returns : | a GDataFeed of query results, or `NULL`; unref with `g_object_unref()`. [transfer full]

### gdata_youtube_service_query_videos_async ()

    void                gdata_youtube_service_query_videos_async
                                                            (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Queries the service for videos matching the parameters set on the GDataQuery. This searches site-wide, and imposes no other restrictions or parameters on the query. `self` and `query` are both reffed when this function is called, so can safely be freed after this function returns.

For more details, see `gdata_youtube_service_query_videos()`, which is the synchronous version of this function.

When the operation is finished, `callback` will be called. You can then call `gdata_service_query_finish()` to get the results of the operation.

`self` : | a GDataService
`query` : | a GDataQuery with the query parameters, or `NULL`. [allow-none]
`cancellable` : | optional GCancellable object, or `NULL`
`progress_callback` : | a GDataQueryProgressCallback to call when an entry is loaded, or `NULL`
`progress_user_data` : | data to pass to the `progress_callback` function. [closure]
`callback` : | a GAsyncReadyCallback to call when authentication is finished
`user_data` : | data to pass to the `callback` function. [closure]

### gdata_youtube_service_query_single_video ()

    GDataYouTubeVideo * gdata_youtube_service_query_single_video
                                                            (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             const gchar *video_id,
                                                             GCancellable *cancellable,
                                                             GError **error);

Retrieves information about the single video with the given `video_id`. `video_id` should be as returned by `gdata_youtube_video_get_video_id()` or as extracted from a YouTube URI.

Parameters and errors are as for `gdata_service_query()`.

`self` : | a GDataYouTubeService
`query` : | a GDataQuery with the query parameters, or `NULL`
`video_id` : | the video ID of the desired video
`cancellable` : | a GCancellable, or `NULL`
`error` : | a GError, or `NULL`
Returns : | a GDataYouTubeVideo, or `NULL`; unref with `g_object_unref()`. [transfer full]

Since 0.4.0

### gdata_youtube_service_query_single_video_async ()

    void                gdata_youtube_service_query_single_video_async
                                                            (GDataYouTubeService *self,
                                                             GDataQuery *query,
                                                             const gchar *video_id,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Retrieves information about the single video with the given `video_id`. `video_id` should be as returned by `gdata_youtube_video_get_video_id()` or as extracted from a YouTube URI. `self`, `query` and `video_id` are reffed/copied when this function is called, so can safely be freed after this function returns.

For more details, see `gdata_youtube_service_query_single_video()`, which is the synchronous version of this function.

When the operation is finished, `callback` will be called. You can then call `gdata_youtube_service_query_single_video_finish()` to get the results of the operation.

`self` : | a GDataService
`query` : | a GDataQuery with the query parameters, or `NULL`
`video_id` : | the video ID of the desired video
`cancellable` : | optional GCancellable object, or `NULL`
`callback` : | a GAsyncReadyCallback to call when authentication is finished
`user_data` : | data to pass to the `callback` function

Since 0.4.0

### gdata_youtube_service_query_single_video_finish ()

    GDataYouTubeVideo * gdata_youtube_service_query_single_video_finish
                                                            (GDataYouTubeService *self,
                                                             GAsyncResult *async_result,
                                                             GError **error);

Finishes an asynchronous query operation for a single video, as started with `gdata_youtube_service_query_single_video_async()`.

`self` : | a GDataYouTubeService
`async_result` : | a GAsyncResult
`error` : | a GError, or `NULL`
Returns : | a GDataYouTubeVideo, or `NULL`; unref with `g_object_unref()`. [transfer full]

Since 0.4.0

### gdata_youtube_service_query_related ()

    GDataFeed *         gdata_youtube_service_query_related (GDataYouTubeService *self,
                                                             GDataYouTubeVideo *video,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GError **error);

Queries the service for videos related to `video`. The algorithm determining which videos are related is on the server side.

If `video` does not have a link with rel value `http://gdata.youtube.com/schemas/2007video.related`, a `GDATA_SERVICE_ERROR_PROTOCOL_ERROR` error will be thrown. Parameters and other errors are as for `gdata_service_query()`.

`self` : | a GDataYouTubeService
`video` : | a GDataYouTubeVideo for which to find related videos
`query` : | a GDataQuery with the query parameters, or `NULL`. [allow-none]
`cancellable` : | optional GCancellable object, or `NULL`
`progress_callback` : | a GDataQueryProgressCallback to call when an entry is loaded, or `NULL`. [scope call]
`progress_user_data` : | data to pass to the `progress_callback` function. [closure]
`error` : | a GError, or `NULL`
Returns : | a GDataFeed of query results; unref with `g_object_unref()`. [transfer full]

### gdata_youtube_service_query_related_async ()

    void                gdata_youtube_service_query_related_async
                                                            (GDataYouTubeService *self,
                                                             GDataYouTubeVideo *video,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Queries the service for videos related to `video`. The algorithm determining which videos are related is on the server side. `self` and `query` are both reffed when this function is called, so can safely be freed after this function returns.

For more details, see `gdata_youtube_service_query_related()`, which is the synchronous version of this function.

When the operation is finished, `callback` will be called. You can then call `gdata_service_query_finish()` to get the results of the operation.

`self` : | a GDataService
`video` : | a GDataYouTubeVideo for which to find related videos
`query` : | a GDataQuery with the query parameters, or `NULL`. [allow-none]
`cancellable` : | optional GCancellable object, or `NULL`
`progress_callback` : | a GDataQueryProgressCallback to call when an entry is loaded, or `NULL`
`progress_user_data` : | data to pass to the `progress_callback` function. [closure]
`callback` : | a GAsyncReadyCallback to call when authentication is finished
`user_data` : | data to pass to the `callback` function. [closure]

### gdata_youtube_service_query_standard_feed ()

    GDataFeed *         gdata_youtube_service_query_standard_feed
                                                            (GDataYouTubeService *self,
                                                             GDataYouTubeStandardFeedType feed_type,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GError **error);

Queries the service's standard `feed_type` feed to build a GDataFeed.

Parameters and errors are as for `gdata_service_query()`.

`self` : | a GDataYouTubeService
`feed_type` : | the feed type to query, from GDataYouTubeStandardFeedType
`query` : | a GDataQuery with the query parameters, or `NULL`. [allow-none]
`cancellable` : | optional GCancellable object, or `NULL`
`progress_callback` : | a GDataQueryProgressCallback to call when an entry is loaded, or `NULL`. [scope call]
`progress_user_data` : | data to pass to the `progress_callback` function. [closure]
`error` : | a GError, or `NULL`
Returns : | a GDataFeed of query results, or `NULL`; unref with `g_object_unref()`. [transfer full]

### gdata_youtube_service_query_standard_feed_async ()

    void                gdata_youtube_service_query_standard_feed_async
                                                            (GDataYouTubeService *self,
                                                             GDataYouTubeStandardFeedType feed_type,
                                                             GDataQuery *query,
                                                             GCancellable *cancellable,
                                                             GDataQueryProgressCallback progress_callback,
                                                             gpointer progress_user_data,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Queries the service's standard `feed_type` feed to build a GDataFeed. `self` and `query` are both reffed when this function is called, so can safely be freed after this function returns.

For more details, see `gdata_youtube_service_query_standard_feed()`, which is the synchronous version of this function.

When the operation is finished, `callback` will be called. You can then call `gdata_service_query_finish()` to get the results of the operation.

`self` : | a GDataService
`feed_type` : | the feed type to query, from GDataYouTubeStandardFeedType
`query` : | a GDataQuery with the query parameters, or `NULL`. [allow-none]
`cancellable` : | optional GCancellable object, or `NULL`
`progress_callback` : | a GDataQueryProgressCallback to call when an entry is loaded, or `NULL`
`progress_user_data` : | data to pass to the `progress_callback` function. [closure]
`callback` : | a GAsyncReadyCallback to call when authentication is finished
`user_data` : | data to pass to the `callback` function. [closure]

### gdata_youtube_service_upload_video ()

    GDataYouTubeVideo * gdata_youtube_service_upload_video  (GDataYouTubeService *self,
                                                             GDataYouTubeVideo *video,
                                                             GFile *video_file,
                                                             GCancellable *cancellable,
                                                             GError **error);

Uploads a video to YouTube, using the properties from `video` and the video file pointed to by `video_file`.

If `video` has already been inserted, a `GDATA_SERVICE_ERROR_ENTRY_ALREADY_INSERTED` error will be returned. If no user is authenticated with the service, `GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED` will be returned.

If there is a problem reading `video_file`, an error from `g_file_load_contents()` or `g_file_query_info()` will be returned. Other errors from GDataServiceError can be returned for other exceptional conditions, as determined by the server.

`self` : | a GDataYouTubeService
`video` : | a GDataYouTubeVideo to insert
`video_file` : | the video file to upload
`cancellable` : | optional GCancellable object, or `NULL`
`error` : | a GError, or `NULL`
Returns : | the inserted GDataYouTubeVideo with updated properties from `video`; unref with `g_object_unref()`. [transfer full]

### gdata_youtube_service_get_developer_key ()

    const gchar *       gdata_youtube_service_get_developer_key
                                                            (GDataYouTubeService *self);

Gets the "developer-key" property from the GDataYouTubeService.

`self` : | a GDataYouTubeService
Returns : | the developer key property

### gdata_youtube_service_get_youtube_user ()

    const gchar *       gdata_youtube_service_get_youtube_user
                                                            (GDataYouTubeService *self);

Gets the "youtube-user" property from the GDataYouTubeService.

`self` : | a GDataYouTubeService
Returns : | the YouTube username property

## Property Details

### The `"developer-key"` property

      "developer-key"            gchar*                : Read / Write / Construct Only

The developer key your application has registered with the YouTube API. For more information, see the online documentation.

The matching "client-id" property belongs to GDataService.

Default value: NULL

### The `"youtube-user"` property

      "youtube-user"             gchar*                : Read

The YouTube username of the authenticated user, or `NULL`. This may differ from "username", due to the work done when YouTube was converted to use Google's centralised login system.

Default value: NULL