YouTube Data API: How unique is PlaylistItem ID?

醉酒当歌 提交于 2021-02-11 14:47:11

问题


Is there a real unique ID for a Video on a YouTube playlist? YouTube offers a playlistItem.id and tells us that this ID is...

The ID that YouTube uses to uniquely identify the playlist item

What I've found out is that this ID is the ID of the Position of a PlaylistItem within a Playlist. If you delete your one and only video on a playlist and you put another video on your playlist, then this new video will have the same PlaylistItem.id.

Any recommendations how to fake a real unique ID?


回答1:


I think that the tuple

<playlistId, playlistItemId, videoId>

could be taken as a globally unique playlist item ID. Of course, for t1 := <p1, i1, v1> and t2 := <p2, i2, v2>, by definition t1 == t2 if and only if:

  • p1 == p2, and
  • i1 == i2, and
  • v1 == v2.

Since each component of such a tuple is a string that contains no comma, the tuple itself can simply be represented by the concatenation of these three strings separated by comma.

Encoding the ID tuples as mentioned implies that the componentwise ID tuples equality (as defined above) becomes trivially the string equality.

Decoding such an ID to its components is also trivial. Any modern language has readily available standard functions to do precisely such operation. For example, in Python that function is str.split; in PHP that is explode.



来源:https://stackoverflow.com/questions/65275884/youtube-data-api-how-unique-is-playlistitem-id

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