Bogdan Iordachescu
Bogdan Iordachescu

Reputation: 314

Youtube Analytics Reports Query does not match the Youtube Channels List for same video list ID given as a filter

I have a channel of 11 videos, YouTube Analytics returns data only on 9 of them. Here is what I am doing:

First we get the channels video list and make an array of video id.

    statslistitems_list_request = youtube.channels().list(part="snippet, statistics, brandingSettings, contentDetails")

    while statslistitems_list_request:
        statslistitems_list_response = statslistitems_list_request.execute()
        for statslistitems_item in statslistitems_list_response["items"]:
            .....
            playlistitems_list_request = youtube.playlistItems().list(
                playlistId=upload_playlist_id,
                part="snippet,status",
                maxResults=200,
            )
            ....
            for (counter, playlist_item) in enumerate(playlistitems_list_response["items"]):
                ... apend video id found ....

in the end, all is fine, we get the list of id's for example on channel id UCHoRqrRYds_IQ5uey8wAKDA , a list of 11 videos

The the problems is with Youtube Analitics:

    videoparser = argparse.ArgumentParser()
    videoparser.add_argument("--metrics", dest="metrics", help="Report metrics", default="views,comments,likes,shares")
    videoparser.add_argument("--dimensions", dest="dimensions", help="Report dimensions", default="video")
    videoparser.add_argument("--start-date", dest="start_date", help="Start date, in YYYY-MM-DD format", default=ten_years_ago)
    videoparser.add_argument("--end-date", dest="end_date", help="End date, in YYYY-MM-DD format", default=one_day_ago)
    videoparser.add_argument("--start-index", dest="start_index", help="Start index", default=1)
    videoparser.add_argument("--max-results", dest="max_results", help="Max results", default=videos_to_count) # 50
    videoparser.add_argument("--filters", dest="filters", help="filters", default='video==' + video_list) 
    videoparser.add_argument("--sort", dest="sort", help="Sort order", default="-views")
(options_video, args_video) = videoparser.parse_known_args()

    video_analytics_response = youtube_analytics.reports().query(
                ids="channel==%s" % channel_id,
                metrics=options_video.metrics,
                dimensions=options_video.dimensions,
                startDate=options_video.start_date,
                endDate=options_video.end_date,
                startIndex=options_video.start_index,
                maxResults=options_video.max_results,
                filters=options_video.filters,
                sort=options_video.sort
            ).execute()

    video_views_list = video_analytics_response.get("rows", [])

video_views_list will only hold 9 in the upper 11 video id list filter case.

Can you guys tell me why is analitics not returning the same length of video as the filter for video id.

More info: 11 video uploaded on the same day and hour, all video approved and 10 public. 1 video uploaded later.

video_id list:

    OtTgqVGZHiI,
    LJguqUv0Zwk,
    SDx7RYY6er8,
    K6-rH57e6kA,
    oHy4tQAc6Ic,
    7LstRv4eHXA,
    MNla8-2UK_Q,
    N_CrA9h_ZEE,
    PctdfcDm8EY,
    KZiqjNJUalY,
    5zRKUcn8vkE

Analitics response:

    [[u'oHy4tQAc6Ic', 5, 0, 1, 0], 
    [u'LJguqUv0Zwk', 3, 0, 0, 0], 
    [u'5zRKUcn8vkE', 2, 0, 0, 0], 
    [u'K6-rH57e6kA', 2, 0, 0, 0], 
    [u'PctdfcDm8EY', 2, 0, 0, 0], 
    [u'SDx7RYY6er8', 2, 0, 0, 0], 
    [u'7LstRv4eHXA', 1, 0, 0, 0], 
    [u'MNla8-2UK_Q', 0, 0, 0, 0], 
    [u'N_CrA9h_ZEE', 0, 0, 0, 0]]

mising id: OtTgqVGZHiI and KZiqjNJUalY

Upvotes: 0

Views: 200

Answers (0)

Related Questions