Skip to content

Commit cb40c35

Browse files
author
Kevin Souza
committed
renames and refactoring fetch_player
1 parent d262172 commit cb40c35

10 files changed

Lines changed: 279 additions & 195 deletions

File tree

src-tauri/src/feed.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use tauri::{async_runtime::Mutex, AppHandle, Emitter, State};
77
use crate::{
88
twitch::{self, stream::LiveNow},
99
user::Platform,
10-
youtube::{self, video::YouTubeVideo},
10+
youtube::{self, video::FeedPageVideo},
1111
AppState,
1212
};
1313

1414
#[derive(Serialize)]
1515
pub struct Feed {
1616
twitch: Option<Vec<LiveNow>>,
17-
youtube: Option<Vec<YouTubeVideo>>,
17+
youtube: Option<Vec<FeedPageVideo>>,
1818
}
1919

2020
#[tauri::command]
@@ -60,7 +60,7 @@ pub async fn get_feed(
6060
"SELECT id, username, title, published_at, view_count FROM youtube ORDER BY published_at DESC LIMIT 50"
6161
};
6262

63-
let mut query_builder = sqlx::query_as::<_, YouTubeVideo>(query);
63+
let mut query_builder = sqlx::query_as::<_, FeedPageVideo>(query);
6464

6565
if let Some(last) = last_published_at {
6666
query_builder = query_builder.bind(last);
@@ -154,7 +154,7 @@ pub async fn refresh_feed(
154154
channel_ids.push(channel_id);
155155
}
156156

157-
let videos = match youtube::video::fetch_videos(channel_ids).await {
157+
let videos = match youtube::video::fetch_feed_videos(channel_ids).await {
158158
Ok(videos) => videos,
159159
Err(err) => {
160160
return Err(format!("Requesting videos: {err}"));

src-tauri/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn run() {
134134
twitch::proxy::proxy_stream,
135135
twitch::chat::join_chat,
136136
youtube::main::import_subscriptions,
137-
youtube::video::fetch_player,
137+
youtube::video::fetch_video,
138138
])
139139
.run(tauri::generate_context!())
140140
.expect("while running tauri application");

src-tauri/src/twitch/stream.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const USHER_API: &str = "https://usher.ttvnw.net/api/channel/hls";
1515
#[derive(Serialize, Debug)]
1616
pub struct LiveNow {
1717
pub username: String,
18+
#[serde(rename = "startedAt")]
1819
pub started_at: String,
1920
}
2021

src-tauri/src/youtube/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ lazy_static! {
2424
.build()
2525
.unwrap()
2626
);
27+
pub static ref USING_BOTGUARD: Mutex<bool> = Mutex::new(false);
2728
}
2829

2930
pub async fn build_client(storage_dir: &Path) -> Result<()> {
@@ -41,6 +42,9 @@ pub async fn build_client(storage_dir: &Path) -> Result<()> {
4142
.storage_dir(storage_dir)
4243
.build_with_client(http_client)?;
4344

45+
let version = client.version_botguard().await;
46+
*USING_BOTGUARD.lock().await = version.is_some();
47+
4448
Ok(())
4549
}
4650

0 commit comments

Comments
 (0)