一些斗鱼TV Web API [Some DouyuTv API]

 

写在最前

去年TI5前开发了dotaonly.com,网站需要用到各个直播平台API。不像国外网站Twitch那样开放,都有现成的API可用,国内网站都很封闭,对开发者不太友好。本文所涉及API皆抓取自斗鱼IOS手机客户端。

首先是不需要登录的API

获取当前全部直播

请求地址:
http://capi.douyucdn.cn/api/v1/live?limit=20&offset=0
参数:
limit: 一次获取的个数
offset:起始位置,比如要获取前20个之后的 offset=20, 下同
返回数据

{
"error": 0,
"data": [
{
"room_id": "16101",
"room_src": "http://rpic.douyucdn.cn/z1602/22/16/16101_160222165702.jpg",
"cate_id": "1",
"room_name": "微笑: 过节就应该带妹!",
"show_status": "1",
"subject": "",
"show_time": "1456126421",
"owner_uid": "391270",
"specific_catalog": "weixiao",
"specific_status": "1",
"vod_quality": "0",
"nickname": "微笑",
"online": 1075780,
"url": "/weixiao",
"game_url": "/directory/game/LOL",
"game_name": "英雄联盟",
"child_id": "28",
"fans": "936235"
}
]
}
12345678910111213141516171819202122232425

获取父频道

请求地址:
http://capi.douyucdn.cn/api/v1/getColumnList
部分返回数据:

    {
"error": 0,
"data": [
{
"cate_id": "1",
"cate_name": "游戏",
"short_name": "game",
"orderdisplay": "1",
"is_relate": "1",
"is_del": "0",
"push_ios": "1",
"push_show": "0"
},
{
"cate_id": "9",
"cate_name": "手机游戏",
"short_name": "sjyx",
"orderdisplay": "2",
"is_relate": "1",
"is_del": "0",
"push_ios": "1",
"push_show": "0"
}
]
}
12345678910111213141516171819202122232425

获取子频道

请求地址:
http://capi.douyucdn.cn/api/v1/getColumnDetail?shortName=game
参数:
shortName: 父频道名字,来自上一个请求返回数据中的short_name
部分返回数据:

{
"error": 0,
"data": [
{
"tag_id": "134",
"short_name": "wsm",
"tag_name": "玩数码",
"pic_name": "7c855c7fa9c8c03697ee61748999d112.jpg",
"icon_name": "a3f49c62bd6156b358a275a07a5b95dd.jpg",
"orderdisplay": "126",
"rank_score": "0",
"night_rank_score": "0",
"nums": "0",
"push_ios": "1",
"push_home": "1",
"is_game_cate": "0",
"cate_id": "3",
"is_del": "0",
"is_relate": "1",
"pic_url": "http://staticlive.douyutv.com/upload/game_cate/7c855c7fa9c8c03697ee61748999d112.jpg",
"url": "/directory/game/wsm",
"icon_url": "http://staticlive.douyutv.com/upload/game_cate/a3f49c62bd6156b358a275a07a5b95dd.jpg",
"count": 15,
"count_ios": 8
},
{
"tag_id": "136",
"short_name": "car",
"tag_name": "玩汽车",
"pic_name": "6b83cf650fb4ba62881c9c528ab602d5.jpg",
"icon_name": "ade2b45ee56831c3b100a436b8c2f624.jpg",
"orderdisplay": "127",
"rank_score": "0",
"night_rank_score": "0",
"nums": "0",
"push_ios": "1",
"push_home": "1",
"is_game_cate": "0",
"cate_id": "3",
"is_del": "0",
"is_relate": "1",
"pic_url": "http://staticlive.douyutv.com/upload/game_cate/6b83cf650fb4ba62881c9c528ab602d5.jpg",
"url": "/directory/game/car",
"icon_url": "http://staticlive.douyutv.com/upload/game_cate/ade2b45ee56831c3b100a436b8c2f624.jpg",
"count": 4,
"count_ios": 2
}
]
}
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849

获取父频道所有直播列表

请求地址:
http://capi.douyucdn.cn/api/v1/getColumnRoom/<cate_id>?limit=20&offset=0
参数:
cate_id: 父频道id
limit
offset
返回数据:

