Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: panic while ep_id is "None" #56

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/mods/get_bili_res.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use pcre2::bytes::Regex;
use qstring::QString;
use serde_json::{self, json};
use std::sync::Arc;
use std::thread::spawn;

pub async fn get_playurl(
req: &HttpRequest,
Expand Down Expand Up @@ -392,7 +391,7 @@ pub async fn get_playurl(
data_type: SesourceType::PlayUrl,
health_type: HealthType::Offline,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -498,7 +497,7 @@ pub async fn get_playurl(
data_type: SesourceType::PlayUrl,
health_type: HealthType::Offline,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -565,7 +564,7 @@ pub async fn get_playurl(
data_type: SesourceType::PlayUrl,
health_type: HealthType::Online,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand All @@ -592,7 +591,7 @@ pub async fn get_playurl(
data_type: SesourceType::PlayUrl,
health_type: HealthType::Online,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand All @@ -618,7 +617,7 @@ pub async fn get_playurl(
area_num,
is_app,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -961,7 +960,7 @@ pub async fn get_search(req: &HttpRequest, is_app: bool, is_th: bool) -> HttpRes
data_type: SesourceType::PlayUrl,
health_type: HealthType::Offline,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -1037,7 +1036,7 @@ pub async fn get_search(req: &HttpRequest, is_app: bool, is_th: bool) -> HttpRes
data_type: SesourceType::PlayUrl,
health_type: HealthType::Offline,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -1132,7 +1131,7 @@ pub async fn get_search(req: &HttpRequest, is_app: bool, is_th: bool) -> HttpRes
data_type: SesourceType::Search,
health_type: HealthType::Online,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand All @@ -1159,7 +1158,7 @@ pub async fn get_search(req: &HttpRequest, is_app: bool, is_th: bool) -> HttpRes
data_type: SesourceType::Search,
health_type: HealthType::Online,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -1318,7 +1317,7 @@ pub async fn get_season(req: &HttpRequest, _is_app: bool, _is_th: bool) -> HttpR
health_type: HealthType::Offline,
area_num: 4,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down Expand Up @@ -1468,7 +1467,7 @@ pub async fn get_season(req: &HttpRequest, _is_app: bool, _is_th: bool) -> HttpR
data_type: SesourceType::PlayUrl,
health_type: HealthType::Online,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand All @@ -1495,7 +1494,7 @@ pub async fn get_season(req: &HttpRequest, _is_app: bool, _is_th: bool) -> HttpR
data_type: SesourceType::PlayUrl,
health_type: HealthType::Online,
});
spawn(move || {
tokio::spawn(async move {
//println!("[Debug] bilisender_cl.len:{}", bilisender_cl.len());
match bilisender_cl.try_send(senddata) {
Ok(_) => (),
Expand Down
12 changes: 11 additions & 1 deletion src/mods/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,17 @@ pub async fn redir_playurl_request(req: &HttpRequest, is_app: bool, is_th: bool)
_ => 2,
};
if config.area_cache_open {
if let Ok(value) = get_ep_area(pool, query.get("ep_id").unwrap(), &area_num).await {
let ep_id = if let Some(value) = query.get("ep_id") {
value
}else{
let return_data =
match get_playurl(req, is_app, is_th, query_string, query, area_num).await {
Ok(value) => value,
Err(value) => value,
};
return build_response(return_data);
};
if let Ok(value) = get_ep_area(pool, ep_id, &area_num).await {
match value {
GetEpAreaType::NoCurrentAreaData(key, redis_value) => {
match get_playurl(req, is_app, is_th, query_string, query, area_num).await {
Expand Down