After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 687597 - Update to YouTube API v3
Update to YouTube API v3
Status: RESOLVED FIXED
Product: libgdata
Classification: Platform
Component: YouTube service
git master
Other All
: Immediate critical
: 0.18
Assigned To: libgdata-maint
libgdata-maint
Depends on:
Blocks:
 
 
Reported: 2012-11-04 22:30 UTC by Philip Withnall
Modified: 2015-04-21 23:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
demos: Expand youtube-cli functionality (16.41 KB, patch)
2015-04-19 23:13 UTC, Philip Withnall
committed Details | Review
youtube: Fix default values of GDataYouTubeQuery location properties (2.56 KB, patch)
2015-04-19 23:13 UTC, Philip Withnall
committed Details | Review
core: Expose gdata_parser_error_from_json_error() internally (3.79 KB, patch)
2015-04-19 23:13 UTC, Philip Withnall
committed Details | Review
app: Add support for JSON to GDataAPPCategories (4.19 KB, patch)
2015-04-19 23:13 UTC, Philip Withnall
committed Details | Review
core: Add internal API for setting GDataFeed:total-results (1.84 KB, patch)
2015-04-19 23:14 UTC, Philip Withnall
committed Details | Review
media: Add JSON support to GDataMediaThumbnail (2.86 KB, patch)
2015-04-19 23:14 UTC, Philip Withnall
committed Details | Review
core: Add JSON support to GDataUploadStream (6.72 KB, patch)
2015-04-19 23:14 UTC, Philip Withnall
committed Details | Review
core: Add new JSON internal parser helper methods (9.36 KB, patch)
2015-04-19 23:14 UTC, Philip Withnall
committed Details | Review
tests: Allow use of deprecated API in unit tests (1.15 KB, patch)
2015-04-19 23:14 UTC, Philip Withnall
committed Details | Review
youtube: Add a GDataYouTubeFeed helper class for parsing feeds (11.33 KB, patch)
2015-04-21 23:52 UTC, Philip Withnall
committed Details | Review
youtube: Port to the YouTube API version 3 (207.65 KB, patch)
2015-04-21 23:53 UTC, Philip Withnall
committed Details | Review
app: Remove unused XML parsing code from GDataAPPCategories (4.58 KB, patch)
2015-04-21 23:53 UTC, Philip Withnall
committed Details | Review
media: Remove unused XML parsing code from GDataMediaThumbnail (5.96 KB, patch)
2015-04-21 23:53 UTC, Philip Withnall
rejected Details | Review

Description Philip Withnall 2012-11-04 22:30:37 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
Comment 1 Philip Withnall 2014-12-14 20:50:09 UTC
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.
Comment 2 Philip Withnall 2015-04-19 23:13:43 UTC
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.
Comment 3 Philip Withnall 2015-04-19 23:13:48 UTC
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.
Comment 4 Philip Withnall 2015-04-19 23:13:52 UTC
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.
Comment 5 Philip Withnall 2015-04-19 23:13:57 UTC
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.
Comment 6 Philip Withnall 2015-04-19 23:14:01 UTC
Created attachment 301952 [details] [review]
core: Add internal API for setting GDataFeed:total-results

This will be useful in adding GDataYouTubeFeed, shortly.
Comment 7 Philip Withnall 2015-04-19 23:14:06 UTC
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.
Comment 8 Philip Withnall 2015-04-19 23:14:10 UTC
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.
Comment 9 Philip Withnall 2015-04-19 23:14:15 UTC
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.
Comment 10 Philip Withnall 2015-04-19 23:14:20 UTC
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.
Comment 11 Philip Withnall 2015-04-19 23:15:48 UTC
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
Comment 12 Philip Withnall 2015-04-21 23:52:55 UTC
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
Comment 13 Philip Withnall 2015-04-21 23:53:01 UTC
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
Comment 14 Philip Withnall 2015-04-21 23:53:06 UTC
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.
Comment 15 Philip Withnall 2015-04-21 23:53:11 UTC
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 16 Philip Withnall 2015-04-21 23:56:21 UTC
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.
Comment 17 Philip Withnall 2015-04-21 23:57:17 UTC
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