histar.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. const histar = {
  2. empty: 'hiker://empty',
  3. url: 'https://www.histar.tv/',
  4. d: [],
  5. categoryColor: '#1cb96f',
  6. params: {
  7. category: getMyVar('Histar.tg.category', 'movie'),
  8. type: getMyVar('Histar.tg.type', 'movie'),
  9. nextCate: getMyVar('Histar.tg.nextCate', 'all/all/all'),
  10. },
  11. data: {
  12. type: [
  13. {title: '电影', key: 'movie', type: 'movie', homepage: 'https://www.histar.tv/movie/'},
  14. {title: '电视剧', key: 'drama', type: 'movie', homepage: 'https://www.histar.tv/drama/'},
  15. {title: '综艺', key: 'variety', type: 'movie', homepage: 'https://www.histar.tv/variety/'},
  16. {title: '纪录片', key: 'documentary', type: 'movie', homepage: 'https://www.histar.tv/documentary/'},
  17. {title: '动漫', key: 'animation', type: 'movie', homepage: 'https://www.histar.tv/animation/'},
  18. {title: '电视直播', key: 'live', type: 'live', homepage: 'https://www.histar.tv/live'},
  19. ],
  20. },
  21. baseParse: () => {
  22. const page = MY_URL.split('##')[1]
  23. if (page === '1') {
  24. histar.data.type.forEach((item) => {
  25. histar.d.push({
  26. title: histar.params.category === item.key ? '‘‘’’<strong><font color="'+histar.categoryColor+'">'+item.title+'</font></strong>' : item.title,
  27. url: $(histar.empty).lazyRule((item) => {
  28. putMyVar("Histar.tg.category", item.key)
  29. putMyVar("Histar.tg.type", item.type)
  30. putMyVar("Histar.tg.nextCate", 'all/all/all')
  31. refreshPage(true)
  32. return "hiker://empty"
  33. }, item),
  34. col_type: 'scroll_button',
  35. })
  36. })
  37. histar.d.push({
  38. col_type: 'blank_block',
  39. })
  40. }
  41. if (histar.params.type === 'movie') {
  42. histar.movieTypeCateParse(page)
  43. } else if (histar.params.type === 'live') {
  44. histar.liveTypeCateParse(page)
  45. }
  46. setResult(histar.d)
  47. },
  48. movieTypeCateParse: (page) => {
  49. const classname = '._tag__filterItem__vBNf8'
  50. const typeItem = histar.data.type.find((item) => item.key === histar.params.category)
  51. if (typeItem) {
  52. const url = typeItem.homepage+histar.params.nextCate
  53. const html = fetch(url)
  54. if (page === '1') {
  55. const list = pdfa(html, 'body&&'+classname)
  56. list.forEach((item, index) => {
  57. const nextList = pdfa(item, classname+'&&a')
  58. nextList.forEach((nextItem) => {
  59. const title = pdfh(nextItem, 'a&&Text')
  60. const href = pdfh(nextItem, 'a&&href')
  61. const cate = href.replace('/'+typeItem.key+'/', '')
  62. histar.d.push({
  63. title: histar.params.nextCate === cate ? '‘‘’’<strong><font color="'+histar.categoryColor+'">'+title+'</font></strong>' : title,
  64. url: $(histar.empty).lazyRule((cate) => {
  65. putMyVar("Histar.tg.nextCate", cate)
  66. refreshPage(true)
  67. return "hiker://empty"
  68. }, cate),
  69. col_type: 'scroll_button',
  70. })
  71. })
  72. histar.d.push({
  73. col_type: 'blank_block',
  74. })
  75. })
  76. }
  77. try {
  78. const script = html.match(/<script id="__NEXT_DATA__" type="application\/json">(.*?)<\/script>/)[1]
  79. const siteJson = JSON.parse(script)
  80. const nextCateArray = histar.params.nextCate.split('/')
  81. const filterCondition = siteJson.props.pageProps.filterCondition
  82. const labelItem = nextCateArray[1] === 'all' ? '' : filterCondition.label.find((label) => label[1] === nextCateArray[1])
  83. const countryItem = nextCateArray[2] === 'all' ? '' : filterCondition.country.find((label) => label === nextCateArray[2])
  84. const params = {
  85. page: Number(page),
  86. pageSize: 18,
  87. chName: typeItem.title,
  88. }
  89. if (labelItem) params.label = labelItem[0]
  90. if (countryItem) params.country = countryItem
  91. const resJson = fetch('https://aws.ulivetv.net/v3/web/api/filter', {
  92. body: params,
  93. method: 'POST',
  94. headers:{
  95. 'content-type': 'application/json',
  96. 'appid': '6fd0866dffd24341c680ed4a5417bdca',
  97. 'user-agent': PC_UA,
  98. 'origin': histar.url,
  99. 'referer': histar.url,
  100. }
  101. })
  102. const movieList = JSON.parse(resJson).data.list
  103. movieList.forEach((item) => {
  104. histar.d.push({
  105. title: item.name,
  106. img: item.img,
  107. url: $(histar.url+'vod/detail/'+item.id+'#immersiveTheme#').rule(() => {
  108. const histar = $.require('hiker://page/histar')
  109. histar.movieDetailParse()
  110. setResult(histar.d)
  111. }),
  112. col_type: 'movie_3_marquee',
  113. })
  114. })
  115. } catch (e) {
  116. log('数据格式错误')
  117. }
  118. }
  119. },
  120. liveTypeCateParse: () => {
  121. },
  122. movieDetailParse: () => {
  123. const html = getResCode()
  124. const section = pdfa(html, 'body&&section')[0]
  125. histar.d.push({
  126. title: pdfa(section, 'section&&.textEllipsis').map(item => pdfh(item, '.textEllipsis&&Text')).join('\n'),
  127. desc: pdfh(section, '.detail_desc__NWoOa&&Text'),
  128. url: MY_URL,
  129. pic_url: pdfh(section, 'img&&src'),
  130. col_type: 'movie_1_vertical_pic_blur',
  131. })
  132. histar.d.push({
  133. col_type: 'big_blank_block'
  134. })
  135. const list = pdfa(html, '.detail_selections__gpJG5&&a')
  136. if (list.length > 0) {
  137. histar.d.push({
  138. title: '选集',
  139. url: "hiker://empty",
  140. col_type: 'text_center_1',
  141. })
  142. list.forEach((item) => {
  143. histar.d.push({
  144. title: pdfh(item, 'a&&Text'),
  145. url: $(pd(item, 'a&&href')).lazyRule(() => {
  146. const histar = $.require('hiker://page/histar')
  147. return histar.videoParse(input)
  148. }),
  149. col_type: 'text_3',
  150. })
  151. })
  152. } else {
  153. histar.d.push({
  154. title: '播放',
  155. url: $(pd(html, '.detail_play__qgcEQ&&href')).lazyRule(() => {
  156. const histar = $.require('hiker://page/histar')
  157. return histar.videoParse(input)
  158. }),
  159. col_type: 'text_center_1',
  160. })
  161. }
  162. },
  163. videoParse: (url) => {
  164. const html = fetch(url)
  165. const script = html.match(/<script id="__NEXT_DATA__" type="application\/json">(.*?)<\/script>/)[1]
  166. const siteJson = JSON.parse(script)
  167. return siteJson.props.pageProps.playUrl
  168. },
  169. }
  170. $.exports = histar