{
"error": 0,
"data": [
{
"room_id": "536341",
"room_src": "http://rpic.douyucdn.cn/z1602/22/17/536341_160222172043.jpg",
"cate_id": "134",
"room_name": "22日晚5点30分MWC现场探馆看产品",
"show_status": "1",
"subject": "",
"show_time": "1456132678",
"owner_uid": "38598100",
"specific_catalog": "",
"specific_status": "0",
"vod_quality": "0",
"nickname": "ZOL中关村在线",
"online": 1969,
"child_id": "0"
},
{
"room_id": "279558",
"room_src": "http://rpic.douyucdn.cn/z1602/22/17/279558_160222171918.jpg",
"cate_id": "136",
"room_name": "[24H斗鱼第一专业车评]陈震YYP选车",
"show_status": "1",
"subject": "",
"show_time": "1455963983",
"owner_uid": "18462494",
"specific_catalog": "",
"specific_status": "0",
"vod_quality": "0",
"nickname": "金叔2015",
"online": 12304,
"child_id": "0"
}
]
}
12345678910111213141516171819202122232425262728293031323334353637

获取子频道直播列表

请求地址:
http://capi.douyucdn.cn/api/v1/live/<tag_id>?&limit=1&offset=0
参数:
tag_id: 子频道id
limit
offset
返回数据:

{
"error": 0,
"data": [
{
"room_id": "536341",
"room_src": "http://rpic.douyucdn.cn/z1602/22/17/536341_160222172043.jpg",
"cate_id": "134",
"room_name": "22日晚5点30分MWC现场探馆看产品",
"show_status": "1",
"subject": "",
"show_time": "1456132678",
"owner_uid": "38598100",
"specific_catalog": "",
"specific_status": "0",
"vod_quality": "0",
"nickname": "ZOL中关村在线",
"online": 5700,
"url": "/536341",
"game_url": "/directory/game/wsm",
"game_name": "玩数码",
"child_id": "0",
"fans": "4084"
}
]
}
12345678910111213141516171819202122232425

获取房间信息

请求地址:
http://capi.douyucdn.cn/api/v1/room/<room_id>?aid=android&client_sys=android&time=<time>&auth=c0a6170a754ca187e8a52a3343ecf273
参数:
room_id: 房间ID
time: unix_time/1000
auth: md5("room/"+room_id+"?aid=android&client_sys=android&time="+1231) 注意:time要和上面一致,android也不能改成ios
插曲[不重要可以跳过不看]:为了查找auth的算法,我先是反编译了斗鱼的apk,结果他们把算法藏在了JNI里,随后尝试反汇编找出来的Share Object,无果。然后在斗鱼网页里的javascript里各种找,也没有,不过发现网页里也有一条类似的API,是从swf里发出的。之后去逐个反编译斗鱼网页里的swf,发现核心的core.swf是被加密了的,好在webroom.swf里找到了解密逻辑。解密后找到一个算sign/auth的function,然而没看懂,是一种变形的C。。最后的最后我在github上搜了一下之前解密用的key,发现之前果然有大神找到了auth算法,附链接。拿到算法,玩了一圈发现必须是这个格式才行,把android换成ios就会验证失败。
返回数据:

