javtiful proxy
This commit is contained in:
@@ -366,36 +366,7 @@ impl JavtifulProvider {
|
|||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
let quality="1080p".to_string();
|
let quality="1080p".to_string();
|
||||||
let video_id = url
|
let video_url = url.replace("javtiful.com","hottub.spacemoehre.de/proxy/javtiful");
|
||||||
.split('/')
|
|
||||||
.nth(4)
|
|
||||||
.ok_or_else(|| ErrorKind::Parse("video id for media".into()))?
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let token = text.split("data-csrf-token=\"")
|
|
||||||
.nth(1)
|
|
||||||
.and_then(|s| s.split('"').next())
|
|
||||||
.ok_or_else(|| ErrorKind::Parse("csrf token".into()))?
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let form = wreq::multipart::Form::new()
|
|
||||||
.text("video_id", video_id.clone())
|
|
||||||
.text("pid_c", "".to_string())
|
|
||||||
.text("token", token.clone());
|
|
||||||
let resp = requester
|
|
||||||
.post_multipart(
|
|
||||||
"https://javtiful.com/ajax/get_cdn",
|
|
||||||
form,
|
|
||||||
vec![("Referer".to_string(), url.to_string())],
|
|
||||||
Some(Version::HTTP_11),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|e| Error::from(format!("{}", e)))?;
|
|
||||||
let text = resp.text().await?;
|
|
||||||
let json: serde_json::Value = serde_json::from_str(&text)?;
|
|
||||||
let video_url = json.get("playlists")
|
|
||||||
.ok_or_else(|| ErrorKind::Parse("video_url in json".into()))?
|
|
||||||
.to_string().replace("\"", "");
|
|
||||||
Ok((
|
Ok((
|
||||||
tags,
|
tags,
|
||||||
vec![VideoFormat::new(video_url, quality, "video/mp4".into())],
|
vec![VideoFormat::new(video_url, quality, "video/mp4".into())],
|
||||||
|
|||||||
64
src/proxies/javtiful.rs
Normal file
64
src/proxies/javtiful.rs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
use ntex::web;
|
||||||
|
use wreq::Version;
|
||||||
|
|
||||||
|
use crate::util::requester::Requester;
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct JavtifulProxy {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl JavtifulProxy {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
JavtifulProxy {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_video_url(
|
||||||
|
&self,
|
||||||
|
url: String,
|
||||||
|
requester: web::types::State<Requester>,
|
||||||
|
) -> String {
|
||||||
|
let mut requester = requester.get_ref().clone();
|
||||||
|
let url = "https://javtiful.com/".to_string() + &url;
|
||||||
|
let text = requester.get(&url, None).await.unwrap_or("".to_string());
|
||||||
|
if text.is_empty() {
|
||||||
|
return "".to_string();
|
||||||
|
}
|
||||||
|
let video_id = url
|
||||||
|
.split('/')
|
||||||
|
.nth(4)
|
||||||
|
.unwrap_or("")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let token = text.split("data-csrf-token=\"")
|
||||||
|
.nth(1)
|
||||||
|
.and_then(|s| s.split('"').next())
|
||||||
|
.unwrap_or("")
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let form = wreq::multipart::Form::new()
|
||||||
|
.text("video_id", video_id.clone())
|
||||||
|
.text("pid_c", "".to_string())
|
||||||
|
.text("token", token.clone());
|
||||||
|
let resp = match requester
|
||||||
|
.post_multipart(
|
||||||
|
"https://javtiful.com/ajax/get_cdn",
|
||||||
|
form,
|
||||||
|
vec![("Referer".to_string(), url.to_string())],
|
||||||
|
Some(Version::HTTP_11),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(r) => r,
|
||||||
|
Err(_) => return "".to_string(),
|
||||||
|
};
|
||||||
|
let text = resp.text().await.unwrap_or_default();
|
||||||
|
let json: serde_json::Value = serde_json::from_str(&text).unwrap_or(serde_json::Value::Null);
|
||||||
|
let video_url = json.get("playlists")
|
||||||
|
.map(|v| v.to_string().replace("\"", ""))
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
return video_url;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,12 @@ use crate::{proxies::sxyprn::SxyprnProxy, util::requester::Requester};
|
|||||||
|
|
||||||
pub mod sxyprn;
|
pub mod sxyprn;
|
||||||
pub mod hanimecdn;
|
pub mod hanimecdn;
|
||||||
|
pub mod javtiful;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum AnyProxy {
|
pub enum AnyProxy {
|
||||||
Sxyprn(SxyprnProxy),
|
Sxyprn(SxyprnProxy),
|
||||||
|
Javtiful(javtiful::JavtifulProxy),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Proxy {
|
pub trait Proxy {
|
||||||
@@ -26,12 +28,8 @@ impl Proxy for AnyProxy {
|
|||||||
requester: web::types::State<Requester>,
|
requester: web::types::State<Requester>,
|
||||||
) -> String {
|
) -> String {
|
||||||
match self {
|
match self {
|
||||||
AnyProxy::Sxyprn(p) => {
|
AnyProxy::Sxyprn(p) => p.get_video_url(url, requester).await,
|
||||||
p.get_video_url(
|
AnyProxy::Javtiful(p) => p.get_video_url(url, requester).await,
|
||||||
url,
|
|
||||||
requester,
|
|
||||||
).await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
13
src/proxy.rs
13
src/proxy.rs
@@ -1,5 +1,6 @@
|
|||||||
use ntex::web::{self, HttpRequest};
|
use ntex::web::{self, HttpRequest};
|
||||||
|
|
||||||
|
use crate::proxies::javtiful::JavtifulProxy;
|
||||||
use crate::proxies::sxyprn::SxyprnProxy;
|
use crate::proxies::sxyprn::SxyprnProxy;
|
||||||
use crate::util::requester::Requester;
|
use crate::util::requester::Requester;
|
||||||
use crate::proxies::*;
|
use crate::proxies::*;
|
||||||
@@ -7,8 +8,13 @@ use crate::proxies::*;
|
|||||||
pub fn config(cfg: &mut web::ServiceConfig) {
|
pub fn config(cfg: &mut web::ServiceConfig) {
|
||||||
cfg.service(
|
cfg.service(
|
||||||
web::resource("/sxyprn/{endpoint}*")
|
web::resource("/sxyprn/{endpoint}*")
|
||||||
.route(web::post().to(sxyprn))
|
.route(web::post().to(proxy2redirect))
|
||||||
.route(web::get().to(sxyprn)),
|
.route(web::get().to(proxy2redirect)),
|
||||||
|
)
|
||||||
|
.service(
|
||||||
|
web::resource("/javtiful/{endpoint}*")
|
||||||
|
.route(web::post().to(proxy2redirect))
|
||||||
|
.route(web::get().to(proxy2redirect)),
|
||||||
)
|
)
|
||||||
.service(
|
.service(
|
||||||
web::resource("/hanime-cdn/{endpoint}*")
|
web::resource("/hanime-cdn/{endpoint}*")
|
||||||
@@ -19,7 +25,7 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn sxyprn(req: HttpRequest,
|
async fn proxy2redirect(req: HttpRequest,
|
||||||
requester: web::types::State<Requester>,) -> Result<impl web::Responder, web::Error> {
|
requester: web::types::State<Requester>,) -> Result<impl web::Responder, web::Error> {
|
||||||
let proxy = get_proxy(req.uri().to_string().split("/").collect::<Vec<&str>>()[2]).unwrap();
|
let proxy = get_proxy(req.uri().to_string().split("/").collect::<Vec<&str>>()[2]).unwrap();
|
||||||
let endpoint = req.match_info().query("endpoint").to_string();
|
let endpoint = req.match_info().query("endpoint").to_string();
|
||||||
@@ -35,6 +41,7 @@ async fn sxyprn(req: HttpRequest,
|
|||||||
fn get_proxy(proxy: &str) -> Option<AnyProxy> {
|
fn get_proxy(proxy: &str) -> Option<AnyProxy> {
|
||||||
match proxy {
|
match proxy {
|
||||||
"sxyprn" => Some(AnyProxy::Sxyprn(SxyprnProxy::new())),
|
"sxyprn" => Some(AnyProxy::Sxyprn(SxyprnProxy::new())),
|
||||||
|
"javtiful" => Some(AnyProxy::Javtiful(JavtifulProxy::new())),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user