问题
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
, andi1 == i2
, andv1 == 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