Problems with GDataEntryYouTubeEntry

38 views
Skip to first unread message

TylerWeir

unread,
Dec 15, 2009, 5:07:17 PM12/15/09
to Google Data APIs Objective-C Client Library Discussion
There is a prior thread with this issue, but it appears to be closed
to replies.

I'd like to get the extended video data per video using GData.

Using the following code, the entries will never respond to
mediaGroup, as they are always GDataEntryBase objects.
- (void)entryListFetchTicket:(GDataServiceTicket *)ticket
finishedWithFeed:(GDataFeedBase *)feed error:(NSError *)error {

for (int i = 0; i < [[feed entries] count]; i++) {
GDataEntryYouTubeVideo *entry = [[feed entries] objectAtIndex:i];

if (!entry || ![entry respondsToSelector:@selector(mediaGroup)]) {
NSLog(@"%d: mediaGroup: NO", i);
}
else{
NSLog(@"%d: mediaGroup: YES", i);
}
}
}

The error is "-[GDataEntryBase mediaGroup]: unrecognized selector sent
to instance"

I'm not sure why this is the case. Looking at the included Youtube
app, the code is the same, in fact copy and pasted it into my iphone
app at one point.

I'm using 1.9.1 and trunk of the library, and both have this issue.

I've searched the forum and implemented all of the solutions posted,
and they all have this issue.

Any thoughts?

Thanks.

Greg Robbins

unread,
Dec 15, 2009, 5:20:47 PM12/15/09
to gdata-objec...@googlegroups.com
Which feed are you trying to fetch?  What does the XML of one of the returned entries look like?

During parsing of the feed and entries returned by the server, an entry's class is usually determined by the "kind" category element of the entry.  A GDataEntryBase instance is created only when there's not a recognizable kind category and the feed does not specify a class for its entries.

TylerWeir

unread,
Dec 15, 2009, 7:15:53 PM12/15/09
to Google Data APIs Objective-C Client Library Discussion
The code:
NSString *feedID = kGDataYouTubeUserFeedIDNewSubscriptionVideos;
NSURL *fURL = [GDataServiceGoogleYouTube
youTubeURLForUserID:rootItem.feedURL userFeedID:feedID];

Printing fURL shows:
"http://gdata.youtube.com/feeds/api/users/tylerweirtube/
newsubscriptionvideos"

Printing an Entry:
"GDataEntryBase 0x3cb7a00: {v:2.0 title:shinhan pro 0910 091214e Sea
vs Flash contentSrc:http://www.youtube.com/v/De9yGTCvdPM?
f=newsubscriptionvideos&app=youtube_gdata
etag:W/"C0EFR347eCp7ImA9WxBTGUw." authors:1 categories:9
links:alternate,video.responses,video.related,self id:tag:youtube.com,
2008:video:De9yGTCvdPM}"

> GDataEntryBase instance is created only when there's not a recognizable kind
> category and the feed does not specify a class for its entries.

Hmm, ok, I'll look at this right now.

Here's a gist of code:
http://gist.github.com/257446

Thanks Greg.

Greg Robbins

unread,
Dec 15, 2009, 7:21:40 PM12/15/09
to gdata-objec...@googlegroups.com
You can turn on http logging by calling
  [GDataHTTPFetcher setIsLoggingEnabled:YES];

You can example the XML for a feed or an entry with
  NSLog(@"%@", [object XMLElement]);

Greg Robbins

unread,
Dec 15, 2009, 7:47:36 PM12/15/09
to gdata-objec...@googlegroups.com
Is GDataEntryYouTubeVideo.m being compiled into your application? Omitting the source for an entry or feed will stop it from being instantiated when it's needed.

TylerWeir

unread,
Dec 15, 2009, 8:07:40 PM12/15/09
to Google Data APIs Objective-C Client Library Discussion
Looks like it:
nm -m libGDataTouchStaticLib.a | grep GDataEntryYouTubeVideo produces
the appropriate symbols.

Greg Robbins

unread,
Dec 15, 2009, 8:14:11 PM12/15/09
to gdata-objec...@googlegroups.com
I just tried adding kGDataYouTubeUserFeedIDNewSubscriptionVideos to the list of feeds in YouTubeSampleWindowController, built and ran the app, and had it fetch the newsubcriptionvideos feed. The entries in the feed are being instantiated as GDataEntryYouTubeVideo, as expected.

I'm curious if the XML for the entries in your feed have the category marking them as being video entries,

  <category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video"/>

TylerWeir

unread,
Dec 16, 2009, 9:32:01 AM12/16/09
to Google Data APIs Objective-C Client Library Discussion
On Dec 15, 8:14 pm, Greg Robbins <grobb...@google.com> wrote:
> I just tried adding kGDataYouTubeUserFeedIDNewSubscriptionVideos to the list
> of feeds in YouTubeSampleWindowController, built and ran the app, and had it
> fetch the newsubcriptionvideos feed. The entries in the feed are being
> instantiated as GDataEntryYouTubeVideo, as expected.

I did the same thing with the example app and it worked as expected.
I then copied the working code to my iPhone app and ran into the
issue.
The feed is "GDataFeedYouTubeVideo" but the entries are
"GDataEntryBase."

If I break and print the objects to the console, I get this:
Printing description of feed:
GDataFeedYouTubeVideo 0x3c55670: {v:2.0 entries:79
etag:W/"CUQAQn47eCp7ImA9WxBTGUo." title:New Subscription Videos for
tylerweirtube updated:2009-12-16T14:22:23Z authors:1 categories:1
links:alternate,feed,batch,self,service id:tag:youtube.com,
2008:user:tylerweirtube:newsubscriptionvideos}

