Search code examples
iphonelimityoutube-apigdata-api

iphone Gdata youtube api limit the number of videos recieved


Hy I'm trying to get all the videos from a user and put them in a list view. I folowed a tutorial on how to do this on iphone and came up whit this. But since this particular user has over 500 videos this method thakes a lot of time to load up the video titles. I saw that ther is a method to get the videos troug a link http://gdata.youtube.com/feeds/api/users/PsyStarcraft/uploads?max-results=50&start-index=51 Any ideeas on how to load them all but whithout making the phone user wait?

'GDataServiceGoogleYouTube *service = [self youTubeService];

NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:@"HuskyStarcraft"
                                                     userFeedID:uploadsID];

[service fetchFeedWithURL:feedURL
                 delegate:self
        didFinishSelector:@selector(request:finishedWithFeed:error:)];

[super viewDidLoad];'

Solution

  • I did this but query setMaxResults won't work. Set start index works fine. Any ideeas?

    GDataServiceGoogleYouTube *service = [self youTubeService];
    
            NSString *uploadsID = kGDataYouTubeUserFeedIDUploads;
            NSURL *feedURL = [GDataServiceGoogleYouTube youTubeURLForUserID:ytid
                                                                 userFeedID:uploadsID
                              ];
    
                NSLog(@"%@", [feedURL path]);
            GDataQueryYouTube* query = [GDataQueryYouTube  youTubeQueryWithFeedURL:feedURL];
            [query setStartIndex:1];
            [query setMaxResults:2];
    
    
    
                [service fetchFeedWithQuery:query
                                   delegate:self
                          didFinishSelector:@selector(request:finishedWithFeed:error:)];
    

    Later, solved it:

    - (GDataServiceGoogleYouTube *)youTubeService {
    static GDataServiceGoogleYouTube* _service = nil;
    
    if (!_service) {
        _service = [[GDataServiceGoogleYouTube alloc] init];
    
        [_service setUserAgent:@"AppWhirl-UserApp-1.0"];
        [_service setShouldCacheDatedData:YES];
        [_service setServiceShouldFollowNextLinks:NO];
    }
    
    // fetch unauthenticated
    [_service setUserCredentialsWithUsername:nil
                                    password:nil];
    
    return _service;
    }
    

    The modified line is

    [_service setServiceShouldFollowNextLinks:NO];

    By the way this is modified from this code: http://pastebin.com/vmV2c0HT