feat: video_id script, move proto include to lib

This commit is contained in:
2026-04-13 10:01:58 +02:00
parent 5a661c826d
commit 1d298794ce
4 changed files with 26 additions and 14 deletions

5
get_url.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
CHANNEL=$1
LIVE_ID=$(curl -sL "https://www.youtube.com/@$CHANNEL/live" | grep -oE '"videoId":"([^"]+)"' | head -n 1 | cut -d'"' -f4)
echo "$LIVE_ID"

View File

@@ -1,11 +0,0 @@
use tonic::{Request, Response, Status, transport::Server};
// use stream_list::greeter_server::{Greeter, GreeterServer};
// use stream_list::{HelloReply, HelloRequest};
use stream_list::{
LiveChatMessageListRequest,
v3_data_live_chat_message_service_server::V3DataLiveChatMessageService,
};
pub mod stream_list {
tonic::include_proto!("youtube.api.v3");
}

19
src/lib.rs Normal file
View File

@@ -0,0 +1,19 @@
use std::process::Command;
pub mod stream_list {
tonic::include_proto!("youtube.api.v3");
}
fn get_live_id(channel: String) -> String {
let video_id = Command::new("./get_url.sh")
.arg(channel)
.output()
.expect("couldn't execute fetch script");
let stdout = video_id.stdout.as_slice().to_vec();
String::from_utf8_lossy(&stdout).trim().to_string()
}
#[test]
fn test_get_live_id() {
get_live_id("linlyboi".to_string());
}

View File

@@ -1,9 +1,8 @@
use client::stream_list::{ use tonic::{Request, Status, metadata::MetadataValue, transport::Channel};
use youtube_chat_rs::stream_list::{
LiveChatMessageListRequest, LiveChatMessageListRequest,
v3_data_live_chat_message_service_client::V3DataLiveChatMessageServiceClient, v3_data_live_chat_message_service_client::V3DataLiveChatMessageServiceClient,
}; };
use tonic::{Request, Status, metadata::MetadataValue, transport::Channel};
mod grpc;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> { async fn main() -> Result<(), Box<dyn std::error::Error>> {