YouTube 数据 api 未按 viewCount 排序

2024-05-14

我正在尝试按 viewCount 从高到低排序 YouTube 频道视频。但结果并不是按最大观看次数排序。

以下是我正在使用的 API:

https://www.googleapis.com/youtube/v3/search?key={api-key}&channelId={channel-id}&part=snippet,id&order=viewCount&maxResults=20

您的 API 请求似乎检索按以下排序的结果viewCount正如预期的那样。

我尝试使用 YouTube 频道“盲目的自我放纵 https://www.youtube.com/channel/UChS8bULfMVx10SiyZyeTszw".

API请求如下:

https://www.googleapis.com/youtube/v3/search?part=snippet%2C+id&channelId=UChS8bULfMVx10SiyZyeTszw&maxResults=20&order=viewCount&fields=items(id%2Csnippet(channelId%2CchannelTitle%2Cdescription%2CpublishedAt%2Ctitle))%2Ckind%2CnextPageToken%2CpageInfo%2CprevPageToken%2CtokenPagination&key={YOUR_API_KEY}

You can 之前的请求。

请求的结果是:

注意:忽略<pre> and </pre> tags:

<pre>
{
 "kind": "youtube#searchListResponse",
 "nextPageToken": "CBQQAA",
 "pageInfo": {
  "totalResults": 140,
  "resultsPerPage": 20
 },
 "items": [
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "dM6elRs7F5k"
   },
   "snippet": {
    "publishedAt": "2007-01-04T00:06:56.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "**Mindless Self Indulgence \"Straight To Video\" music video**",
    "description": "\"Straight To Video\" from \"You'll Rebel To Anything\" (UCR/Metropolis) Director: Poz Lang DP: Daniel Fickle Producer: Jim Muscarella for Hi Tide Pictures ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "UR0UkTiKxmc"
   },
   "snippet": {
    "publishedAt": "2008-08-05T23:09:09.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence \"Never Wanted To Dance\" Music Video",
    "description": "Trouble with the volume? Report it at http:/ /tinyurl.com/6aeoe2 This is a YOUTUBE error, not on MSI's end...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "0GLoHifu6aM"
   },
   "snippet": {
    "publishedAt": "2011-01-13T01:41:10.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "The Left Rights - \"I'M ON CRACK\" Music Video",
    "description": "Video by Mike Diva http://www.youtube.com/mikediva Co-Director Pedro Flores http://www.youtube.com/peedeeflo \"Bad Choices Made Easy\" is out NOW: CD: ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#channel",
    "channelId": "UChS8bULfMVx10SiyZyeTszw"
   },
   "snippet": {
    "publishedAt": "2006-07-10T20:54:29.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence",
    "description": "The OFFICIAL YouTube source for all things Mindless Self Indulgence -- be sure to subscribe for news on the upcoming MSI music videos, and exclusives!",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "xfBQppaKcS8"
   },
   "snippet": {
    "publishedAt": "2010-11-02T21:33:13.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "The Left Rights - Genesis 16:12",
    "description": "Music video for The Left Rights' \"Genesis 16:12\". Created by M dot Strange. http://www.youtube.com/user/mdotstrange The Left Rights are Jimmy Urine & Steve, ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "JGMFzvvsrpg"
   },
   "snippet": {
    "publishedAt": "2006-08-02T22:24:11.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - \"Stupid MF\" (live) Worcester, MA",
    "description": "Mindless Self Indulgence performing \"Stupid MF\" live on the Cursing in Braille tour. Recorded at The Palladium on 7/20/2006 in Worcester, MA. Video Crew: ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "PNFjLzVKVdk"
   },
   "snippet": {
    "publishedAt": "2013-10-15T01:20:26.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence \"It Gets Worse\" Lyric Video",
    "description": "Created by M dot Strange Album available here: http://bit.ly/ 146xOB9 Tour info here: http://on.fb.me/17c5OY9 \"It Gets Worse\" digital single available here: ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "s_Gyh1r-ut0"
   },
   "snippet": {
    "publishedAt": "2009-01-12T06:27:32.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - Mark David Chapman Official Music Video",
    "description": "MSI's \"Mark David Chapman\" Video by Mike Diva http://www.youtube.com/mikediva Get the song and music video (in 3 formats including iPod, iPhone, and HQ) ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "CQUy82eN43g"
   },
   "snippet": {
    "publishedAt": "2010-11-09T20:04:20.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "The Left Rights \"FREE PORN\" Music Video",
    "description": "\"Bad Choices Made Easy\" is out NOW: CD: http://www.metropolis-mailorder.com/product.php?prodnum=MET+687 Deluxe MP3 Album: ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "AFEHvYNz490"
   },
   "snippet": {
    "publishedAt": "2008-04-21T02:46:58.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - MSI's \"Animal\" by M dot Strange",
    "description": "From the limited edition deluxe version of MSI's new album, \"IF\" (out NOW worldwide). Order it now at http://www.theomegaorder.com/msi Modeled, rigged, ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "DjQzoIHyW2w"
   },
   "snippet": {
    "publishedAt": "2007-08-30T02:17:49.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence 'Golden I'/'Our Pain Your Gain' DVD",
    "description": "Mindless Self Indulgence perform \"Golden I\" from the upcoming MSI debut DVD, \"Our Pain, Your Gain\" in stores September 11th. Want to win MSI concert tickets, ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "BF9BgIOb2Ew"
   },
   "snippet": {
    "publishedAt": "2007-09-07T20:32:31.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence 'Clarissa'/'Our Pain Your Gain' DVD",
    "description": "http://www.reccenter.com & Mindless Self Indulgence bring you "Clarissa" from the upcoming MSI debut DVD, "Our Pain, Your Gain" in stores September 11th.",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "XtjTxDU2XFI"
   },
   "snippet": {
    "publishedAt": "2015-11-03T18:50:13.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - Personal Jesus (Official Video)",
    "description": "Directed by Yarvo. Buy \"Pink\": http://smarturl.it/getpink \"Pink\" Bundle: http://merchnow.com/catalogs/mindless-self-indulgence/bundles.",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "17kGWHLg3wU"
   },
   "snippet": {
    "publishedAt": "2013-08-02T18:55:56.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - How I Learned To Stop Giving A Shit & Love Mindless Self Indulgence",
    "description": "Sign up for the website and add your tour history! http://mindlessselfindulgence.com/past-shows/ 1- \"Witness\" 0:00 | 3:16 2- \"Fuck Machine\" 3:17 | 6:40 3- \"It Gets ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "-kXrv10hr2I"
   },
   "snippet": {
    "publishedAt": "2006-08-01T23:31:27.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence Give Fan A Haircut Onstage!",
    "description": "Mindless Self Indulgence give a fan a haircut on the Cursing in Braille tour. Recorded at The Palladium on 7/20/2006 in Worcester, MA. Video Crew: ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "NNcM11Bx7VM"
   },
   "snippet": {
    "publishedAt": "2006-09-01T17:05:44.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - \"Bring The Pain\" live in NJ",
    "description": "Mindless Self Indulgence performing \"Bring The Pain\" live on the Cursing in Braille tour. Recorded at the Starland Ballroom on 7/21/2006 in Sayreville, NJ.",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "k37WOBvc6vU"
   },
   "snippet": {
    "publishedAt": "2006-10-03T21:57:07.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - \"Pay For It\" (live) Worcester, MA",
    "description": "Mindless Self Indulgence performing \"Pay For It\" live on the Cursing in Braille tour. Recorded at The Palladium on 7/20/2006 in Worcester, MA. Video Crew: ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "xIQtBPTTrwE"
   },
   "snippet": {
    "publishedAt": "2014-02-03T20:46:29.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence \"Fuck Machine\" AMV Cartoon",
    "description": "Animation by MoreFrames Animation Art by BiteyTheVillain Sign up for the website and add your tour history! http://mindlessselfindulgence.com/past-shows/",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "nL7-oPP-_ZA"
   },
   "snippet": {
    "publishedAt": "2012-12-06T15:22:48.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence \"It Gets Worse\" NEW DEMO!",
    "description": "HOW I LEARNED TO STOP GIVING A SHIT AND LOVE MINDLESS SELF INDULGENCE is out now: http://bit.ly/ 11mfkoY.",
    "channelTitle": "Mindless Self Indulgence"
   }
  },
  {
   "id": {
    "kind": "youtube#video",
    "videoId": "wRR-_O3kbX8"
   },
   "snippet": {
    "publishedAt": "2006-07-12T19:22:03.000Z",
    "channelId": "UChS8bULfMVx10SiyZyeTszw",
    "title": "Mindless Self Indulgence - \"Brooklyn Hype (1+2)\" (live) NYC",
    "description": "Mindless Self Indulgence performing \"Brooklyn Hype (Parts 1+2)\" live at a secret show under the alias Bette Davis Eyes. Recorded at CBGB's on 2/24/2004 in ...",
    "channelTitle": "Mindless Self Indulgence"
   }
  }
 ]
}
</pre>

