GNOME Bugzilla – Bug 687597
Update to YouTube API v3
Last modified: 2015-04-21 23:57:28 UTC
Just when our support for v2 was looking comfortable, here comes v3! It’s still in an experimental phase at the moment, and the v2 API won’t disappear for a while. Of note is that the new API is REST-based and uses JSON. This confirms the suspicion that Google are moving from Atom to JSON/REST for all of their APIs. It means that either libgdata will have to be rearchitected to support both Atom and JSON (because some of the APIs still use only Atom, such as PicasaWeb); or a new library will have to be created which just supports the JSON-based APIs, and steals a load of common code from libgdata. Either solution would work. The former would be harder, but theoretically less pain for all the programs which use libgdata, as it could be done without breaking API (probably). Documentation: https://developers.google.com/youtube/v3/ Announcement: https://groups.google.com/forum/?fromgroups=#!topic/youtube-api/5v-5tZSaykg
The v2 API will be removed entirely on 2015-04-20 (see the bottom of https://developers.google.com/youtube/youtube-api-list), so we need to port by then.
Created attachment 301948 [details] [review] demos: Expand youtube-cli functionality Add support for all of the major features which our YouTube service currently supports: querying single videos, related videos, standard feeds, categories, and uploading videos.
Created attachment 301949 [details] [review] youtube: Fix default values of GDataYouTubeQuery location properties The latitude and longitude properties previously had 0.0 as their default value, which is a valid location. They should instead have G_MAXDOUBLE as their default, which is not a valid location — and hence doesn’t affect query results before the properties are set explicitly.
Created attachment 301950 [details] [review] core: Expose gdata_parser_error_from_json_error() internally Expose this as an internal helper function, which will be useful in upcoming commits.
Created attachment 301951 [details] [review] app: Add support for JSON to GDataAPPCategories This allows downloading the YouTube category list with v3 of the YouTube API.
Created attachment 301952 [details] [review] core: Add internal API for setting GDataFeed:total-results This will be useful in adding GDataYouTubeFeed, shortly.
Created attachment 301953 [details] [review] media: Add JSON support to GDataMediaThumbnail This will be used in the upcoming port to v3 of the YouTube API.
Created attachment 301954 [details] [review] core: Add JSON support to GDataUploadStream Add support for JSON to the non-resumable and resumable code paths, so that GDataEntrys which specify application/json as their content type have JSON generated and uploaded, rather than XML. This will be useful for the upcoming port to v3 of the YouTube API.
Created attachment 301955 [details] [review] core: Add new JSON internal parser helper methods New internal API: • gdata_parser_int_from_json_member() • gdata_parser_strv_from_json_member() These will be useful in upcoming changes to port to v3 of the YouTube API.
Created attachment 301956 [details] [review] tests: Allow use of deprecated API in unit tests We need to test that the behaviour of deprecated API doesn’t change across the versions of libgdata, which requires it to be accessible in the headers, and hence LIBGDATA_DISABLE_DEPRECATED cannot be defined. All deprecated API is marked with G_GNUC_DEPRECATED anyway, and the tests can explicitly disable this with G_GNUC_BEGIN_IGNORE_DEPRECATIONS.
Making progress. Remainder of the work is basically finished, but needs tidying up and documenting properly before it’s pushed: https://git.gnome.org/browse/libgdata/commit/?h=wip/pwithnall/youtube-v3. Attachment 301948 [details] pushed as 7887424 - demos: Expand youtube-cli functionality Attachment 301949 [details] pushed as 7fc7b3a - youtube: Fix default values of GDataYouTubeQuery location properties Attachment 301950 [details] pushed as b354ff4 - core: Expose gdata_parser_error_from_json_error() internally Attachment 301951 [details] pushed as f89b123 - app: Add support for JSON to GDataAPPCategories Attachment 301952 [details] pushed as 9dc3981 - core: Add internal API for setting GDataFeed:total-results Attachment 301953 [details] pushed as de74263 - media: Add JSON support to GDataMediaThumbnail Attachment 301954 [details] pushed as d8a40c6 - core: Add JSON support to GDataUploadStream Attachment 301955 [details] pushed as 750bb7f - core: Add new JSON internal parser helper methods Attachment 301956 [details] pushed as 5fd7761 - tests: Allow use of deprecated API in unit tests
Created attachment 302104 [details] [review] youtube: Add a GDataYouTubeFeed helper class for parsing feeds This parses YouTube-specific properties of the feed — specifically, the total-results and items-per-page, which were previously handled in a service-agnostic manner by GDataFeed, but YouTube doesn’t conform to that. This adds the following new API: • GDataYouTubeFeed
Created attachment 302105 [details] [review] youtube: Port to the YouTube API version 3 Deprecated API: • GDataYouTubeQuery:format, gdata_youtube_query_get_format(), gdata_youtube_query_set_format() • GDataYouTubeQuery:has-location • GDataYouTubeQuery:language, gdata_youtube_query_get_language(), gdata_youtube_query_set_language() • GDataYouTubeQuery:sort-order, gdata_youtube_query_get_sort_order(), gdata_youtube_query_set_sort_order() • GDataYouTubeQuery:uploader, gdata_youtube_query_get_uploader(), gdata_youtube_query_set_uploader() • GDataYouTubeSortOrder • GDataYouTubeUploader • GDataYouTubeContent • GDataYouTubeFormat • GDataYouTubeVideo:video-id, gdata_youtube_video_get_video_id() • gdata_youtube_video_look_up_content() (use gdata_youtube_video_get_player_uri() instead) • GDATA_YOUTUBE_RATING_TYPE_SIMPLE • GDataYouTubeCredit, GDATA_YOUTUBE_CREDIT_ENTITY_PARTNER • GDataYouTubeVideo:credit, gdata_youtube_video_get_credit() • GDataYouTubeVideo:is-draft, gdata_youtube_video_is_draft(), gdata_youtube_video_set_is_draft() • GDATA_YOUTUBE_*_FEED except GDATA_YOUTUBE_MOST_POPULAR_FEED (all others have been deprecated online and will transparently return the most popular videos from the past 24 hours) API changes: • GDataYouTubeQuery:restriction no longer accepts IP addresses • All GDataCommentable functionality on GDataYouTubeVideo is disabled at runtime until the v3 YouTube API for comments is finished online • Not all properties of a GDataYouTubeVideo may be retrieved when doing searches, retrieving related videos, or listing standard feeds — to guarantee getting all properties, use gdata_service_query_single_entry() for the video in question; common properties such as title, description, player URI and thumbnails will always be retrieved Internally, the GDataYouTubeControl and GDataYouTubeGroup APIs have been removed, but they were never visible publicly, so this is not an API break. Due to the transition from v2 to v3 of the YouTube API, your client’s developer key may stop working. Refresh it here: https://developers.google.com/youtube/registering_an_application
Created attachment 302106 [details] [review] app: Remove unused XML parsing code from GDataAPPCategories No longer needed after porting the YouTube API to v3, which uses JSON.
Created attachment 302107 [details] [review] media: Remove unused XML parsing code from GDataMediaThumbnail No longer needed after porting the YouTube API to v3, which uses JSON.
Comment on attachment 302107 [details] [review] media: Remove unused XML parsing code from GDataMediaThumbnail (In reply to Philip Withnall from comment #15) > Created attachment 302107 [details] [review] [review] > media: Remove unused XML parsing code from GDataMediaThumbnail > > No longer needed after porting the YouTube API to v3, which uses JSON. That’s completely wrong. The PicasaWeb service still uses GDataMediaThumbnail, and is still XML-based. GDataMediaThumbnail has to retain support for XML for now.
Fixed, pending updating the tests. Whew. Attachment 302104 [details] pushed as 4cf196e - youtube: Add a GDataYouTubeFeed helper class for parsing feeds Attachment 302105 [details] pushed as 727c13a - youtube: Port to the YouTube API version 3 Attachment 302106 [details] pushed as 9c996d5 - app: Remove unused XML parsing code from GDataAPPCategories