YouTube Data API v3 does not have unique IDs for resources

我与影子孤独终老i 提交于 2021-01-28 02:11:57

问题


This is befuddling me and seems a bit ludicrous. When I execute two different queries on the Data API (take the example request on the Activities List endpoint as a proof of concept) the id for resources are not the same between requests.

Here's an activity resource from my first request:

{
    "kind": "youtube#activity",
    "etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/uGfbHYfKHEFhxWYbbmVxyBbQvNk\"",
    "id": "VTE1MjI3NzQwODY5NDMzMzYyOTc5NjQ5Ng==",
    "snippet": {
        "publishedAt": "2018-04-03T16:48:06.000Z",
        "channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
        "title": "Google Summer of Code 2013 Mentor Summit",
        // ...
    }
    // ...
}

Note the id value, which is "the ID that YouTube uses to uniquely identify the activity" according to the API documentation.

Here's my second request:

{
    "kind": "youtube#activity",
    "etag": "\"RmznBCICv9YtgWaaa_nWDIH1_GM/dzIxWbnYZ3xx-1zi2VQ0V_f5PII\"",
    "id": "VTE1MjI3NzQwODY5NDYzMDM0OTg5MDAwMA==",
    "snippet": {
        "publishedAt": "2018-04-03T16:48:06.000Z",
        "channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
        "title": "Google Summer of Code 2013 Mentor Summit",
        // ...
    }
    // ...
}

The id is different for the same resources. Although first few characters are the same, I've tried to truncate the id but it's still not unique for all resources.

I'm wondering if the id is the de facto way to uniquely identify resources. Has anyone run into this? Is this the proper behavior? How do I uniquely identify resources if the id that YouTube provides is not the way? I could put together a hacky solution, but this doesn't seem right.

Would love to hear thoughts.


回答1:


The solution I used was to take the hash of the publish date of the activity and the channel ID appended together. This does not sit well with me, but it's the solution I went with.



来源:https://stackoverflow.com/questions/49639258/youtube-data-api-v3-does-not-have-unique-ids-for-resources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!