123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- /*
- * @File : jianpian.js
- * @Author : jade
- * @Date : 2024/1/15 10:32
- * @Email : jadehh@1ive.com
- * @Software : Samples
- * @Desc : 完成荐片所有功能(添加弹幕)
- */
- import {Spider} from "./spider.js";
- import {_, load} from "../lib/cat.js";
- import {VodDetail, VodShort} from "../lib/vod.js";
- import * as Utils from "../lib/utils.js";
- class JianPianSpider extends Spider {
- constructor() {
- super();
- this.siteUrl = "http://api2.rinhome.com"
- // this.siteUrl = "https://ownjpykxttjzuhy.jiesiwa.com"
- }
- getName() {
- return "🌼┃荐片┃🌼"
- }
- getAppName() {
- return "荐片"
- }
- getJSName() {
- return "jianpian"
- }
- getType() {
- return 3
- }
- getHeader() {
- return {
- "User-Agent": "jianpian-android/360",
- "JPAUTH": "y261ow7kF2dtzlxh1GS9EB8nbTxNmaK/QQIAjctlKiEv",
- "Referer": "www.jianpianapp.com"
- }
- }
- async spiderInit(inReq=null) {
- if (inReq !== null){
- this.jsBase = await js2Proxy(inReq,"img",this.getHeader());
- }else{
- this.jsBase = await js2Proxy(true, this.siteType, this.siteKey, 'img/', this.getHeader());
- }
- }
- async init(cfg) {
- await super.init(cfg);
- this.danmuStaus = true
- await this.spiderInit(null)
- }
- async parseVodShortListFromJson(data_list) {
- let vod_list = [];
- for (const data of data_list) {
- let vodShort = new VodShort();
- vodShort.vod_id = data["id"]
- if (data["path"] !== undefined) {
- vodShort.vod_pic = this.jsBase + Utils.base64Encode(data["path"])
- } else {
- vodShort.vod_pic = this.jsBase + Utils.base64Encode(data["thumbnail"])
- }
- vodShort.vod_name = data["title"]
- if (data["mask"] !== undefined){
- vodShort.vod_remarks = data["mask"]
- }else{
- vodShort.vod_remarks = data["playlist"]["title"]
- }
- vod_list.push(vodShort)
- }
- return vod_list
- }
- objToList(list, key, split_value = "*") {
- let value_list = []
- for (const dic of list) {
- value_list.push(dic[key])
- }
- return value_list.join(split_value)
- }
- async parseVodDetailfromJson(obj) {
- let vodDetail = new VodDetail();
- vodDetail.vod_id = obj["id"]
- vodDetail.vod_year = obj["year"]["title"]
- if (!this.catOpenStatus) {
- vodDetail.vod_pic = obj["thumbnail"] + "@Referer=www.jianpianapp.com@User-Agent=jianpian-version353@JPAUTH=y261ow7kF2dtzlxh1GS9EB8nbTxNmaK/QQIAjctlKiEv"
- } else {
- vodDetail.vod_pic = this.jsBase + Utils.base64Encode(obj["thumbnail"])
- }
- vodDetail.type_name = obj["category"][0]["title"]
- vodDetail.vod_name = obj["title"]
- vodDetail.vod_content = obj["description"]
- vodDetail.vod_area = obj["area"]["title"]
- vodDetail.vod_director = this.objToList(obj["directors"], "name")
- vodDetail.vod_actor = this.objToList(obj["actors"], "name")
- vodDetail.vod_remarks = "评分:" + obj["score"]
- let playKeyList = [{"btbo_downlist": "btbo"}, {"xunlei_downlist": "迅雷"}, {"m3u8_downlist": "m3u8"}, {"new_ftp_list": "new_ftp"}, {"new_m3u8_list": "new_m3u8"}]
- let playlist = {}
- let urlList = []
- for (const dic of playKeyList) {
- let key = Object.keys(dic)[0]
- let value = Object.values(dic)[0]
- if (obj[key].length > 0) {
- let url_str_list = []
- for (const dic of obj[key]) {
- url_str_list.push(dic["title"] + "$" + dic["url"])
- }
- if (urlList.indexOf(url_str_list.join("#")) === -1) {
- urlList.push(url_str_list.join("#"))
- playlist[value] = url_str_list.join("#")
- } else {
- await this.jadeLog.warning(`key为:${key},播放链接重复,无需保存`)
- }
- }
- }
- vodDetail.vod_play_url = _.values(playlist).join('$$$');
- vodDetail.vod_play_from = _.keys(playlist).join('$$$');
- return vodDetail
- }
- async setClasses() {
- let type_name_list = ["全部", "电影", "电视剧", "动漫", "综艺"]
- let type_id_list = ["0", "1", "2", "3", "4"]
- for (let i = 0; i < type_name_list.length; i++) {
- let type_name = type_name_list[i]
- let type_id = type_id_list[i]
- this.classes.push({"type_name": type_name, "type_id": type_id})
- }
- }
- async setFilterObj() {
- this.filterObj = {
- "0": [{
- "key": "area", "name": "地區", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "国产", "v": "1"
- }, {
- "n": "中国香港", "v": "3"
- }, {
- "n": "中国台湾", "v": "6"
- }, {
- "n": "美国", "v": "5"
- }, {
- "n": "韩国", "v": "18"
- }, {
- "n": "日本", "v": "2"
- }]
- }, {
- "key": "year", "name": "年份", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "2024", "v": "119"
- }, {
- "n": "2023", "v": "153"
- }, {
- "n": "2022", "v": "101"
- }, {
- "n": "2021", "v": "118"
- }, {
- "n": "2020", "v": "16"
- }, {
- "n": "2019", "v": "7"
- }, {
- "n": "2018", "v": "2"
- }, {
- "n": "2017", "v": "3"
- }, {
- "n": "2016", "v": "22"
- }]
- }, {
- "key": "by", "name": "排序", "value": [{
- "n": "热门", "v": "hot"
- }, {
- "n": "更新", "v": "updata"
- }, {
- "n": "评分", "v": "rating"
- }]
- }], "1": [{
- "key": "area", "name": "地區", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "国产", "v": "1"
- }, {
- "n": "中国香港", "v": "3"
- }, {
- "n": "中国台湾", "v": "6"
- }, {
- "n": "美国", "v": "5"
- }, {
- "n": "韩国", "v": "18"
- }, {
- "n": "日本", "v": "2"
- }]
- }, {
- "key": "year", "name": "年份", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "2024", "v": "119"
- }, {
- "n": "2023", "v": "153"
- }, {
- "n": "2022", "v": "101"
- }, {
- "n": "2021", "v": "118"
- }, {
- "n": "2020", "v": "16"
- }, {
- "n": "2019", "v": "7"
- }, {
- "n": "2018", "v": "2"
- }, {
- "n": "2017", "v": "3"
- }, {
- "n": "2016", "v": "22"
- }]
- }, {
- "key": "by", "name": "排序", "value": [{
- "n": "热门", "v": "hot"
- }, {
- "n": "更新", "v": "updata"
- }, {
- "n": "评分", "v": "rating"
- }]
- }], "2": [{
- "key": "area", "name": "地區", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "国产", "v": "1"
- }, {
- "n": "中国香港", "v": "3"
- }, {
- "n": "中国台湾", "v": "6"
- }, {
- "n": "美国", "v": "5"
- }, {
- "n": "韩国", "v": "18"
- }, {
- "n": "日本", "v": "2"
- }]
- }, {
- "key": "year", "name": "年份", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "2024", "v": "119"
- }, {
- "n": "2023", "v": "153"
- }, {
- "n": "2022", "v": "101"
- }, {
- "n": "2021", "v": "118"
- }, {
- "n": "2020", "v": "16"
- }, {
- "n": "2019", "v": "7"
- }, {
- "n": "2018", "v": "2"
- }, {
- "n": "2017", "v": "3"
- }, {
- "n": "2016", "v": "22"
- }]
- }, {
- "key": "by", "name": "排序", "value": [{
- "n": "热门", "v": "hot"
- }, {
- "n": "更新", "v": "updata"
- }, {
- "n": "评分", "v": "rating"
- }]
- }], "3": [{
- "key": "area", "name": "地區", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "国产", "v": "1"
- }, {
- "n": "中国香港", "v": "3"
- }, {
- "n": "中国台湾", "v": "6"
- }, {
- "n": "美国", "v": "5"
- }, {
- "n": "韩国", "v": "18"
- }, {
- "n": "日本", "v": "2"
- }]
- }, {
- "key": "year", "name": "年份", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "2024", "v": "119"
- }, {
- "n": "2023", "v": "153"
- }, {
- "n": "2022", "v": "101"
- }, {
- "n": "2021", "v": "118"
- }, {
- "n": "2020", "v": "16"
- }, {
- "n": "2019", "v": "7"
- }, {
- "n": "2018", "v": "2"
- }, {
- "n": "2017", "v": "3"
- }, {
- "n": "2016", "v": "22"
- }]
- }, {
- "key": "by", "name": "排序", "value": [{
- "n": "热门", "v": "hot"
- }, {
- "n": "更新", "v": "updata"
- }, {
- "n": "评分", "v": "rating"
- }]
- }], "4": [{
- "key": "area", "name": "地區", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "国产", "v": "1"
- }, {
- "n": "中国香港", "v": "3"
- }, {
- "n": "中国台湾", "v": "6"
- }, {
- "n": "美国", "v": "5"
- }, {
- "n": "韩国", "v": "18"
- }, {
- "n": "日本", "v": "2"
- }]
- }, {
- "key": "year", "name": "年份", "value": [{
- "n": "全部", "v": "0"
- }, {
- "n": "2024", "v": "119"
- }, {
- "n": "2023", "v": "153"
- }, {
- "n": "2022", "v": "101"
- }, {
- "n": "2021", "v": "118"
- }, {
- "n": "2020", "v": "16"
- }, {
- "n": "2019", "v": "7"
- }, {
- "n": "2018", "v": "2"
- }, {
- "n": "2017", "v": "3"
- }, {
- "n": "2016", "v": "22"
- }]
- }, {
- "key": "by", "name": "排序", "value": [{
- "n": "热门", "v": "hot"
- }, {
- "n": "更新", "v": "updata"
- }, {
- "n": "评分", "v": "rating"
- }]
- }]
- }
- }
- async setHomeVod() {
- let content = await this.fetch(this.siteUrl + "/api/tag/hand?code=unknown601193cf375db73d&channel=wandoujia", null, this.getHeader())
- if (!_.isEmpty(content)) {
- let content_json = JSON.parse(content)
- let data_list = content_json["data"][0]["video"]
- this.homeVodList = await this.parseVodShortListFromJson(data_list)
- }
- }
- async setCategory(tid, pg, filter, extend) {
- let cateId = extend["cateId"] ?? tid
- let area = extend["area"] ?? "0";
- let year = extend["year"] ?? "0";
- let by = extend["by"] ?? "hot";
- this.limit = 24
- let categoryUrl = this.siteUrl + `/api/crumb/list?area=${area}&category_id=${cateId}&page=${pg}&type=0&limit=24&sort=${by}&year=${year}`
- await this.jadeLog.debug(`分类URL:${categoryUrl}`)
- let content = await this.fetch(categoryUrl, null, this.getHeader())
- if (!_.isEmpty(content)) {
- let content_json = JSON.parse(content)
- let data = content_json["data"]
- this.vodList = await this.parseVodShortListFromJson(data)
- }
- }
- async setDetail(id) {
- let url = this.siteUrl + "/api/node/detail?channel=wandoujia&token=&id=" + id;
- let content = await this.fetch(url, null, this.getHeader())
- if (!_.isEmpty(content)) {
- let content_json = JSON.parse(content);
- let data_list = content_json["data"]
- this.vodDetail = await this.parseVodDetailfromJson(data_list)
- }
- }
- async setSearch(wd, quick) {
- let url = this.siteUrl + "/api/video/search?page=1" + "&key=" + wd;
- const content = await this.fetch(url, null, this.getHeader());
- if (!_.isEmpty(content)) {
- let content_json = JSON.parse(content)
- let data_list = content_json["data"]
- this.vodList = await this.parseVodShortListFromJson(data_list)
- }
- }
- async setPlay(flag, id, flags) {
- await this.jadeLog.debug(`播放链接为:${id}`)
- this.playUrl = id
- }
- }
- let spider = new JianPianSpider()
- async function init(cfg) {
- await spider.init(cfg)
- }
- async function home(filter) {
- return await spider.home(filter)
- }
- async function homeVod() {
- return await spider.homeVod()
- }
- async function category(tid, pg, filter, extend) {
- return await spider.category(tid, pg, filter, extend)
- }
- async function detail(id) {
- return await spider.detail(id)
- }
- async function play(flag, id, flags) {
- return await spider.play(flag, id, flags)
- }
- async function search(wd, quick) {
- return await spider.search(wd, quick)
- }
- async function proxy(segments, headers) {
- return await spider.proxy(segments, headers)
- }
- export function __jsEvalReturn() {
- return {
- init: init,
- home: home,
- homeVod: homeVod,
- category: category,
- detail: detail,
- play: play,
- proxy: proxy,
- search: search,
- };
- }
- export {spider}
|