{
"error": 0,
"data": {
"room_id": "58428",
"room_src": "http://rpic.douyucdn.cn/z1602/23/23/58428_160223234559.jpg",
"cate_id": "3",
"room_name": "yyf直播间 电子竞技只有锤!",
"vod_quality": "0",
"show_status": "2",
"show_time": "1456221459",
"owner_uid": "236231",
"specific_catalog": "",
"specific_status": "1",
"online": 0, // 这个是在线人数,虽然比较虚
"nickname": "yyfyyf",
"url": "/58428",
"game_url": "/directory/game/DOTA2",
"game_name": "DOTA2",
"game_icon_url": "http://staticlive.douyutv.com/upload/game_cate/bfe845a28fef8106cf645ed3b83aa375.jpg",
"rtmp_url": "", //如果再直播会有,我抓这个时候鱼鱼枫已经被怼的下播了
"rtmp_live": "",
"rtmp_cdn": "",
"rtmp_multi_bitrate": [],
"hls_url": "",
"servers": [ //这个就比较重要了,这个是弹幕验证服务器列表!弹幕相关的socket加密解密源代码我也找到了。如有需求请留言,我看情况发出来。
{
"ip": "119.90.49.93",
"port": "8063"
},
....略
],
"use_p2p": "0",
"room_dm_delay": 30,
"black": [],
"show_details": "yyf贴吧: http://tieba.baidu.com/f?kw=yyf&amp;fr=ala0&amp;tpl=5\n新浪微博: http://www.weibo.com/u/2176141495/home?wvr=5",
"owner_avatar": "http://uc.douyutv.com/avatar.php?uid=236231&size=big",
"cdns": [],
"owner_weight": "304.67t", //主播体重
"fans": "492867", //这个应该是关注数。
"gift": [ //一些礼物信息
{
"id": "59",
"name": "火箭",
"pc": "50000",
"type": "2",
"gx": 5000,
"desc": "赠送网站广播并派送出神秘宝箱",
"intro": "我们的征途是星辰大海",
"ef": 1,
"pimg": "http://staticlive.douyutv.com/upload/dygift/447b61f6c0d6890d4490a90d0bdbf8bc.png",
"mimg": "http://staticlive.douyutv.com/upload/dygift/ab957377200959761121a3791a54b9b7.png",
"cimg": "http://staticlive.douyutv.com/upload/dygift/7dce6b2170eebecf85596b47370217ce.gif",
"himg": "http://staticlive.douyutv.com/upload/dygift/7f0643700d331aca31a6f6ea255e323e.gif",
"stay_time": 200000,
"drgb": "",
"urgb": "#732909",
"grgb": "#732909",
"brgb": "#5861b5",
"pdbimg": "http://staticlive.douyutv.com/upload/dygift/005786105dd86e3964732e7fc2fc2085.png",
"pdhimg": "http://staticlive.douyutv.com/upload/dygift/6ffb9bc8d35d315943ae117dc788824e.gif",
"small_effect_icon": "http://staticlive.douyutv.com/upload/dygift/75e55aae938fc703d977e8c966fef91d.png",
"big_effect_icon": "http://staticlive.douyutv.com/upload/dygift/40f964e70faa46923dcc4c4931bbac8f.gif",
"pad_big_effect_icon": "http://staticlive.douyutv.com/upload/dygift/ccffe8c6453074a68be1730802203241.gif"
},
...略
]
}
}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768

搜索直播间

请求地址:
http://capi.douyucdn.cn/api/v1/searchNew/<search_string>/1?limit=1&offset=0
参数:
search_string: 要搜索的内容,房间id或者房间名
limit:
offset:
返回数据:

{
"error": 0,
"data": {
"count": 299,
"room": [
{
"room_id": "73327",
"room_src": "http://rpic.douyucdn.cn/z1602/24/02/73327_160224021924.jpg",
"cate_id": "134",
"room_name": "返回Windows写个博客",
"show_status": "1",
"subject": "",
"show_time": "1456244441",
"owner_uid": "2154075",
"specific_catalog": "dotaonly",
"specific_status": "1",
"vod_quality": "0",
"nickname": "ShaneX",
"online": 5,
"child_id": "0",
"url": "/dotaonly",
"game_url": "/directory/game/wsm",
"game_name": "玩数码",
"fans": "2490"
}
]
}
}
12345678910111213141516171819202122232425262728

以上就是我觉着有用的不用登陆可获取API,下面是需要登陆的

需登陆可用的API

获取登陆token

请求地址:
http://capi.douyucdn.cn/api/v1/login?username=<user_name>&password=<password_md5>
参数:
user_name: 用户名
password_md5: 密码的md5
返回数据:

{
"error": 0,
"data": {
"uid": "2154075",
"username": "auto_beKEugHSJv",
"nickname": "ShaneX",
"email": "245****@qq.com", //不知道斗鱼为何要遮蔽邮箱以及下面的电话
"qq": "",
"mobile_phone": "150****3913",
"phone_status": "1",
"email_status": "1",
"lastlogin": "1455383420",
"avatar": { //头像
"small": "http://uc.douyutv.com/avatar.php?uid=2154075&size=small",
"middle": "http://uc.douyutv.com/avatar.php?uid=2154075&size=middle",
"big": "http://uc.douyutv.com/avatar.php?uid=2154075&size=big"
},
"has_room": "1", //是否是直播
"groupid": "1",
"is_own_room": "1",
"gold1": "4772", //鱼丸数
"score": "117020", //经验值
"level": {
"current": {
"lv": 12,
"pic": "user12.gif",
"mpic": "gold05.png",
"name": "黄金5",
"pic_url": "http://staticlive.douyutv.com/common/douyu/images/classimg/user12.gif?v=v26185",
"score": 100000
},
"next": {
"lv": 13,
"pic": "user13.gif",
"mpic": "gold04.png",
"name": "黄金4",
"pic_url": "http://staticlive.douyutv.com/common/douyu/images/classimg/user13.gif?v=v26185",
"score": 150000
}
},
"follow": "35",
"ios_gold_switch": 1,
"gold": "372.4", //鱼翅
"token": "a**********a", //token!
"token_exp": 1457111772 //过期时间,十天
}
}
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647