我确实按照以下步骤检查了结果是否正确:

  • 使用视频列表 API https://developers.google.com/youtube/v3/docs/videos/list,使用videoIddM6elRs7F5k返回先前结果的第一个元素及其viewCount值设置为9921351。对于之前结果中返回的第二项(即视频IDUR0UkTiKxmc)我向视频列表 API https://developers.google.com/youtube/v3/docs/videos/list和它的viewCount值设置为4798354.

这里是对于视频 ID =dM6elRs7F5k

这里是对于视频 ID =UR0UkTiKxmc

  • 感谢这个答案 https://webapps.stackexchange.com/a/79054/207498,您可以通过修改 URL 来检索给定channel_id 中观看次数最多的视频。

    https://www.youtube.com/channel/UChS8bULfMVx10SiyZyeTszw/videos?sort=video_view_count https://www.youtube.com/channel/UChS8bULfMVx10SiyZyeTszw/videos?sort=video_view_count

通过将 search.list API 的结果与网站中显示的结果进行匹配(输入上面的网址)- 您可以检查 API 的结果是否准确。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

YouTube 数据 api 未按 viewCount 排序 的相关文章

随机推荐

  • 处理聚合的所有事件

    请参阅下面我的第一个持久订阅 namespace PersistentSubscription internal class Program private static void Main var subscription new Per
  • 使用 InlineKeyboardButton python telegram bot 发送命令

    在Python电报机器人中 是否有可能InlineKeyboardButton发送类似命令 cancel当它被按下时 例如 当用户按下取消按钮时 他们将自动发送 cancel 命令 然后由机器人处理 从这里的例子来看 https githu
  • 作为对象访问 vue-i18n 消息

    我想创建一个取决于页面的动态滑块 security signin slide1 Kitten1 slide2 Kitten2 signup slide1 Kitten1 slide2 Kitten2 slide3 Kitten3 问题是我想
  • flutter web http.get 返回“不支持的操作:Platform._version”

    我正在开发 flutter web 应用程序并尝试从互联网获取一些数据 我正在使用包 http http dart 并尝试这样做 await http get url 但我得到了这个错误 不支持的操作 Platform version da
  • Mapkit 在 IOS 13 中使用过多的 CPU

    最近 在一些用户更新到 iOS 13 x 后 我的 iOS 应用程序开始频繁崩溃 在 iOS 12 x 中没有出现该问题 我正在使用 Mapkit 渲染一些 MKPolygons 和 MKPolylines MKPolylines 被删除并
  • 使用 JPA 标准 API 进行日期比较

    我有一个包含两个日期的范围日期选择器 start and end 其中两者都可以为空 我想过滤一张表 其中实体具有确切的一个日期 date 所以 这里有一些例子 我愿意匹配 想象要匹配的日期是当前日期 17 07 2016 空 17 07
  • Angular *ngFor 循环遍历数组的数组

    我有一个数组 其中包含其他数组 如下所示 array element A element B YES NO 我想使用 ngFor 循环遍历 HTML 表中的这个对象数组 table thead tr th th th COLUMN 1 th
  • 如果条件长度 > 1 并且仅使用第一个元素,为什么我会在 R 中收到此警告

    我有下面的源代码 这if is na monthData 用于检查是否monthData is NA 如果是 则为其分配一个初始值 monthData lt NA if category QUARTER for m in c rep 1 4
  • 如果tinyMCE编辑器为空,如何通过在其旁边附加字符串来验证它?

    我需要验证一个表格 此表单有一些下拉菜单和tinyMCE编辑器 我通过在每个字段后附加字符串 Required 如果为空 来验证此表单 但是我无法验证tinyMCE编辑器 如果编辑器为空 我尝试了类似的操作 tinyMCE get tiny
  • 为什么不能在 Fragment 中使用 ViewPager?它实际上是

    有信息无法使用ViewPager在一个Fragment在许多来源中 例如 Android 开发者繁忙编码指南 http commonsware com 作者 Mark Murphy 或者类似的帖子this https stackoverfl
  • PHP MySQL 查询带有 %s 和 %d

    SELECT COUNT AS test FROM s WHERE id d AND tmp mail lt gt 什么是 s and d for 这些是使用的格式符号 例如经过sprintf 例子 Output SELECT COUNT
  • 无法在我的 Django 项目中使用 Sphinx 生成自动文档

    我正在向我的 Django 项目添加文档 github链接 https github com augustakingfoundation queryjane app 该项目是开源的 使用sphinx 但是当尝试生成python文件的auto
  • OAuth2 隐式流程 - IFrame 刷新身份

    我正在为隐式流开发 OAuth2 客户端 并正在实现基于 IFrame 的刷新 因为隐式流中没有刷新令牌 我所坚持的是试图找出将访问令牌传递回服务器的 标准 我是否通过 access token 查询字符串参数传回 或者在设置 IFrame
  • 音频流的最佳实践

    我正在编写一个应用程序来播放远程服务器的音频 我尝试了多种方法来实现流音频 但它们对我来说都不够好 这就是我尝试过的 幼稚地使用 MediaPlayer 就像是 MediaPlayer player new MediaPlayer play
  • 将数组数据从 html 表单传递到 php 数组变量

    我有一张表格来记录一组项目的工作时间 该表单使用项目 ID 小时数和注释字段的数组 表单行是项目数量的循环 该表单将数据传递给 PHP 脚本进行处理 PHP 脚本没有看到数组中的值 它只是给我 Array 作为输出 文档和其他示例让我想知道
  • 如何在 Xamarin.iOS 应用程序中创建导航?

    我习惯于与Xamarin Forms 我用 XAML 或 C 创建一个页面并导航到它 但现在这是我第一次尝试创建一个不适合的 iOS 应用程序Xamarin Forms 我在 Windows PC 上的 Visual Studio 中进行此
  • 是否可以将整个“卡片”包装在 标记中?

    在我的网站中 我有 卡片 每张卡片都包含许多元素 图像 文本 日期等 这有点像 Twitter 中的推文卡 我希望整个卡片都是可点击的 应该是到另一个页面的链接 目前 我有顶级元素作为 a 标记和使用aria label and aria
  • 删除 R 中具有重复属性的行

    我有一个大数据框 其中包含以下列 ID time OS IP 该数据帧的每一行对应一个条目 在该数据框中对于某些IDs存在多个条目 行 我想删除这些多行 显然 同一 ID 的其他属性会有所不同 或者换句话说 我只想要每个 ID 一个条目 行
  • 提升 asio 和 endian

    我不知道 boost asio 是否处理字节序 Asio 确实会转换类似的东西port进入网络秩序 转换函数不作为官方接口的一部分公开 而是隐藏在detail名称空间代替 例如boost asio detail socket ops hos
  • YouTube 数据 api 未按 viewCount 排序

    我正在尝试按 viewCount 从高到低排序 YouTube 频道视频 但结果并不是按最大观看次数排序 以下是我正在使用的 API https www googleapis com youtube v3 search key api ke