douban_open.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import {
  2. Crypto, load, _
  3. }
  4. from 'assets://js/lib/cat.js';
  5. let key = '豆瓣电影';
  6. let HOST = 'https://www.6080yy4.com';
  7. let siteKey = '';
  8. let siteType = 0;
  9. const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
  10. async function request(reqUrl, agentSp) {
  11. let res = await req(reqUrl, {
  12. method: 'get',
  13. headers: {
  14. 'User-Agent': agentSp || UA,
  15. 'Referer': HOST
  16. },
  17. });
  18. return res.content;
  19. }
  20. // cfg = {skey: siteKey, ext: extend}
  21. async function init(cfg) {
  22. siteKey = cfg.skey;
  23. siteType = cfg.stype;
  24. }
  25. async function home(filter) {
  26. let classes = [{
  27. 'type_id': '/cinema/nowplaying/@nowplaying',
  28. 'type_name': '正在热映'
  29. }, {
  30. 'type_id': '/cinema/nowplaying/@upcoming',
  31. 'type_name': '即将上映'
  32. }, {
  33. 'type_id': '@movie',
  34. 'type_name': '热门电影'
  35. }, {
  36. 'type_id': '@tv',
  37. 'type_name': '热门电视剧'
  38. }];
  39. let filterObj = {};
  40. return JSON.stringify({
  41. class: classes,
  42. filters: filterObj,
  43. });
  44. }
  45. async function homeVod() {}
  46. async function category(tid, pg, filter, extend) {
  47. let flag = tid.split('@')[1];
  48. const link = "https://movie.douban.com" + tid.split('@')[0];
  49. const html = await request(link);
  50. const $ = load(html);
  51. let items,$item,videos;
  52. switch(flag){
  53. case 'nowplaying':
  54. items = $('div#nowplaying > div > ul > li');
  55. videos = _.map(items, (item) => {
  56. $item = $(item);
  57. return {
  58. vod_id: $item.find('ul > li.stitle > a').attr('href'),
  59. vod_name: $item.find('ul > li.stitle > a').attr('title'),
  60. vod_pic: $item.find('ul > li.poster > a > img').attr('src'),
  61. vod_remarks: $item.find('ul > li.srating > span.subject-rate').text() || $item.find('ul > li.srating > span.text-tip').text(),
  62. };
  63. });
  64. break;
  65. case 'upcoming':
  66. items = $('div#upcoming > div > ul > li');
  67. videos = _.map(items, (item) => {
  68. $item = $(item);
  69. return {
  70. vod_id: $item.find('ul > li.stitle > a').attr('href'),
  71. vod_name: $item.find('ul > li.stitle > a').attr('title'),
  72. vod_pic: $item.find('ul > li.poster > a > img').attr('src'),
  73. vod_remarks: $item.find('ul > li.srating > span.release-date').text(),
  74. };
  75. });
  76. break;
  77. default:
  78. let url = 'https://movie.douban.com/j/search_subjects?type=' + flag + '&tag=%E7%83%AD%E9%97%A8&page_limit=50&page_start=0';
  79. let subjects = JSON.parse(await request(url)).subjects;
  80. videos = _.map(subjects, (subject) => {
  81. return {
  82. vod_id: subject.url,
  83. vod_name: subject.title,
  84. vod_pic: subject.cover,
  85. vod_remarks: subject.rate,
  86. };
  87. });
  88. }
  89. return JSON.stringify({
  90. page: parseInt(pg),
  91. pagecount: 0,
  92. limit: 0,
  93. total: 0,
  94. list: videos,
  95. });
  96. }
  97. async function detail(id) {
  98. let html = await request(id);
  99. let $ = load(html);
  100. let json = $("script[type='application/ld+json']").text();
  101. let v = JSON.parse(json.replaceAll('@',''));
  102. let directors = [];
  103. _.map(v.director, (director) => {
  104. directors.push(director.name.split(' ')[0]);
  105. });
  106. const director = directors.join('/');
  107. let actors = [];
  108. _.map(v.actor, (actor) => {
  109. actors.push(actor.name.split(' ')[0]);
  110. });
  111. const actor = actors.join('/');
  112. const vod = {
  113. vod_id: id,
  114. vod_name: v.name,
  115. vod_pic: v.image,
  116. vod_remarks: '',
  117. vod_director: director,
  118. vod_actor: actor,
  119. vod_year: v.datePublished,
  120. vod_content: '[关注公众号:影视资源站] ' + v.description,
  121. };
  122. console.debug(vod);
  123. let trailer = $("a.related-pic-video").attr("href").replace('#content','');
  124. if(trailer.length === 0){
  125. vod.vod_play_from = '暂无预告片';
  126. vod.vod_play_url = '无预告片$https://boot-video.xuexi.cn/video/1006/p/423728851d9dd3838079f59c0d994ddc-ffd3ac9ba2a349848733c6f31bb0802c-2.mp4';
  127. }else{
  128. const playMap = {};
  129. html = await request(trailer);
  130. $ = load(html);
  131. const playlists = $('ul.video-list-col > li');
  132. playMap['预告片'] = [];
  133. _.each(playlists, (playlist) => {
  134. const $playlist = $(playlist);
  135. const title = $playlist.find('a.pr-video > strong').text();
  136. const playUrl = $playlist.find('a.pr-video').attr('href');
  137. playMap['预告片'].push(title + '$' + playUrl.replace('#content',''));
  138. });
  139. vod.vod_play_from = _.keys(playMap).join('$$$');
  140. const urls = _.values(playMap);
  141. const vod_play_url = _.map(urls, (urlist) => {
  142. return urlist.join('#');
  143. });
  144. vod.vod_play_url = vod_play_url.join('$$$');
  145. }
  146. return JSON.stringify({
  147. list: [vod],
  148. });
  149. }
  150. async function play(flag, id, flags) {
  151. let playUrl;
  152. if(id.endsWith('.mp4')){
  153. playUrl = id;
  154. }else{
  155. const html = await request(id);
  156. const $ = load(html);
  157. let json = $("script[type='application/ld+json']").text();
  158. let v = JSON.parse(json.replaceAll('@',''));
  159. playUrl = v.embedUrl;
  160. }
  161. return JSON.stringify({
  162. parse: 0,
  163. url: playUrl,
  164. header: {
  165. 'User-Agent': UA,
  166. },
  167. });
  168. }
  169. export function __jsEvalReturn() {
  170. return {
  171. init: init,
  172. home: home,
  173. homeVod: homeVod,
  174. category: category,
  175. detail: detail,
  176. play: play,
  177. };
  178. }