Exemple #1
0
def get_sub_vids(youtube, credentials, MAX_VIDS, MAX_AGE):
    channels = get_updated_channels(youtube, credentials)
    
    playlist_queries = []
    for ch in channels:
        q = channel_playlists_query(youtube, credentials, ch)
        q._name = ch
        playlist_queries.append(q)
    
    resps = batch.batch_query(batch.get_http_factory(credentials), playlist_queries)
    upload_playlists = [_UploadPlaylist(r[0]._name, r[2]) for r in resps]
    
    return get_videos_in_playlists(youtube, credentials, upload_playlists, MAX_VIDS, MAX_AGE)
Exemple #2
0
def get_videos_in_playlists(youtube, credentials, playlist_list, MAX_VIDS, MAX_AGE):
    assert MAX_VIDS >= -1
    assert MAX_AGE >= -1

    playlist_queries = []
    
    for playlist in playlist_list:
        query = batch.Query(youtube.playlistItems().list,
                            {'playlistId':playlist.playlist_id,
                             'part':'snippet'},
                            limit=(batch.QueryLimitCount(MAX_VIDS),
                                   batch.QueryLimitAge(MAX_AGE)))
        query._name = playlist
        playlist_queries.append(query)
    
    resps = batch.batch_query(batch.get_http_factory(credentials), playlist_queries)
    uploaded_vids = []
    for r in resps:
        author = r[0]._name.author_name
        response = r[2]
        
        uploaded_vids.extend([Vid(author, item) for item in response['items']])
    
    return uploaded_vids