Skip to content

Commit

Permalink
feat: DUB 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Greatwallcorner committed Dec 11, 2024
1 parent f30997e commit c2d6edb
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 14 deletions.
Binary file modified jar/spider.jar
Binary file not shown.
11 changes: 10 additions & 1 deletion json/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spider": "../jar/spider.jar;md5;92ca9354dbc6a80563a500663ed2491e",
"spider": "../jar/spider.jar;md5;198903037572d4d7d5e030a14792ab76",
"sites": [
{
"key": "Douban",
Expand Down Expand Up @@ -37,6 +37,15 @@
"changeable": 0,
"ext": {}
},
{
"key": "DUB",
"name": "DUB",
"type": 3,
"api": "csp_DUB",
"searchable": 0,
"changeable": 0,
"ext": {}
},
{
"key": "QxiTv",
"name": "七喜 | 影视",
Expand Down
2 changes: 1 addition & 1 deletion json/configAll.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spider": "../jar/spider.jar;md5;92ca9354dbc6a80563a500663ed2491e",
"spider": "../jar/spider.jar;md5;198903037572d4d7d5e030a14792ab76",
"sites": [
{
"key": "Douban",
Expand Down
73 changes: 63 additions & 10 deletions src/main/java/com/github/catvod/spider/DUB.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
package com.github.catvod.spider

import cn.hutool.core.codec.Base64
import com.github.catvod.bean.Class
import com.github.catvod.bean.Result
import com.github.catvod.bean.Vod
import com.github.catvod.bean.Vod.VodPlayBuilder.PlayUrl
import com.github.catvod.crawler.Spider
import com.github.catvod.crawler.SpiderDebug
import com.github.catvod.net.OkHttp
import com.github.catvod.utils.Image
import com.github.catvod.utils.Json
import com.github.catvod.utils.Utils
import org.jsoup.Jsoup
import org.jsoup.select.Elements
import java.util.HashMap
import java.net.URLDecoder
import java.net.URLEncoder
import java.util.*

class DUB: Spider() {
private val host = Utils.base64Decode("aHR0cHM6Ly90di5nYm9rdS5jb20v")

private val cateFormat = "/vodtype/%s.html" // tid-page
private val cateFormat2 = "/vodtype/%s-%s.html" // tid-page
private var referer = "duboku.tv"
private var referer = Utils.base64Decode("YzNSaGRHbGpMM0JzWVhsbGNpOTJhV1JxY3pJMUxuQm9jQT09")
private val signUrl = Utils.base64Decode("c3RhdGljL3BsYXllci92aWRqczI1LnBocA==")
private val searchUrl = Utils.base64Decode("L3ZvZHNlYXJjaC8tLS0tLS0tLS0tLS0tLmh0bWw/d2Q9JXMmc3VibWl0PQ==")

// private val classList = Class.parseFromFormatStr("")
override fun homeContent(filter: Boolean): String {
val result = OkHttp.string("https://tv.gboku.com/vodtype/1.html", Utils.webHeaders("duboku.tv"))
// val result = OkHttp.string("$host/vodtype/2.html", Utils.webHeaders("duboku.tv"))
// val result = OkHttp.string("https://tv.gboku.com/vodtype/1.html", Utils.webHeaders("duboku.tv"))
val result = OkHttp.string("$host/vodtype/2.html", Utils.webHeaders("duboku.tv"))
val document = Jsoup.parse(result)
val select = document.select("ul.nav-list > li")

Expand All @@ -32,7 +42,7 @@ class DUB: Spider() {
}

override fun categoryContent(tid: String?, pg: String?, filter: Boolean, extend: HashMap<String, String>?): String {
var url = ""
var url: String
if(pg == "1"){
url = cateFormat.format(tid)
}else{
Expand All @@ -50,7 +60,7 @@ class DUB: Spider() {
vod.apply {
setVodRemarks(fa.text())
setVodId(fa.attr("href"))
setVodPic(fa.attr("data-original"))
setVodPic(Image.UrlHeaderBuilder(fa.attr("data-original")).referer(referer).build())
setVodName(fa.attr("title"))
}
vodList.add(vod)
Expand All @@ -59,7 +69,9 @@ class DUB: Spider() {
}

override fun detailContent(ids: MutableList<String>): String {
val string = OkHttp.string("$host${ids[0]}", Utils.webHeaders(referer))
val u = "$host${ids[0]}"
val string = OkHttp.string(u, Utils.webHeaders(referer))
referer = u
val document = Jsoup.parse(string)
val detail = document.select(".myui-content__detail")
val vod = Vod()
Expand Down Expand Up @@ -106,15 +118,56 @@ class DUB: Spider() {


override fun searchContent(key: String?, quick: Boolean): String {
return super.searchContent(key, quick)
val string =
OkHttp.string("$host${searchUrl.format(URLEncoder.encode(key, "UTF-8"))}", Utils.webHeaders(referer))
val document = Jsoup.parse(string)
val select = document.select("ul#searchList > li")
val vodList = mutableListOf<Vod>()
for (element in select) {
vodList.add(Vod().apply {
val text = element.select("a.searchKey")
setVodName(text.text())
setVodId(text.attr("href"))
val thumb = element.select(".thumb > a")
setVodPic(Image.UrlHeaderBuilder(thumb.attr("data-original")).referer(referer).build())
setVodRemarks(thumb.select(".tag").text())
})
}
return Result.string(vodList)
}

override fun searchContent(key: String?, quick: Boolean, pg: String?): String {
return super.searchContent(key, quick, pg)
}

override fun playerContent(flag: String?, id: String?, vipFlags: MutableList<String>?): String {
return super.playerContent(flag, id, vipFlags)
@OptIn(ExperimentalStdlibApi::class)
override fun playerContent(flag: String?, id: String, vipFlags: MutableList<String>?): String {
val string = OkHttp.string("$host$id")
val regex = Regex("var\\s*player_[a-z]{0,4}\\s*=\\s*([^<]+)")
val data = regex.find(string)
var url = ""
if((data?.groupValues?.size ?: 0) > 0){
val parse = Json.parse(data!!.groupValues[1])
val rst = parse.asJsonObject
val encrypt = rst.get("encrypt").asInt
url = if(encrypt == 2){
URLDecoder.decode(Base64.decodeStr(rst.get("url").asString), "UTF-8")
}else{
URLDecoder.decode(rst.get("url").asString, "UTF-8")
}
}else{
SpiderDebug.log("DUB 获取播放链接失败 $string")
}

val signDocument = OkHttp.string("$host$signUrl", Utils.webHeaders(referer))
val signRegx = Regex("encodeURIComponent\\s*\\(\\s*[\"']([^\"']+)[\"']\\s*\\)")
val find = signRegx.find(signDocument)
if((find?.groupValues?.size ?: 0) > 0){
val sign = find!!.groupValues[1]
return Result.get().url("$url?sign=${URLEncoder.encode(sign, "UTF-8")}").string()
}
SpiderDebug.log("DUB 获取签名失败")
return Result.error("获取播放链接失败")
}

}
6 changes: 5 additions & 1 deletion src/test/java/DUBTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cn.hutool.core.lang.Assert
import com.github.catvod.bean.Result
import com.github.catvod.spider.DUB
import common.TestInterface
import org.junit.jupiter.api.Test

Expand Down Expand Up @@ -32,12 +33,15 @@ class DUBTest:TestInterface<DUB> {
assert(detailContent)
}

@Test
override fun playTest() {
val playerContent = t.playerContent("", "/vodplay/5067-1-1.html", mutableListOf())
assert(playerContent)
}

@Test
override fun searchTest() {
TODO("Not yet implemented")
val searchContent = t.searchContent("庆余年", false)
assert(searchContent)
}
}
10 changes: 9 additions & 1 deletion src/test/java/common/Util.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package common;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HtmlUtil;
import com.github.catvod.utils.Utils;
Expand All @@ -14,7 +15,7 @@
public class Util {
@Test
public void strEncode(){
String s = "/api.php/provide/search_result";
String s = "/vodsearch/-------------.html?wd=%s&submit=";
System.out.println(Utils.base64Encode(s));
}

Expand All @@ -34,6 +35,13 @@ public void md5Test(){
System.out.println(s1);
}

@Test
public void decodeTest(){
String s = "JTY4JTc0JTc0JTcwJTczJTNBJTJGJTJGJTc0JTMyJTMwJTZEJTJFJTZFJTYyJTZGJTZCJTc1JTJFJTYzJTZGJTZEJTJGJTMyJTMwJTMyJTM0JTMxJTMyJTMwJTM2JTJGJTRGJTQzJTZGJTU3JTM1JTUyJTU2JTU0JTJGJTY5JTZFJTY0JTY1JTc4JTJFJTZEJTMzJTc1JTM4";
String s1 = Base64.decodeStr(s);
System.out.println(s1);
}

@Test
public void htmlEncode(){
String html = FileUtil.readString(new File("E:\\Archives\\compose-mutiplatform-workspace\\Test\\https __www.yjys.me_.htm"), "utf-8");
Expand Down

0 comments on commit c2d6edb

Please sign in to comment.