Skip to content

Commit

Permalink
[mod] 斗鱼直播间标题, js 运行时修改
Browse files Browse the repository at this point in the history
  • Loading branch information
Borber committed Feb 8, 2023
1 parent 012bdd4 commit d311cba
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/live/douyu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down Expand Up @@ -142,6 +141,15 @@ async fn douyu_do_js(rid: &str) -> Result<ShowType> {
.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
Expand Down Expand Up @@ -204,7 +212,7 @@ async fn douyu_do_js(rid: &str) -> Result<ShowType> {
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),
}
Expand Down

0 comments on commit d311cba

Please sign in to comment.