Printing description of 0:
GDataEntryBase 0x3c5e7d0: {v:2.0 title:Sea.Really vs Leta [15
December, 2009] 5set @ ShinHan Bank Proleague 2009-10
contentSrc:http://www.youtube.com/v/WYXMqdYFK7c?
f=newsubscriptionvideos&app=youtube_gdata
etag:W/"CEUDQX47eCp7ImA9WxBTGUo." authors:1 categories:10
links:alternate,video.responses,video.related,mobile,self
id:tag:youtube.com,2008:video:WYXMqdYFK7c}


> I'm curious if the XML for the entries in your feed have the category
> marking them as being video entries,
>
>   <category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video"/>

I apologize, I'm not sure where to break to get the raw XML response.
I looked through the lib, but nothing jumped out at me.
Is there a function I can sit on to see the response?

Thanks.

SJ

unread,
Dec 16, 2009, 10:20:41 AM12/16/09
to Google Data APIs Objective-C Client Library Discussion
I had this same problem and found out that the GDataFeedYouTubeVideo
classes were not being registered. They are created with a factory
style pattern that looks up the derived class based on the XML
returned. If the correct class is not registered then you just get
the base class back. You need to explicitly use the class or call the
register method. I can't remember off the top of my head the exact
change I made and I am not at my workstation at the moment. Let me
know if you need me to look back at my changes for you.
-Steve

Tyler Weir

unread,
Dec 16, 2009, 10:23:08 AM12/16/09
to gdata-objec...@googlegroups.com
> change I made and I am not at my workstation at the moment.  Let me
> know if you need me to look back at my changes for you.

Sounds like the solution to me, I'd appreciate it if you could take a
look at your code for me.

Thanks,
Tyler

-------------------------------------
http://www.tylerweir.ca
> --
>
> You received this message because you are subscribed to the Google Groups "Google Data APIs Objective-C Client Library Discussion" group.
> To post to this group, send email to gdata-objec...@googlegroups.com.
> To unsubscribe from this group, send email to gdata-objectivec-...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gdata-objectivec-client?hl=en.
>
>
>

SJ

unread,
Dec 16, 2009, 10:36:45 AM12/16/09
to Google Data APIs Objective-C Client Library Discussion
Something to look for in the mean time...

Make sure you are checking the type of the object explicitly... For
example:

if ([gentry isKindOfClass:[GDataEntryYouTubePlaylist class]]) {
...
}

This will cause the linker to link the class object and it will
automatically register. If you just use casts and base class pointers
the derived class is never registered.
Let me know if this works...

-Steve



On Dec 16, 9:23 am, Tyler Weir <tyler.w...@gmail.com> wrote:
> > change I made and I am not at my workstation at the moment.  Let me
> > know if you need me to look back at my changes for you.
>
> Sounds like the solution to me, I'd appreciate it if you could take a
> look at your code for me.
>
> Thanks,
> Tyler
>
> -------------------------------------http://www.tylerweir.ca

Greg Robbins

unread,
Dec 16, 2009, 11:46:51 AM12/16/09
to gdata-objec...@googlegroups.com
You can inspect the XML for a feed or entry by writing the entry's XML to the console with
  NSLog(@"the feed's XML is %@", [feed XMLElement]);
or
  NSLog(@"the entry's XML is %@", [entry XMLElement]);

That is typically useful in the callback from a fetch to see what was returned by the server (in the finishedWithFeed: or finishedWithEntry: method.)


To get a full http log, including the XML sent to and from the server, add 

  [GDataHTTPFetcher setIsLoggingEnabled:YES];

to your application. This is described in the library's introduction document, under "Logging http server traffic".


Registration of feed and entry classes used in the library is done automatically by the +load methods in those classes. Objective-C invokes a class's +load when the class is loaded into memory as part of its library or application.

If any classes are not present in your application at runtime, my guess is that you compiled against the static library without specifying -ObjC as a linker flag for your target, as mentioned in the project's BuildingTheLibrary wiki page. The -ObjC linker flag prevents stripping of unreferenced code from the static library. 

SJ

unread,
Dec 16, 2009, 12:00:24 PM12/16/09
to Google Data APIs Objective-C Client Library Discussion
The -ObjC option makes sense... All these problems occurred during
the initial phases of configuring XCode to properly compile and link a
very simple example for the iPhone. Therefore, with all the options
and build types (debug, release, distribution, etc...) they probably
just didn't get updated properly at first.
-Steve

TylerWeir

unread,
Dec 16, 2009, 12:23:51 PM12/16/09
to Google Data APIs Objective-C Client Library Discussion
(I replied say all is well, apparently that did not take, so here it
is again.)

Thanks, it's all working now.

-ObjC was required for a few other libs I use, so it's set.

The solution was adding this to the code:


- (void)entryListFetchTicket: (GDataServiceTicket *) ticket
finishedWithFeed: (GDataFeedBase *) feed error: (NSError *) error {

for (int i = 0; i < [[feed entries] count]; i++) {
GDataEntryBase *entry = [[feed entries] objectAtIndex: i];

if ([entry isKindOfClass: [GDataEntryYouTubeVideo class]]) { // <-
Changed, it was a respondsToSelector:@selector(mediaGroup) prior.
GDataEntryYouTubeVideo *v = (GDataEntryYouTubeVideo *)entry;

if ([v respondsToSelector: @selector(mediaGroup)]) {
// do stuff here
}
}
}
}

Thanks for your time and energy helping me out.

Cheers,
Tyler
Reply all
Reply to author
Forward
0 new messages