【问题标题】:How clear my YouTube playlist via API? (delete all playlistitems, but not delete playlist)如何通过 API 清除我的 YouTube 播放列表? (删除所有播放列表项,但不删除播放列表)
【发布时间】:2015-03-04 05:34:39
【问题描述】:

如何通过 API 清除我的 YouTube 播放列表?需要删除所有播放列表项,但不删除播放列表。 我当然知道 - 需要循环 1. 获取播放列表 ID 2. 删除它 3. 等等 但可能是更简单的方法? 谢谢!

【问题讨论】:

    标签: api youtube youtube-api


    【解决方案1】:

    它记录在 Youtube API 中。这是删除 playListItems 应遵循的流程。 从 PlayList 中获取 plaListItems 列表。

    https://developers.google.com/youtube/v3/docs/playlists/list - 使用列表

    从播放列表中获取项目列表后,使用“DELETE playListItem” https://developers.google.com/youtube/v3/docs/playlistItems/delete

    【讨论】:

      【解决方案2】:

      我通过删除播放列表然后重新创建它解决了这个问题。以下是 Kotlin 代码,mYouTube 是根据 API 认证的 youtube 对象:https://developers.google.com/youtube/v3/guides/authentication

      // Delete the playlist
      mYouTube.playlists().delete({playlistId}).execute()
      
      // Create a new playlist
      val playlist = Playlist()
      
      playlist.snippet = PlaylistSnippet()
      playlist.snippet.title = {playlist title}
      playlist.status = PlaylistStatus()
      
      mYoutube.playlists().insert("snippet,status", playlist).execute()
      

      【讨论】:

      • 这也将视图计数重置为零。
      猜你喜欢
      • 1970-01-01
      • 2018-06-24
      • 2017-06-25
      • 2014-02-07
      • 2021-08-11
      • 1970-01-01
      • 2013-11-22
      • 2015-04-23
      相关资源
      最近更新 更多