Skip to content

Commit 32d664f

Browse files
committed
fix(yt): use different continuation token source
1 parent 6419dc9 commit 32d664f

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/youtube/context.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,10 @@ impl ChatContext {
220220
None => "2.20240207.07.00".to_string()
221221
};
222222

223-
static LIVE_CONTINUATION_REGEX: OnceLock<Regex> = OnceLock::new();
224-
static REPLAY_CONTINUATION_REGEX: OnceLock<Regex> = OnceLock::new();
225-
let continuation_regex = if live_status.updates_live() {
226-
LIVE_CONTINUATION_REGEX.get_or_init(|| Regex::new(
227-
r#"Live chat['"],\s*['"]selected['"]:\s*(?:true|false),\s*['"]continuation['"]:\s*\{\s*['"]reloadContinuationData['"]:\s*\{['"]continuation['"]:\s*['"](.+?)['"]"#
228-
).unwrap())
229-
} else {
230-
REPLAY_CONTINUATION_REGEX.get_or_init(|| {
231-
Regex::new(
232-
r#"Top chat replay['"],\s*['"]selected['"]:\s*true,\s*['"]continuation['"]:\s*\{\s*['"]reloadContinuationData['"]:\s*\{['"]continuation['"]:\s*['"](.+?)['"]"#
233-
)
234-
.unwrap()
235-
})
236-
};
223+
static CONTINUATION_REGEX: OnceLock<Regex> = OnceLock::new();
224+
let continuation_regex = CONTINUATION_REGEX.get_or_init(|| {
225+
Regex::new(r#"['"]continuations['"]:\s*\[\{\s*['"]reloadContinuationData['"]:\s*\{['"]continuation['"]:\s*['"](.+?)['"]"#).unwrap()
226+
});
237227
let continuation = match continuation_regex.captures(&page_contents).and_then(|captures| captures.get(1)) {
238228
Some(matched) => matched.as_str().to_string(),
239229
None => return Err(Error::NoChatContinuation)

src/youtube/types/get_live_chat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ impl GetLiveChatResponse {
6868
Ok(get_http_client()
6969
.post(Url::parse_with_params(
7070
if options.live_status.updates_live() { TANGO_LIVE_ENDPOINT } else { TANGO_REPLAY_ENDPOINT },
71-
[("key", options.api_key.as_str()), ("prettyPrint", "false")]
71+
[("prettyPrint", "false")]
7272
)?)
7373
.simd_json(&body)?
7474
.send()

0 commit comments

Comments
 (0)