Replies: 1 comment 1 reply
|
What issue does this solve? You can already move items to the top of the playlist |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I've discovered that the YouTube API supports an additional action,
ACTION_MOVE_VIDEO_AFTER, which can be used to move an item to the top of a playlist. This feature could potentially enhance the functionality of theedit_playlist()mixin.Based on this finding, I'd like to propose the following modification:
[...] def edit_playlist( [...] moveItem: Optional[Union[str, tuple[str, str]]] = None, """ [...] :param moveItem: Optional tuple to move an item in the playlist. Format: (item1, item2) - (None, item2): Move item to the top of the playlist. - (item1, None): Move item to the bottom of the playlist. - (item1, item2): Move item1 before item2. Items are identified by their setVideoId which is the unique id of a playlist item. See get_playlist() for details. [...] """ [...] if isinstance(moveItem, tuple): item1, item2 = moveItem if item1 is None and isinstance(item2, str): # Move item to top of the playlist action = { "action": "ACTION_MOVE_VIDEO_AFTER", "setVideoId": item2 } elif isinstance(item1, str) and item2 is None: # Move item to the bottom of the playlist action = { "action": "ACTION_MOVE_VIDEO_BEFORE", "setVideoId": item1 } elif isinstance(item1, str) and isinstance(item2, str): # Move item1 before item2 action = { "action": "ACTION_MOVE_VIDEO_BEFORE", "setVideoId": item1, "movedSetVideoIdSuccessor": item2 } else: raise ValueError("Invalid moveItem tuple format") actions.append(action) elif isinstance(moveItem, str): # keep supporting the previous way of doing it action = { "action": "ACTION_MOVE_VIDEO_BEFORE", "setVideoId": moveItem } actions.append(action) [...]I know this might affect other parts of the code, so feel free to use this idea however you see fit, if you think it's worth it. Let me know if you need anything else!
All reactions