获取个人信息

请求地址:
http://capi.douyucdn.cn/api/v1/my_info?token=<token>
参数:
token: 登陆token
返回数据:

和上面的一毛一样。
1

获取关注列表

请求地址:
http://capi.douyucdn.cn/api/v1/remind_list?token=<token>&limit=1&offset=1
参数:
token:
limit:
offset:
请求地址2:
http://capi.douyucdn.cn/api/v1/followRoom?token=<token>&live=1
参数:
token:
live: 1是正在直播的,0是没开直播的
返回数据:

{
"error": 0,
"data": [
{
"id": "163643",
"room_id": "163643",
"room_src": "http://rpic.douyucdn.cn/z1602/24/00/163643_160224001525.jpg",
"cate_id": "26",
"nickname": "蓝天上的流云",
"show_status": "2",
"owner_uid": "4773042",
"name": "【流云红警】一个人默默地直播,5555~",
"game_tag_id": "26",
"game_tag_name": "怀旧游戏",
"owner": "蓝天上的流云",
"owner_avatar_small": "http://uc.douyutv.com/avatar.php?uid=4773042&size=small",
"owner_avatar_middle": "http://uc.douyutv.com/avatar.php?uid=4773042&size=middle",
"owner_avatar_big": "http://uc.douyutv.com/avatar.php?uid=4773042&size=big",
"remind_status": "0",
"live_status": "2",
"online": 0,
"show_time": "1456238974",
"fans": "47425"
}
]
}
1234567891011121314151617181920212223242526

取消关注

【POST】请求地址:
http://capi.douyucdn.cn/api/v1/follow/del

参数:
ids: 要取消关注的列表, e.g.:123,321,132
返回数据:

{
"error": 0,
"data": [20360, 184219]
}
1234

获取观看历史

请求地址:
http://capi.douyucdn.cn/api/v1/history?token=<token>
参数:
token:
返回数据:

{
"error": 0,
"data": [
{
"room_id": "73327",
"room_src": "http://rpic.douyucdn.cn/z1602/24/01/73327_160224015628.jpg",
"cate_id": "134",
"room_name": "返回Windows写个博客",
"show_status": "1",
"subject": "",
"show_time": "1456244441",
"owner_uid": "2154075",
"specific_catalog": "dotaonly",
"specific_status": "1",
"vod_quality": "0",
"nickname": "ShaneX",
"online": 4,
"child_id": "0",
"url": "/dotaonly",
"game_url": "/directory/game/wsm",
"game_name": "玩数码",
"rid": "73327",
"oid": "2154075",
"n": "返回Windows写个博客",
"lt": "1456246497",
"uc": "5",
"ls": "1",
"on": "ShaneX",
"fans": "2489"
}
]
}
1234567891011121314151617181920212223242526272829303132

写在最后

我写这个时候在直播,有个人跑我直播间说我抓这个毫无意义,那我就呵呵了。还有就是不得不感慨一下斗鱼程序猿写代码能力之弱,我翻代码时候甚至看到过这样的代码(time/1000/60)*60 前端js也是很乱。
额,如果有什么问题或者不明,欢迎留言,转载请注明。
我的直播间: 斗鱼 不定时会直播码code

 
 

