huya.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. /*
  2. * @File : huya.js
  3. * @Author : jade
  4. * @Date : 2024/3/7 9:13
  5. * @Email : jadehh@1ive.com
  6. * @Software : Samples
  7. * @Desc :
  8. */
  9. import {_, load} from '../lib/cat.js';
  10. import {VodDetail, VodShort} from "../lib/vod.js"
  11. import * as Utils from "../lib/utils.js";
  12. import {Spider} from "./spider.js";
  13. class HuyaSpider extends Spider {
  14. constructor() {
  15. super();
  16. this.isJustLive = false
  17. this.dataFrom = ""
  18. this.customArea = ""
  19. this.huYaPlayForamtObj = {"AL": "蓝光8M", "TX": "蓝光4M", "HW": "超清", "HS": "流畅"}
  20. this.livePlayForamtObj = {"HD": "蓝光8M", "LD": "蓝光4M", "SD": "超清", "OD": "流畅"}
  21. }
  22. getName() {
  23. return "🐯┃虎牙直播┃🐯"
  24. }
  25. getAppName() {
  26. return "虎牙直播"
  27. }
  28. getJSName() {
  29. return "huya"
  30. }
  31. getType() {
  32. return 3
  33. }
  34. async spiderInit() {
  35. if (this.cfgObj.hasOwnProperty('custom')) {
  36. this.customArea = this.cfgObj.custom;
  37. }
  38. if (this.cfgObj.hasOwnProperty('from')) {
  39. this.dataFrom = this.cfgObj.from;
  40. }
  41. if (this.dataFrom !== 'justlive') {
  42. this.siteUrl = 'https://www.huya.com';
  43. } else {
  44. this.siteUrl = 'http://live.yj1211.work';
  45. this.isJustLive = true;
  46. }
  47. }
  48. async init(cfg) {
  49. await super.init(cfg);
  50. await this.spiderInit()
  51. }
  52. getHeader() {
  53. let header = super.getHeader();
  54. header["User-Agent"] = Utils.MOBILEUA
  55. return header
  56. }
  57. async setClasses() {
  58. this.classes = [{
  59. "type_id": "1", "type_name": "网游"
  60. }, {"type_id": "2", "type_name": "单机"}, {"type_id": "3", "type_name": "手游"}, {
  61. "type_id": "8", "type_name": "娱乐"
  62. }]
  63. }
  64. async setFilterObj() {
  65. this.filterObj = {
  66. "1": [{
  67. "key": "cateId",
  68. "name": "分类",
  69. "init": "1",
  70. "value": [{"n": "英雄联盟", "v": "1"}, {"n": "CS2", "v": "862"}, {
  71. "n": "穿越火线", "v": "4"
  72. }, {"n": "lol云顶之弈", "v": "5485"}, {"n": "无畏契约", "v": "5937"}, {
  73. "n": "CFHD", "v": "6079"
  74. }, {"n": "逆战", "v": "135"}, {"n": "炉石传说", "v": "393"}, {"n": "DOTA2", "v": "7"}, {
  75. "n": "地下城与勇士", "v": "2"
  76. }, {"n": "魔兽世界", "v": "8"}, {"n": "坦克世界", "v": "802"}, {"n": "DOTA1", "v": "6"}, {
  77. "n": "梦三国", "v": "489"
  78. }, {"n": "魔兽争霸3", "v": "4615"}, {"n": "问道", "v": "107"}, {
  79. "n": "命运方舟", "v": "3058"
  80. }, {"n": "QQ飞车", "v": "9"}, {"n": "星际争霸", "v": "5"}, {
  81. "n": "网游竞技", "v": "100023"
  82. }, {"n": "射击综合游戏", "v": "100141"}, {"n": "暴雪专区", "v": "100043"}, {
  83. "n": "彩虹岛Online", "v": "683"
  84. }, {"n": "剑灵", "v": "897"}, {"n": "军事游戏", "v": "100133"}, {
  85. "n": "冒险岛", "v": "2243"
  86. }, {"n": "暗黑破坏神", "v": "1123"}, {"n": "诛仙3", "v": "1646"}, {
  87. "n": "热血江湖", "v": "387"
  88. }, {"n": "英魂之刃", "v": "1830"}, {"n": "武林外传一世琴缘", "v": "1661"}, {
  89. "n": "起凡:群雄逐鹿", "v": "1612"
  90. }, {"n": "神武4电脑版", "v": "3227"}, {"n": "龙之谷", "v": "15"}, {
  91. "n": "炉石战棋", "v": "5751"
  92. }, {"n": "御龙在天", "v": "675"}, {"n": "逆水寒", "v": "2952"}, {
  93. "n": "千年3", "v": "878"
  94. }, {"n": "永恒之塔", "v": "446"}, {"n": "体育游戏", "v": "100135"}, {
  95. "n": "寻仙", "v": "734"
  96. }, {"n": "战舰世界", "v": "1947"}, {"n": "QQ三国", "v": "1090"}, {
  97. "n": "流放之路", "v": "427"
  98. }, {"n": "反恐精英Online", "v": "1918"}, {"n": "反恐行动online", "v": "861"}, {
  99. "n": "征途", "v": "2715"
  100. }, {"n": "战争雷霆", "v": "624"}, {"n": "丝路传说2", "v": "1026"}, {
  101. "n": "星际战甲", "v": "627"
  102. }, {"n": "NBA2KOL系列", "v": "3959"}, {"n": "九阴真经", "v": "1009"}, {
  103. "n": "跑跑卡丁车", "v": "162"
  104. }, {"n": "诛仙世界", "v": "7749"}, {"n": "QQ华夏", "v": "1878"}, {
  105. "n": "天涯明月刀", "v": "1219"
  106. }, {"n": "大话西游:归来", "v": "8239"}, {"n": "荒野行动PC版", "v": "3185"}, {
  107. "n": "新剑侠情缘", "v": "586"
  108. }, {"n": "剑网3", "v": "900"}, {"n": "生死狙击2", "v": "6091"}, {
  109. "n": "全球使命", "v": "939"
  110. }, {"n": "梦想世界3", "v": "486"}, {"n": "枪神纪", "v": "496"}, {
  111. "n": "新天龙八部", "v": "5671"
  112. }, {"n": "铁甲雄兵", "v": "2765"}, {"n": "神泣", "v": "2531"}, {
  113. "n": "斗战神", "v": "591"
  114. }, {"n": "造梦西游OL", "v": "6815"}, {"n": "天堂", "v": "1966"}, {
  115. "n": "大话西游2", "v": "2975"
  116. }, {"n": "使命召唤:战区", "v": "5911"}, {"n": "希望OL", "v": "1161"}, {
  117. "n": "极光世界 弑神传", "v": "514"
  118. }, {"n": "守望先锋归来", "v": "2174"}, {"n": "QQ自由幻想", "v": "1862"}, {
  119. "n": "命运2", "v": "2942"
  120. }, {"n": "奇迹世界2", "v": "766"}, {"n": "坦克大战", "v": "4359"}, {
  121. "n": "生死狙击", "v": "2471"
  122. }, {"n": "天翼决", "v": "779"}, {"n": "QQ幻想", "v": "2419"}, {
  123. "n": "新飞飞(FlyFF)", "v": "1582"
  124. }, {"n": "刀剑英雄", "v": "915"}, {"n": "FIFA Online系列", "v": "100079"}, {
  125. "n": "全球使命3", "v": "2953"
  126. }, {"n": "完美端游系列", "v": "3034"}, {"n": "战意", "v": "2599"}, {
  127. "n": "泡泡堂", "v": "440"
  128. }, {"n": "赛尔号", "v": "2755"}, {"n": "大唐无双零", "v": "1584"}, {
  129. "n": "QQ炫舞", "v": "2440"
  130. }, {"n": "007:传奇", "v": "1135"}, {"n": "天下", "v": "1597"}, {
  131. "n": "天谕", "v": "1899"
  132. }, {"n": "新倩女幽魂", "v": "1579"}, {"n": "传世无双", "v": "984"}, {
  133. "n": "剑侠世界", "v": "903"
  134. }, {"n": "Warhaven", "v": "9053"}, {"n": "诺亚传说", "v": "190"}, {
  135. "n": "新挑战", "v": "583"
  136. }, {"n": "超激斗梦境", "v": "5691"}, {"n": "QQ音速", "v": "1085"}, {"n": "征途2", "v": "677"}, {
  137. "n": "征程", "v": "678"
  138. }, {"n": "蜀门", "v": "4711"}, {"n": "完美世界:诸神之战", "v": "7217"}, {
  139. "n": "战之刃:幸存者", "v": "8627"
  140. }, {"n": "黎明之光", "v": "41"}, {"n": "天命西游", "v": "1086"}, {
  141. "n": "炫舞时代", "v": "3353"
  142. }, {"n": "荣誉空间", "v": "225"}, {"n": "卡拉彼丘", "v": "9073"}, {
  143. "n": "成吉思汗怀旧版", "v": "640"
  144. }, {"n": "英雄年代3", "v": "1232"}, {"n": "天书奇谈", "v": "2225"}, {
  145. "n": "劲舞团", "v": "2420"
  146. }, {"n": "远征Online梦想版", "v": "142"}, {"n": "奇迹:传奇", "v": "3917"}, {
  147. "n": "封印者", "v": "2294"
  148. }, {"n": "上古世纪", "v": "1046"}, {"n": "梦幻诛仙2", "v": "488"}, {
  149. "n": "TERA Online", "v": "1072"
  150. }, {"n": "倚天Ⅱ", "v": "959"}, {"n": "街头篮球", "v": "206"}, {
  151. "n": "永恒轮回:无限", "v": "7847"
  152. }, {"n": "火线精英", "v": "2550"}, {"n": "忍者村大战2", "v": "2369"}, {
  153. "n": "领地人生", "v": "2282"
  154. }, {"n": "仙侠世界", "v": "995"}, {"n": "洛奇英雄传", "v": "432"}, {
  155. "n": "KARDS", "v": "8261"
  156. }, {"n": "无限法则", "v": "3189"}, {"n": "全面战争:竞技场", "v": "5901"}, {
  157. "n": "自由篮球", "v": "243"
  158. }, {"n": "FC Online4", "v": "3683"}, {"n": "战地之王", "v": "618"}, {
  159. "n": "古剑奇谭OL", "v": "1892"
  160. }, {"n": "QQ仙侠传", "v": "2291"}, {"n": "300英雄", "v": "1132"}]
  161. }], "2": [{
  162. "key": "cateId",
  163. "name": "分类",
  164. "init": "2793",
  165. "value": [{"n": "天天吃鸡", "v": "2793"}, {"n": "永劫无间", "v": "6219"}, {
  166. "n": "主机游戏", "v": "100032"
  167. }, {"n": "猛兽派对", "v": "6165"}, {"n": "互动点播", "v": "5907"}, {
  168. "n": "我的世界", "v": "1732"
  169. }, {"n": "方舟", "v": "1997"}, {"n": "单机热游", "v": "100002"}, {
  170. "n": "怀旧游戏", "v": "100125"
  171. }, {"n": "逃离塔科夫", "v": "3493"}, {"n": "俄罗斯钓鱼4", "v": "5495"}, {
  172. "n": "部落:上升", "v": "1318"
  173. }, {"n": "Dark and Darker", "v": "7905"}, {"n": "The Front", "v": "9497"}, {
  174. "n": "Apex英雄", "v": "5011"
  175. }, {"n": "生化危机4重制版", "v": "8013"}, {"n": "DayZ独立版", "v": "1125"}, {
  176. "n": "星空", "v": "7857"
  177. }, {"n": "互动剧游", "v": "6919"}, {"n": "艾尔登法环", "v": "5801"}, {
  178. "n": "恐惧之间", "v": "6679"
  179. }, {"n": "SCUM", "v": "4245"}, {"n": "Dread Hunger", "v": "7601"}, {
  180. "n": "塞尔达传说:王国之泪", "v": "7883"
  181. }, {"n": "欧洲卡车模拟", "v": "475"}, {"n": "洛克王国", "v": "2864"}, {
  182. "n": "卧龙:苍天陨落", "v": "7859"
  183. }, {"n": "无人深空", "v": "2566"}, {"n": "帝国神话", "v": "6821"}, {
  184. "n": "饥荒", "v": "74"
  185. }, {"n": "森林之子", "v": "7943"}, {"n": "星球大战系列", "v": "554"}, {
  186. "n": "极限竞速:地平线", "v": "2634"
  187. }, {"n": "最终幻想16", "v": "7869"}, {"n": "Among Us", "v": "6163"}, {
  188. "n": "怪物猎人:崛起", "v": "6479"
  189. }, {"n": "怪物猎人物语", "v": "7101"}, {"n": "骑马与砍杀系列", "v": "4783"}, {
  190. "n": "荒野大镖客2", "v": "4319"
  191. }, {"n": "太荒初境", "v": "7685"}, {"n": "罗布乐思", "v": "5771"}, {
  192. "n": "只狼:影逝二度", "v": "4505"
  193. }, {"n": "双人成行", "v": "6737"}, {"n": "重生边缘", "v": "6201"}, {
  194. "n": "海贼王 寻秘世界", "v": "5097"
  195. }, {"n": "战神:诸神黄昏", "v": "7771"}, {"n": "恐鬼症", "v": "6205"}, {
  196. "n": "鬼谷八荒", "v": "6571"
  197. }, {"n": "霍格沃茨之遗", "v": "7881"}, {"n": "全面战争", "v": "3521"}, {
  198. "n": "仁王2", "v": "5795"
  199. }, {"n": "奥拉星", "v": "2846"}, {"n": "甜蜜之家", "v": "6739"}, {
  200. "n": "仙剑奇侠传七", "v": "6509"
  201. }, {"n": "消逝的光芒2", "v": "7581"}, {"n": "渡神记", "v": "6231"}, {
  202. "n": "归家异途", "v": "2949"
  203. }, {"n": "博德之门3", "v": "6147"}, {"n": "看门狗:军团", "v": "6155"}, {
  204. "n": "使命召唤系列", "v": "100137"
  205. }, {"n": "育碧游戏", "v": "100139"}, {"n": "帝国时代4", "v": "4835"}, {
  206. "n": "英灵神殿", "v": "6609"
  207. }, {"n": "蛮荒志异:起源", "v": "9709"}, {"n": "岛", "v": "3019"}, {
  208. "n": "沙盒与副本", "v": "9151"
  209. }, {"n": "扫雷", "v": "2349"}, {"n": "街机游戏", "v": "5999"}, {
  210. "n": "幽灵线:东京", "v": "7669"
  211. }, {"n": "怪物猎人世界", "v": "3519"}, {"n": "盗贼之海", "v": "3641"}, {
  212. "n": "纸人", "v": "5257"
  213. }, {"n": "黑色像素人", "v": "28"}, {"n": "对马岛之魂", "v": "6039"}, {
  214. "n": "瑞奇与叮当", "v": "2455"
  215. }, {"n": "港诡实录", "v": "5853"}, {"n": "剑士", "v": "1467"}, {
  216. "n": "魔法门之英雄无敌系列", "v": "2096"
  217. }, {"n": "星露谷物语", "v": "2443"}, {"n": "仙剑奇侠传四", "v": "1659"}, {
  218. "n": "伤害世界", "v": "2337"
  219. }, {"n": "禁闭求生", "v": "6065"}, {"n": "真三国无双", "v": "1599"}, {
  220. "n": "恐怖黎明", "v": "3435"
  221. }, {"n": "其他单机", "v": "3069"}, {"n": "幽灵行动:荒野", "v": "2794"}, {
  222. "n": "边缘", "v": "151"
  223. }, {"n": "阿凡达", "v": "106"}, {"n": "全面战争:三国", "v": "3004"}, {
  224. "n": "黎明之星", "v": "40"
  225. }, {"n": "翼星求生", "v": "7463"}, {"n": "黎明传说", "v": "39"}, {
  226. "n": "恶魔之魂", "v": "6151"
  227. }, {"n": "艾兰岛", "v": "3855"}, {"n": "龙与地下城:秘影历代记HD", "v": "17"}, {
  228. "n": "龙与地下城:匕首谷", "v": "18"
  229. }, {"n": "沙石镇时光", "v": "7687"}, {"n": "三国志曹操传", "v": "2592"}, {
  230. "n": "FIFA足球", "v": "1888"
  231. }, {"n": "最终幻想7:重制版", "v": "5809"}, {"n": "四海兄弟", "v": "5995"}, {
  232. "n": "最终幻想:起源", "v": "7653"
  233. }, {"n": "摔跤城大乱斗", "v": "7773"}, {"n": "音乐游戏", "v": "2761"}, {
  234. "n": "精灵与萤火意志", "v": "5895"
  235. }, {"n": "桥梁建造师", "v": "3275"}, {"n": "哈迪斯", "v": "6153"}, {
  236. "n": "小缇娜的奇幻之地", "v": "7647"
  237. }, {"n": "宝可梦:剑盾", "v": "5715"}, {"n": "边境", "v": "4779"}, {
  238. "n": "人类一败涂地", "v": "3289"
  239. }, {"n": "糖豆人:终极淘汰赛", "v": "6083"}, {"n": "精灵宝可梦Let's Go", "v": "4375"}, {
  240. "n": "战锤40K:暗潮", "v": "3016"
  241. }, {"n": "石油骚动", "v": "2585"}, {"n": "紫塞秋风", "v": "6045"}, {
  242. "n": "阿尔比恩", "v": "8115"
  243. }, {"n": "猎人:荒野的召唤", "v": "2906"}, {"n": "FIFA 23", "v": "7789"}, {
  244. "n": "都市:天际线", "v": "2201"
  245. }, {"n": "乐高大电影:游戏版", "v": "1439"}, {"n": "全面战争:阿提拉", "v": "2383"}, {
  246. "n": "斩妖行", "v": "6105"
  247. }, {"n": "马里奥赛车8", "v": "5947"}, {"n": "复仇者联盟", "v": "6121"}, {"n": "霓虹深渊", "v": "5743"}]
  248. }], "3": [{
  249. "key": "cateId",
  250. "name": "分类",
  251. "init": "2336",
  252. "value": [{"n": "王者荣耀", "v": "2336"}, {"n": "和平精英", "v": "3203"}, {
  253. "n": "英雄联盟手游", "v": "6203"
  254. }, {"n": "CF手游", "v": "2413"}, {"n": "金铲铲之战", "v": "7185"}, {
  255. "n": "三国杀", "v": "1669"
  256. }, {"n": "原神", "v": "5489"}, {"n": "棋牌桌游", "v": "100036"}, {
  257. "n": "综合手游", "v": "100029"
  258. }, {"n": "劲乐幻想", "v": "7691"}, {"n": "新游广场", "v": "100052"}, {
  259. "n": "崩坏:星穹铁道", "v": "7349"
  260. }, {"n": "火影忍者手游", "v": "2429"}, {"n": "第五人格", "v": "3115"}, {
  261. "n": "问道手游", "v": "2477"
  262. }, {"n": "暗区突围", "v": "7209"}, {"n": "QQ飞车手游", "v": "2928"}, {
  263. "n": "球球大作战", "v": "2411"
  264. }, {"n": "明日之后", "v": "3483"}, {"n": "皇室战争", "v": "2439"}, {
  265. "n": "COD手游", "v": "4769"
  266. }, {"n": "手游休闲", "v": "100004"}, {"n": "二次元手游", "v": "100091"}, {
  267. "n": "摸了个鱼", "v": "9283"
  268. }, {"n": "MMORPG", "v": "100273"}, {"n": "动作游戏", "v": "100197"}, {
  269. "n": "战争冲突", "v": "7449"
  270. }, {"n": "王者模拟战", "v": "5699"}, {"n": "逆水寒手游", "v": "7725"}, {
  271. "n": "幻塔", "v": "6437"
  272. }, {"n": "欢乐斗地主", "v": "1749"}, {"n": "神武4手游", "v": "3135"}, {
  273. "n": "阴阳师", "v": "2598"
  274. }, {"n": "DNF手游", "v": "4921"}, {"n": "欢乐麻将", "v": "1751"}, {
  275. "n": "英雄联盟电竞经理", "v": "7177"
  276. }, {"n": "狼人杀手游", "v": "100049"}, {"n": "新天龙八部手游", "v": "6945"}, {
  277. "n": "中国象棋", "v": "1671"
  278. }, {"n": "天天象棋", "v": "4997"}, {"n": "传奇世界3D", "v": "3961"}, {
  279. "n": "御龙在天手游", "v": "2568"
  280. }, {"n": "高能英雄", "v": "8359"}, {"n": "天龙八部手游", "v": "2852"}, {
  281. "n": "三国志战略版", "v": "5619"
  282. }, {"n": "忍者必须死3", "v": "4041"}, {"n": "SKY光遇", "v": "3719"}, {
  283. "n": "虎牙领主争霸", "v": "7529"
  284. }, {"n": "云上城之歌", "v": "5977"}, {"n": "晶核", "v": "7279"}, {
  285. "n": "仙境传说RO", "v": "2675"
  286. }, {"n": "天天狼人", "v": "2774"}, {"n": "JJ棋牌", "v": "3841"}, {
  287. "n": "奇迹MU:觉醒", "v": "3116"
  288. }, {"n": "指尖四川麻将", "v": "7215"}, {"n": "部落冲突", "v": "1797"}, {
  289. "n": "新剑侠情缘手游", "v": "6259"
  290. }, {"n": "萌宠远征", "v": "9385"}, {"n": "暗黑破坏神:不朽", "v": "6385"}, {
  291. "n": "英雄杀", "v": "2688"
  292. }, {"n": "热血江湖手游", "v": "2817"}, {"n": "蛋仔派对", "v": "6909"}, {
  293. "n": "完美世界手游", "v": "4237"
  294. }, {"n": "巅峰战舰", "v": "2502"}, {"n": "狼人杀", "v": "2785"}, {
  295. "n": "斗罗大陆:魂师对决", "v": "6745"
  296. }, {"n": "武侠乂手游", "v": "4929"}, {"n": "诛仙手游", "v": "2647"}, {
  297. "n": "斗破苍穹手游", "v": "4337"
  298. }, {"n": "迷你世界", "v": "2683"}, {"n": "风云", "v": "3061"}, {
  299. "n": "妄想山海", "v": "6007"
  300. }, {"n": "曙光英雄", "v": "6169"}, {"n": "三国战纪2", "v": "6049"}, {
  301. "n": "梦幻新诛仙", "v": "5975"
  302. }, {"n": "黎明觉醒:生机", "v": "6131"}, {"n": "远征", "v": "7837"}, {
  303. "n": "航海王:燃烧意志", "v": "3943"
  304. }, {"n": "火炬之光:无限", "v": "6399"}, {"n": "巅峰极速", "v": "6979"}, {
  305. "n": "圣境之塔", "v": "7055"
  306. }, {"n": "魔力宝贝", "v": "2891"}, {"n": "香肠派对", "v": "3639"}, {
  307. "n": "创造与魔法", "v": "2931"
  308. }, {"n": "JJ斗地主", "v": "6271"}, {"n": "永恒纪元:戒", "v": "2646"}, {
  309. "n": "天涯明月刀手游", "v": "5115"
  310. }, {"n": "狼人杀官方", "v": "3679"}, {"n": "混沌起源", "v": "5985"}, {
  311. "n": "多多自走棋", "v": "5133"
  312. }, {"n": "梦幻诛仙手游", "v": "2672"}, {"n": "鸿图之下", "v": "6027"}, {
  313. "n": "新笑傲江湖", "v": "5669"
  314. }, {"n": "凡人修仙传:人界篇", "v": "8297"}, {"n": "多乐棋牌", "v": "6209"}, {
  315. "n": "口袋觉醒", "v": "5953"
  316. }, {"n": "跑跑卡丁车手游", "v": "2620"}, {"n": "奶块", "v": "2775"}, {
  317. "n": "月圆之夜", "v": "4339"
  318. }, {"n": "率土之滨", "v": "2691"}, {"n": "征途2手游", "v": "2811"}, {
  319. "n": "英魂之刃口袋版", "v": "2760"
  320. }, {"n": "精灵盛典:黎明", "v": "6123"}, {"n": "方舟手游", "v": "4035"}, {
  321. "n": "掼蛋", "v": "6225"
  322. }, {"n": "绝世仙王", "v": "6619"}, {"n": "流星群侠传", "v": "3927"}, {
  323. "n": "寻仙手游", "v": "2979"
  324. }, {"n": "一梦江湖", "v": "3082"}, {"n": "Lost Light(萤火突击国际服)", "v": "6859"}, {
  325. "n": "弹幕云游戏", "v": "7001"
  326. }, {"n": "猎魂觉醒", "v": "3071"}, {"n": "冒险岛:枫之传说", "v": "8005"}, {
  327. "n": "征途手游", "v": "2556"
  328. }, {"n": "海岛奇兵", "v": "2624"}, {"n": "倩女幽魂手游", "v": "2503"}, {
  329. "n": "超凡先锋", "v": "6507"
  330. }, {"n": "龙之谷2手游", "v": "2736"}, {"n": "崩坏3", "v": "2639"}, {
  331. "n": "猫和老鼠", "v": "2758"
  332. }, {"n": "七人传奇:光与暗之交战", "v": "8125"}, {"n": "JJ麻将", "v": "9487"}, {
  333. "n": "拉轰西游", "v": "9543"
  334. }, {"n": "三国战纪", "v": "6047"}, {"n": "自由幻想手游", "v": "4015"}, {
  335. "n": "秦时明月世界", "v": "5279"
  336. }, {"n": "新斗罗大陆", "v": "6657"}, {"n": "新神魔大陆", "v": "5939"}, {
  337. "n": "逃跑吧!少年", "v": "4137"
  338. }, {"n": "太古神王2", "v": "6649"}, {"n": "剑侠世界3", "v": "7183"}, {
  339. "n": "天天吃鸡手机版", "v": "4341"
  340. }, {"n": "时空猎人3", "v": "6411"}, {"n": "合金弹头:觉醒", "v": "6931"}, {
  341. "n": "明日方舟", "v": "4925"
  342. }, {"n": "原始征途", "v": "7713"}, {"n": "奇迹:最强者", "v": "3215"}, {
  343. "n": "天天酷跑", "v": "1715"
  344. }, {"n": "FC 足球世界", "v": "3873"}, {"n": "万国觉醒", "v": "6159"}, {
  345. "n": "机动都市阿尔法", "v": "5411"
  346. }, {"n": "航海王热血航线", "v": "6181"}, {"n": "幻世九歌", "v": "7199"}, {
  347. "n": "植物大战僵尸", "v": "485"
  348. }, {"n": "无悔华夏", "v": "7063"}, {"n": "时空猎人", "v": "1742"}, {
  349. "n": "荒野乱斗", "v": "4613"
  350. }, {"n": "拳皇98终极之战OL", "v": "2687"}, {"n": "蛇蛇争霸", "v": "2680"}, {
  351. "n": "王牌竞速", "v": "6463"
  352. }, {"n": "重返帝国", "v": "6955"}, {"n": "吞噬星空:黎明", "v": "6651"}, {
  353. "n": "口袋妖怪", "v": "2541"
  354. }, {"n": "QQ炫舞手游", "v": "2991"}, {"n": "一拳超人:最强之男", "v": "4629"}, {
  355. "n": "荣耀新三国", "v": "6943"
  356. }, {"n": "少年三国志2", "v": "6125"}, {"n": "我的起源", "v": "5365"}, {
  357. "n": "决战平安京", "v": "3064"
  358. }, {"n": "剑灵2", "v": "7223"}, {"n": "开心消消乐", "v": "1712"}, {
  359. "n": "小小蚁国", "v": "7803"
  360. }, {"n": "最强NBA", "v": "2988"}, {"n": "剑侠情缘手游", "v": "2621"}, {
  361. "n": "长安幻想", "v": "6727"
  362. }, {"n": "我叫MT4", "v": "4087"}, {"n": "全明星街球派对", "v": "8401"}, {
  363. "n": "大话西游手游", "v": "2626"
  364. }, {"n": "荣耀大天使", "v": "6477"}, {"n": "镇魂街:天生为王", "v": "6557"}, {
  365. "n": "摩尔庄园", "v": "5981"
  366. }, {"n": "游戏王:决斗链接", "v": "4451"}, {"n": "剑侠世界2手游", "v": "3150"}, {
  367. "n": "青云诀2", "v": "6009"
  368. }, {"n": "战地无疆", "v": "7909"}, {"n": "一念逍遥", "v": "6419"}, {
  369. "n": "永劫无间手游", "v": "7579"
  370. }, {"n": "尘白禁区", "v": "7297"}, {"n": "元梦之星", "v": "9521"}, {
  371. "n": "不良人3", "v": "5891"
  372. }, {"n": "剑灵:革命", "v": "4545"}, {"n": "魔力宝贝:旅人", "v": "7573"}, {
  373. "n": "米加小镇", "v": "7269"
  374. }, {"n": "龙武手游", "v": "5219"}, {"n": "斗罗大陆2:绝世唐门", "v": "6581"}, {
  375. "n": "西行纪燃魂", "v": "8303"
  376. }, {"n": "坦克世界闪击战", "v": "4977"}, {"n": "军棋", "v": "2561"}, {
  377. "n": "饥荒:新家", "v": "6491"
  378. }, {"n": "拳皇命运", "v": "3379"}, {"n": "实况足球", "v": "3741"}, {
  379. "n": "战舰世界闪击战", "v": "4101"
  380. }, {"n": "时空召唤", "v": "2551"}, {"n": "王牌战争:文明重启", "v": "5479"}, {
  381. "n": "雀魂麻将", "v": "7107"
  382. }, {"n": "欢乐升级", "v": "3925"}, {"n": "绿色征途", "v": "4227"}, {
  383. "n": "弹弹堂手游", "v": "2857"
  384. }, {"n": "太极熊猫3:猎龙", "v": "2778"}, {"n": "哈利波特:魔法觉醒", "v": "5835"}, {
  385. "n": "天地劫:幽城再临", "v": "5987"
  386. }, {"n": "热血街篮", "v": "5859"}, {"n": "神雕侠侣手游", "v": "1781"}, {
  387. "n": "山海镜花", "v": "5089"
  388. }, {"n": "三国志战棋版", "v": "7937"}, {"n": "神雕侠侣2", "v": "4209"}, {
  389. "n": "仙魔决", "v": "1674"
  390. }, {"n": "王者荣耀星之破晓", "v": "7927"}, {"n": "我在江湖之神魔道", "v": "7699"}, {
  391. "n": "梦幻模拟战", "v": "3481"
  392. }, {"n": "单机手游", "v": "2777"}, {"n": "斗罗大陆-斗神再临", "v": "6631"}, {
  393. "n": "未来之役", "v": "6831"
  394. }, {"n": "风云岛行动", "v": "4695"}, {"n": "新游推荐", "v": "3160"}, {
  395. "n": "火影忍者OL", "v": "3901"
  396. }, {"n": "九灵神域", "v": "7719"}, {"n": "武动乾坤", "v": "3829"}, {
  397. "n": "秦时明月2", "v": "1784"
  398. }, {"n": "文明与征服", "v": "7071"}, {"n": "战双:帕弥什", "v": "4133"}, {
  399. "n": "大航海时代:海上霸主", "v": "6929"
  400. }, {"n": "剑网1:归来", "v": "7361"}, {"n": "绝区零", "v": "7711"}, {
  401. "n": "黑色沙漠手游", "v": "7287"
  402. }, {"n": "虎牙吃鸡", "v": "7465"}, {"n": "一剑斩仙", "v": "6843"}, {
  403. "n": "传奇天下", "v": "6927"
  404. }, {"n": "斗斗堂", "v": "7133"}, {"n": "斗罗大陆", "v": "6119"}, {
  405. "n": "天谕手游", "v": "5925"
  406. }, {"n": "坎公骑冠剑", "v": "6641"}, {"n": "最终幻想觉醒", "v": "2721"}, {
  407. "n": "神将三国", "v": "6621"
  408. }, {"n": "灌篮高手正版授权手游", "v": "5399"}, {"n": "剑与家园", "v": "2838"}, {
  409. "n": "极无双2", "v": "7825"
  410. }, {"n": "光明大陆", "v": "2832"}, {"n": "荒野行动", "v": "3084"}, {
  411. "n": "战斗法则", "v": "9513"
  412. }, {"n": "疯狂原始人", "v": "4619"}, {"n": "逆战手游", "v": "7575"}, {
  413. "n": "石器时代:觉醒", "v": "9159"
  414. }]
  415. }], "8": [{
  416. "key": "cateId",
  417. "name": "分类",
  418. "init": "1663",
  419. "value": [{"n": "星秀", "v": "1663"}, {"n": "户外", "v": "2165"}, {
  420. "n": "一起看", "v": "2135"
  421. }, {"n": "二次元", "v": "2633"}, {"n": "虚拟偶像", "v": "6055"}, {"n": "旅游", "v": "6791"}, {
  422. "n": "放映厅", "v": "6245"
  423. }, {"n": "娱乐天地", "v": "100022"}, {"n": "交友", "v": "4079"}, {
  424. "n": "组队", "v": "5367"
  425. }, {"n": "吃喝玩乐", "v": "100044"}, {"n": "原创", "v": "6861"}, {
  426. "n": "虎牙文化", "v": "4089"
  427. }, {"n": "体育", "v": "2356"}, {"n": "虎牙地方", "v": "5123"}, {"n": "颜值", "v": "2168"}, {
  428. "n": "科技", "v": "2408"
  429. }, {"n": "音乐", "v": "3793"}, {"n": "趣分享", "v": "5883"}, {"n": "一起买", "v": "7759"}, {
  430. "n": "派对", "v": "7785"
  431. }]
  432. }],
  433. };
  434. if (this.customArea.length > 0) {
  435. const filterCfg = this.customArea.split('#');
  436. this.classes.unshift({"type_id": "custom", "type_name": "自选"});
  437. const filterList = _.map(filterCfg, (it) => {
  438. const filterKv = it.split(',');
  439. return {
  440. n: filterKv[1], v: filterKv[0],
  441. };
  442. });
  443. const defKey = filterList[0];
  444. this.filterObj["custom"] = [{"key": "cateId", "name": "分类", "init": defKey.v, "value": filterList}];
  445. }
  446. if (this.isJustLive) {
  447. // key-value映射修改
  448. const filterKeys = Object.keys(this.filterObj);
  449. for (const filterKey of filterKeys) {
  450. const filterItem = this.filterObj[filterKey];
  451. for (const typeItem of filterItem) {
  452. typeItem.value = _.map(typeItem.value, (it) => {
  453. // 修改默认值
  454. if (it.v === typeItem.init) {
  455. typeItem.init = it.n;
  456. }
  457. return {
  458. n: it.n, v: it.n,
  459. };
  460. });
  461. }
  462. }
  463. }
  464. this.classes.unshift({"type_id": "home", "type_name": "首页"});
  465. }
  466. async setHome(filter) {
  467. await this.setClasses()
  468. await this.setFilterObj()
  469. }
  470. async parseVodShortListFromJson(obj) {
  471. let vod_list = []
  472. if (this.isJustLive) {
  473. for (const it of obj["data"]) {
  474. let vodShort = new VodShort()
  475. vodShort.vod_id = it["roomId"]
  476. vodShort.vod_name = it["ownerName"] + it["roomName"]
  477. vodShort.vod_pic = it["roomPic"]
  478. vodShort.vod_remarks = it["categoryName"]
  479. vod_list.push(vodShort)
  480. }
  481. } else {
  482. for (const it of obj.data.datas) {
  483. let vodShort = new VodShort()
  484. vodShort.vod_id = it["profileRoom"]
  485. vodShort.vod_name = it["nick"] + it["introduction"]
  486. vodShort.vod_pic = it["screenshot"]
  487. vodShort.vod_remarks = it["gameFullName"]
  488. vod_list.push(vodShort)
  489. }
  490. }
  491. return vod_list
  492. }
  493. getPlayUrlData(streamInfo, ratio) {
  494. const hlsUrl = streamInfo["sHlsUrl"] + '/' + streamInfo["sStreamName"] + '.' + streamInfo["sHlsUrlSuffix"];
  495. const srcAntiCode = unescape(streamInfo["sHlsAntiCode"]);
  496. let codeList = srcAntiCode.split('&');
  497. codeList = codeList.filter(code => code !== '');
  498. let cryptoInfo = {};
  499. for (const code of codeList) {
  500. const [k, v] = code.split('=');
  501. cryptoInfo[k] = v;
  502. }
  503. const fm = Utils.unquote(cryptoInfo["fm"]);
  504. const fmDecoded = Utils.base64Decode(fm);
  505. const hashPrefix = fmDecoded.split('_')[0];
  506. const ctype = cryptoInfo["ctype"] || '';
  507. const txyp = cryptoInfo["txyp"] || '';
  508. const fs = cryptoInfo.fs || '';
  509. const t = cryptoInfo.t || '';
  510. const u = 1463993859134;
  511. const curTime = Date.now();
  512. const seqid = Math.floor(curTime + u);
  513. const wsTime = (Math.floor(curTime / 1e3) + 3600).toString(16);
  514. const v0 = seqid + '|' + ctype + '|' + t;
  515. const v1 = Utils.md5Encode(v0);
  516. const v2 = hashPrefix + '_' + u + '_' + streamInfo["sStreamName"] + '_' + v1 + '_' + wsTime;
  517. const hash = Utils.md5Encode(v2);
  518. // ratio = ""
  519. const purl = `${hlsUrl}?wsSecret=${hash}&wsTime=${wsTime}&seqid=${seqid}&ctype=${ctype}&ver=1&txyp=${txyp}&fs=${fs}&ratio=${ratio}&u=${u}&t=${t}&sv=2107230339`;
  520. return {
  521. cdnType: streamInfo["sCdnType"], playUrl: purl,
  522. };
  523. }
  524. async parseVodDetailfromJson(liveInfo, streamInfoList, bitInfoList) {
  525. let vodDetail = new VodDetail()
  526. vodDetail.vod_name = liveInfo["introduction"] ?? liveInfo["sIntroduction"]
  527. vodDetail.vod_pic = liveInfo["screenshot"] ?? liveInfo["sScreenshot"]
  528. vodDetail.vod_remarks = liveInfo["gameFullName"] ?? liveInfo["sGameFullName"]
  529. vodDetail.type_name = liveInfo["gameFullName"] ?? liveInfo["sGameFullName"]
  530. vodDetail.vod_director = liveInfo["nick"] ?? liveInfo["sNick"]
  531. vodDetail.vod_content = liveInfo["activityCount"] ?? liveInfo["lActivityCount"]
  532. vodDetail.vod_content = vodDetail.vod_content + '人在线'
  533. let vod_play_from_list = []
  534. let vod_play_list = []
  535. for (const streamInfo of streamInfoList) {
  536. let vodItems = []
  537. for (const bitinfo of bitInfoList) {
  538. let format_name = this.huYaPlayForamtObj[streamInfo["sCdnType"]]
  539. if (format_name === bitinfo["sDisplayName"]) {
  540. const urlData = this.getPlayUrlData(streamInfo, bitinfo["iBitRate"]);
  541. vod_play_from_list.push(format_name)
  542. vodItems.push("虎牙直播" + '$' + urlData["playUrl"])
  543. vod_play_list.push(vodItems.join("#"))
  544. break
  545. }
  546. }
  547. }
  548. vodDetail.vod_play_from = vod_play_from_list.join("$$$")
  549. vodDetail.vod_play_url = vod_play_list.join("$$$")
  550. return vodDetail
  551. }
  552. async parseVodDetailFromDoc(vodData, playData) {
  553. let vodDetail = new VodDetail()
  554. vodDetail.vod_name = vodData["data"]["roomName"]
  555. vodDetail.vod_director = vodData["data"]["ownerName"]
  556. vodDetail.vod_pic = vodData["data"]["roomPic"]
  557. vodDetail.vod_remarks = vodData["data"]["categoryName"]
  558. vodDetail.vod_content = vodData["data"]["online"] + "人在线"
  559. let vod_play_from_list = []
  560. let vod_play_list = []
  561. for (const key of Object.keys(this.livePlayForamtObj)) {
  562. let vodItems = []
  563. if (playData.data.hasOwnProperty(key)) {
  564. vod_play_from_list.push(this.livePlayForamtObj[key])
  565. vodItems.push("JustLive" + '$' + playData["data"][key])
  566. vod_play_list.push(vodItems.join("#"))
  567. }
  568. }
  569. vodDetail.vod_play_from = vod_play_from_list.join("$$$")
  570. vodDetail.vod_play_url = vod_play_list.join("$$$")
  571. return vodDetail
  572. }
  573. async parseVodShortListFromDocBySearch(data) {
  574. let vod_list = [];
  575. for (const vod of data.response['3']["docs"]) {
  576. let vodShort = new VodShort()
  577. vodShort.vod_id = vod["room_id"]
  578. vodShort.vod_name = vod["game_nick"] + vod["game_introduction"]
  579. vodShort.vod_pic = vod["game_screenshot"]
  580. vodShort.vod_remarks = vod["game_name"]
  581. vod_list.push(vodShort)
  582. }
  583. return vod_list
  584. }
  585. async setCategory(tid, pg, filter, extend) {
  586. if (pg <= 0 || typeof pg == 'undefined') pg = 1;
  587. let url = '';
  588. let data = {}
  589. if (this.isJustLive) {
  590. if (tid === 'home') {
  591. url = this.siteUrl + '/api/live/getRecommendByPlatform?platform=huya&size=20&page=' + pg;
  592. } else {
  593. url = this.siteUrl + '/api/live/getRecommendByPlatformArea?platform=huya&size=20&area=' + extend.cateId + '&page=' + pg;
  594. }
  595. data = JSON.parse(await this.fetch(url, null, this.getHeader()));
  596. } else {
  597. if (tid === 'home') {
  598. url = this.siteUrl + '/cache.php?m=LiveList&do=getLiveListByPage&tagAll=1&page=' + pg;
  599. } else {
  600. url = this.siteUrl + '/cache.php?m=LiveList&do=getLiveListByPage&gameId=' + extend["cateId"] + '&tagAll=0&page=' + pg;
  601. }
  602. data = JSON.parse(await this.fetch(url, null, this.getHeader()));
  603. }
  604. this.vodList = await this.parseVodShortListFromJson(data)
  605. }
  606. async setDetail(id) {
  607. let liveInfo = null;
  608. let streamInfoList = null;
  609. if (this.isJustLive) {
  610. await this.jadeLog.debug("JustLive", true)
  611. const vodInfo = await this.fetch(this.siteUrl + `/api/live/getRoomInfo?platform=huya&roomId=${id}`, null, this.getHeader())
  612. const playInfo = await this.fetch(this.siteUrl + `/api/live/getRealUrl?platform=huya&roomId=${id}`, null, this.getHeader())
  613. const vodData = JSON.parse(vodInfo);
  614. const playData = JSON.parse(playInfo)
  615. this.vodDetail = await this.parseVodDetailFromDoc(vodData, playData)
  616. } else {
  617. await this.jadeLog.debug("虎牙直播", true)
  618. const resp = await this.fetch('https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=' + id, null, this.getHeader());
  619. const data = JSON.parse(resp);
  620. liveInfo = data.data["liveData"];
  621. let bitInfo = JSON.parse(liveInfo["bitRateInfo"])
  622. streamInfoList = data.data.stream["baseSteamInfoList"];
  623. this.vodDetail = await this.parseVodDetailfromJson(liveInfo, streamInfoList, bitInfo)
  624. }
  625. /** 网页链接
  626. *
  627. * await this.jadeLog.debug("虎牙直播",true)
  628. * const headers = {
  629. * 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': Utils.MOBILEUA,
  630. * };
  631. * let content = await this.fetch('https://m.huya.com/' + id, null, headers);
  632. * let liveData = JSON.parse(Utils.getStrByRegex(/<script> window.HNF_GLOBAL_INIT = (.*?)<\/script>/, content))
  633. * const vodData = liveData["roomInfo"];
  634. * liveInfo = vodData["tLiveInfo"];
  635. * streamInfoList = vodData["tLiveInfo"]["tLiveStreamInfo"]["vStreamInfo"]["value"]
  636. * let bitInfoList = vodData["tLiveInfo"]["tLiveStreamInfo"]["vBitRateInfo"]["value"]
  637. * this.vodDetail = await this.parseVodDetailfromJson(liveInfo, streamInfoList, bitInfoList)
  638. * */
  639. }
  640. async setSearch(wd, quick) {
  641. const resp = await this.fetch('https://search.cdn.huya.com/?m=Search&do=getSearchContent&q=' + wd + '&uid=0&v=4&typ=-5&livestate=0&rows=40&start=0', null, this.getHeader());
  642. const data = JSON.parse(resp);
  643. this.vodList = await this.parseVodShortListFromDocBySearch(data)
  644. }
  645. }
  646. let spider = new HuyaSpider()
  647. async function init(cfg) {
  648. await spider.init(cfg)
  649. }
  650. async function home(filter) {
  651. return await spider.home(filter)
  652. }
  653. async function homeVod() {
  654. return await spider.homeVod()
  655. }
  656. async function category(tid, pg, filter, extend) {
  657. return await spider.category(tid, pg, filter, extend)
  658. }
  659. async function detail(id) {
  660. return await spider.detail(id)
  661. }
  662. async function play(flag, id, flags) {
  663. return await spider.play(flag, id, flags)
  664. }
  665. async function search(wd, quick) {
  666. return await spider.search(wd, quick)
  667. }
  668. export function __jsEvalReturn() {
  669. return {
  670. init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search,
  671. };
  672. }
  673. export {spider}