Skip to content

Commit

Permalink
Merge branch 'aquelemiguel:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cycle-five authored Sep 4, 2023
2 parents bb1cdbe + d13c701 commit c9fd875
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/commands/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ pub async fn play(
.ok_or(ParrotError::Other("failed to fetch playlist"))?;

for url in urls.iter() {
let queue =
enqueue_track(&call, &QueryType::VideoLink(url.to_string())).await?;
let Ok(queue) = enqueue_track(&call, &QueryType::VideoLink(url.to_string())).await else {
continue;
};
update_queue_messages(&ctx.http, &ctx.data, &queue, guild_id).await;
}
}
Expand Down Expand Up @@ -248,7 +249,9 @@ pub async fn play(
.ok_or(ParrotError::Other("failed to fetch playlist"))?;

for (idx, url) in urls.into_iter().enumerate() {
let queue = insert_track(&call, &QueryType::VideoLink(url), idx + 1).await?;
let Ok(queue) = insert_track(&call, &QueryType::VideoLink(url), idx + 1).await else {
continue;
};
update_queue_messages(&ctx.http, &ctx.data, &queue, guild_id).await;
}
}
Expand Down Expand Up @@ -285,8 +288,9 @@ pub async fn play(
let mut insert_idx = 1;

for (i, url) in urls.into_iter().enumerate() {
let mut queue =
insert_track(&call, &QueryType::VideoLink(url), insert_idx).await?;
let Ok(mut queue) = insert_track(&call, &QueryType::VideoLink(url), insert_idx).await else {
continue;
};

if i == 0 && !queue_was_empty {
queue = force_skip_top_track(&call.lock().await).await?;
Expand Down Expand Up @@ -327,7 +331,9 @@ pub async fn play(
.ok_or(ParrotError::Other("failed to fetch playlist"))?;

for url in urls.into_iter() {
let queue = enqueue_track(&call, &QueryType::VideoLink(url)).await?;
let Ok(queue) = enqueue_track(&call, &QueryType::VideoLink(url)).await else {
continue;
};
update_queue_messages(&ctx.http, &ctx.data, &queue, guild_id).await;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/sources/youtube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct YouTube {}

impl YouTube {
pub fn extract(query: &str) -> Option<QueryType> {
if query.contains("playlist?list=") {
if query.contains("list=") {
Some(QueryType::PlaylistLink(query.to_string()))
} else {
Some(QueryType::VideoLink(query.to_string()))
Expand Down Expand Up @@ -124,6 +124,7 @@ async fn ytdl(uri: &str) -> Result<(Child, Metadata), SongbirdError> {
"infinite", // infinite number of download retries
"--no-playlist", // only download the video if URL also has playlist info
"--ignore-config", // disable all configuration files for a yt-dlp run
"--no-warnings", // don't print out warnings
uri,
"-o",
"-", // stream data to stdout
Expand Down Expand Up @@ -173,6 +174,7 @@ async fn _ytdl_metadata(uri: &str) -> SongbirdResult<Metadata> {
"infinite", // infinite number of download retries
"--no-playlist", // only download the video if URL also has playlist info
"--ignore-config", // disable all configuration files for a yt-dlp run
"--no-warnings", // don't print out warnings
uri,
"-o",
"-", // stream data to stdout
Expand Down

0 comments on commit c9fd875

Please sign in to comment.