Skip to content

Commit

Permalink
trying to fix playing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
cycle-five committed Jul 11, 2024
1 parent a0f5426 commit 9cefc3d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crack-core/src/commands/music/play_utils/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ impl QueryType {
QueryType::VideoLink(query) => {
tracing::warn!("In VideoLink");
video_info_to_source_and_metadata(client.clone(), query.clone()).await
// let mut ytdl = YoutubeDl::new(client, query);
// let mut ytdl = YoutubeDl::new(client, query.clone());
// tracing::warn!("ytdl: {:?}", ytdl);
// let metadata = ytdl.aux_metadata().await?;
// let my_metadata = MyAuxMetadata::Data(metadata);
Expand Down
11 changes: 11 additions & 0 deletions crack-core/src/commands/music/play_utils/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,15 @@ mod test {
let res = get_msg(mode, query_or_url, is_prefix);
assert_eq!(res, Some("asdf asdf asdf asd f".to_string()));
}

// #[tokio::test]
// async fn test_youtube_query_queues() {
// let url = "https://www.youtube.com/playlist?list=PLzk-s3QLDrQ8tGpRzZ01woRoUd4ed-84q"
// .to_string();
// let mut ytdl = QueryType::Youtube(url);
// let ctx = crate::test::test_context().await;
// let call = ctx.get_call().await;
// let res = queue_track_front(ctx, &call, &ytdl).await;
// assert!(res.is_ok());
// }
}
1 change: 0 additions & 1 deletion crack-core/src/http_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ mod test {
let url = "https://example.com";

let final_url = resolve_final_url(url).await.unwrap();
// assert_eq!(final_url, "https://example.com/");
assert_eq!(final_url, "https://example.com/");
}
}
26 changes: 22 additions & 4 deletions crack-core/src/sources/rusty_ytdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,18 +416,18 @@ impl Seek for MediaSourceStream {

impl MediaSource for MediaSourceStream {
fn is_seekable(&self) -> bool {
false
true
}

fn byte_len(&self) -> Option<u64> {
// Some(self.stream.content_length() as u64)
Some(0)
Some(self.stream.content_length() as u64)
// Some(0)
}
}

#[cfg(test)]
mod test {
use crate::http_utils;
use crate::{http_utils, sources::rusty_ytdl::RustyYoutubeClient};
use rusty_ytdl::search::YouTube;
use songbird::input::YoutubeDl;
use std::sync::Arc;
Expand Down Expand Up @@ -529,4 +529,22 @@ mod test {

println!("{:?}", res_all);
}

#[tokio::test]
async fn test_rusty_ytdl_plays() {
let client = http_utils::get_client();
let rusty_ytdl = RustyYoutubeClient::new_with_client(client.clone()).unwrap();
let result = rusty_ytdl.search(String::from("The Night Chicago Died"), 1).await.unwrap();
let result = result.first().unwrap();
let metadata = RustyYoutubeClient::search_result_to_aux_metadata(result);
let url = metadata.source_url.unwrap();

println!("{:?}", url);

}

// #[tokio::test]
// async fn test_can_play_ytdl() {
// let url = "https://www.youtube.com/watch?v=p-L0NpaErkk".to_string();
// }
}

0 comments on commit 9cefc3d

Please sign in to comment.