Skip to content

Commit d856431

Browse files
committed
fix(yt): various fixes
1 parent b337e29 commit d856431

File tree

4 files changed

+14
-27
lines changed

4 files changed

+14
-27
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edition = "2021"
1010
rust-version = "1.75"
1111

1212
[dependencies]
13+
tracing = "0.1"
1314
irc = { version = "1.0", optional = true, default-features = false }
1415
tokio = { version = "1.42", default-features = false, features = [ "net" ] }
1516
futures-util = { version = "0.3", default-features = false }

src/youtube/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(crate) fn get_http_client() -> &'static reqwest::Client {
4949
let mut headers = HeaderMap::new();
5050
// Set our Accept-Language to en-US so we can properly match substrings
5151
headers.append(header::ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.5"));
52-
headers.append(header::USER_AGENT, HeaderValue::from_static("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:123.0) Gecko/20100101 Firefox/123.0"));
52+
headers.append(header::USER_AGENT, HeaderValue::from_static("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:138.0) Gecko/20100101 Firefox/138.0"));
5353
// Referer is required by Signaler endpoints.
5454
headers.append(header::REFERER, HeaderValue::from_static("https://www.youtube.com/"));
5555
reqwest::Client::builder().default_headers(headers).build().unwrap()
@@ -172,7 +172,9 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
172172
'i: loop {
173173
match chunk.cont().await {
174174
Some(Ok(c)) => chunk = c,
175-
Some(Err(err)) => eprintln!("{err:?}"),
175+
Some(Err(e)) => {
176+
tracing::error!(source = ?e, trigger = "between-sessions", "Failed to fetch continuation");
177+
}
176178
_ => break 'i
177179
};
178180

@@ -216,7 +218,9 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
216218

217219
match chunk.cont().await {
218220
Some(Ok(c)) => chunk = c,
219-
Some(Err(err)) => eprintln!("{err:?}"),
221+
Some(Err(e)) => {
222+
tracing::error!(source = ?e, trigger = "signal", "Failed to fetch continuation");
223+
}
220224
_ => break 'i
221225
};
222226
channel.topic = chunk.signaler_topic.clone().unwrap();
@@ -244,7 +248,7 @@ pub async fn stream(options: &ChatContext) -> Result<BoxStream<'_, Result<Action
244248
}
245249
Ok(None) => break,
246250
Err(e) => {
247-
eprintln!("{e:?}");
251+
tracing::error!(source = ?e, "Signaler stream errored");
248252
break;
249253
}
250254
}

src/youtube/types/get_live_chat.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,15 @@ impl GetLiveChatResponse {
6666
pub async fn fetch(options: &ChatContext, continuation: impl AsRef<str>) -> Result<Self, Error> {
6767
let body = GetLiveChatRequestBody::new(continuation.as_ref(), &options.client_version, "WEB");
6868
Ok(get_http_client()
69-
.post(Url::parse_with_params(if options.live_status.updates_live() { TANGO_LIVE_ENDPOINT } else { TANGO_REPLAY_ENDPOINT }, [
70-
("key", options.api_key.as_str()),
71-
("prettyPrint", "false")
72-
])?)
69+
.post(Url::parse_with_params(
70+
if options.live_status.updates_live() { TANGO_LIVE_ENDPOINT } else { TANGO_REPLAY_ENDPOINT },
71+
[("key", options.api_key.as_str()), ("prettyPrint", "false")]
72+
)?)
7373
.simd_json(&body)?
7474
.send()
7575
.await?
7676
.simd_json()
77-
.await
78-
.unwrap())
77+
.await?)
7978
}
8079
}
8180

src/youtube/types/streams_page.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub enum PageContentsRenderer {
3131
#[serde(rename_all = "camelCase")]
3232
pub enum TabItemRenderer {
3333
TabRenderer {
34-
endpoint: FeedEndpoint,
3534
title: String,
3635
#[serde(default)]
3736
selected: bool,
@@ -40,21 +39,6 @@ pub enum TabItemRenderer {
4039
ExpandableTabRenderer {}
4140
}
4241

43-
#[derive(Debug, Deserialize)]
44-
#[serde(rename_all = "camelCase")]
45-
pub struct FeedEndpoint {
46-
pub browse_endpoint: BrowseEndpoint,
47-
pub command_metadata: CommandMetadata
48-
}
49-
50-
#[derive(Debug, Deserialize)]
51-
#[serde(rename_all = "camelCase")]
52-
pub struct BrowseEndpoint {
53-
pub browse_id: String,
54-
pub params: String,
55-
pub canonical_base_url: String
56-
}
57-
5842
#[derive(Debug, Deserialize)]
5943
#[serde(rename_all = "camelCase")]
6044
pub enum FeedContentsRenderer {
@@ -79,7 +63,6 @@ pub enum RichGridItem {
7963
pub enum RichItemContent {
8064
#[serde(rename_all = "camelCase")]
8165
VideoRenderer {
82-
description_snippet: LocalizedText,
8366
thumbnail: ImageContainer,
8467
thumbnail_overlays: Vec<ThumbnailOverlay>,
8568
video_id: String

0 commit comments

Comments
 (0)