diff --git a/CHANGELOG.md b/CHANGELOG.md index 0069314..33c7028 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.1.17] + +### Added + +- 添加斗鱼直播间标题获取 ### Changed diff --git a/Cargo.lock b/Cargo.lock index b700a79..ec55f65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1253,7 +1253,7 @@ checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" [[package]] name = "seam" -version = "0.1.16" +version = "0.1.17" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index abf65cd..734ab72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "seam" -version = "0.1.16" +version = "0.1.17" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/live/douyu.rs b/src/live/douyu.rs index a864c35..c073cfe 100644 --- a/src/live/douyu.rs +++ b/src/live/douyu.rs @@ -7,7 +7,6 @@ use crate::util::{do_js, md5, parse_url}; use anyhow::{Ok, Result}; use chrono::prelude::*; use regex::Regex; -use serde_json::Value; const URL: &str = "https://www.douyu.com/"; const M_URL: &str = "https://m.douyu.com/"; @@ -142,6 +141,15 @@ async fn douyu_do_js(rid: &str) -> Result { .text() .await?; + let re = Regex::new(r#"roomName":"([\s\S]*?)""#).unwrap(); + let title = re + .captures(&text) + .unwrap() + .get(1) + .unwrap() + .as_str() + .to_owned(); + // 正则匹配固定位置的js代码 let re = Regex::new(r"(function ub98484234.*)\s(var.*)").unwrap(); let func = re @@ -204,7 +212,7 @@ async fn douyu_do_js(rid: &str) -> Result { parse_url(format!("{CDN_1}{key}.flv")), parse_url(format!("{CDN_2}{key}.flv")), ]; - Ok(ShowType::On(Detail::new("douyu".to_owned(), nodes))) + Ok(ShowType::On(Detail::new(title, nodes))) } _ => Ok(ShowType::Off), }