一些斗鱼TV Web API [Some DouyuTv API]的更多相关文章

  1. ASP.NET Core Web API 开发-RESTful API实现

    ASP.NET Core Web API 开发-RESTful API实现 REST 介绍: 符合REST设计风格的Web API称为RESTful API. 具象状态传输(英文:Representa ...

  2. go web framework gin group api 设计

    假如让你来设计group api, 你该怎么设计呢? group api 和普通api的区别在于前缀不同,如果group api的版本为v1.0 那么相对应的url为/v1.0/xxx, 如果是普通a ...

  3. SharePoint 2013 APP 开发示例 (六)服务端跨域访问 Web Service (REST API)

    上个示例(SharePoint 2013 APP 开发示例 (五)跨域访问 Web Service (REST API))是基于JavaScript,运行在web browser内去访问REST AP ...

  4. SharePoint 2013 APP 开发示例 (五)跨域访问 Web Service (REST API)

          虽然 JQuery 也能通过授权header实现跨域, 但SharePoint 提供了更简单的方法,它被实现在SP.RequestExecutor里 .它能访问跨域的服务包括REST AP ...

  5. Selenium Web 自动化 - Selenium常用API

    Selenium Web 自动化 - Selenium常用API 2016-08-01 目录 1 对浏览器操作  1.1 用webdriver打开一个浏览器  1.2 最大化浏览器&关闭浏览器 ...

  6. [Node.js] 08 - Web Server and REST API

    有了 [Node.js] 07 - Html and Http 作为基础,再继续下面的内容. Node.js 路由 Node.js GET/POST请求 Node.js Web 模块 Node.js ...

  7. 创建基于OData的Web API - Knowledge Builder API, Part IV: Write Controller

    基于上一篇<创建基于OData的Web API - Knowledge Builder API, Part III:Write Model and Controller>,新创建的ODat ...

  8. HTML5之本地文件系统API - File System API

    HTML5之本地文件系统API - File System API 新的HTML5标准给我们带来了大量的新特性和惊喜,例如,画图的画布Canvas,多媒体的audio和video等等.除了上面我们提到 ...

  9. 谈谈微服务中的 API 网关(API Gateway)

    前言 又是很久没写博客了,最近一段时间换了新工作,比较忙,所以没有抽出来太多的时间写给关注我的粉丝写一些干货了,就有人问我怎么最近没有更新博客了,在这里给大家抱歉. 那么,在本篇文章中,我们就一起来探 ...

随机推荐

  1. python递归锁与信号量

    递归锁 一把大锁在加一把小锁. import threading import time def run1(): print("grab the first part data") ...

  2. spring security基于数据库表进行认证

    我们从研究org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl.class的源码开始 public class JdbcDaoI ...

  3. 专家来“搞”| IoT DevKit,物联网界新手大礼包等你来拿

    专家来“搞” 这是一档基于近期热门云技术,邀请 IT 和开发领域的资深专家,来给大家分享不同领域的云技术操作环境及开发过程中经常遇到的痛点和解决方案,与实战紧密相连,帮助大家学习知识点,顺利解决工作中 ...

  4. 再学UML-Bug管理系统UML2.0建模实例(三)

    3.系统设计 在对系统进行全面分析后,我们开始使用UML对系统进行设计,构造BMS系统的设计模型,包括类图.包图.顺序图(实现模型).组件图和部署图等的绘制,回答了“怎么做”的问题.具体设计工作如下: ...

  5. 保存Google、Bing翻译的语音

    以Chrome浏览器+google翻译为例,bing的下载步骤也类似 1.打开google翻译页面(translate.google.com),输入一段文本,如下图 2.可以看到,右侧已经翻译好了,这 ...

  6. 【UVA1309】Sudoku(DLX)

    点此看题面 大致题意: 让你填完整一个\(16*16\)的数独. 解题思路 我们知道,数独问题显然可以用\(DLX\)解决. 考虑对于一个数独,它要满足的要求为:每个位置都必须有数,每一行都必须有全部 ...

  7. 【luogu P3178 [HAOI2015]树上操作】 题解

    题目链接:https://www.luogu.org/problemnew/show/P3178 模板题 菜 #include <cstdio> #include <cstring& ...

  8. FileUpload框架实现文件上传(多个文件)和下载

    一.文件上传: 对于大文件执行下面的代码之间卡死 package com.example.web.service.servlet; import java.io.File; import java.i ...

  9. [译]GLUT教程 - 安装

    Lighthouse3d.com >> GLUT Tutorial >> Basics >> Setup 你需要什么 要用GLUT库开发程序,你可以下载最新版本3. ...

  10. JS JavaScript实现杨辉三角

    1       1 1      1 2 1    1 3 3 1   1 4 6 4 1 1 5 10 10 5 1 ........ 观察这样的一组数,找出规律,用控制台输出这样规律的数 规律:这 ...