Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer youtube-dlc as an alternative to youtube-dl #1

Merged
merged 5 commits into from
Nov 13, 2020
Merged

Offer youtube-dlc as an alternative to youtube-dl #1

merged 5 commits into from
Nov 13, 2020

Conversation

peppizza
Copy link
Contributor

@FelixMcFelix FelixMcFelix added the enhancement New feature or request label Nov 13, 2020
Copy link
Member

@FelixMcFelix FelixMcFelix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, it'll be useful to support this as a drop in.

I've made some comments around what feature flags to use, and how -- mainly to minimise friction.

@@ -135,6 +136,8 @@ driver = [
"url",
"xsalsa20poly1305",
]
youtube-dl = []
youtube-dlc = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just youtube-dlc will suffice: see below.

build.rs Outdated
If you are unsure, go with `youtube-dl`, however, if you encounter any errors with `youtube-dl`,
such as tracks ending immedietly when they are queued/played, try 'youtube-dlc'."
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add only one new feature (youtube-dl), this check can be avoided.

In general, it's better to avoid adding in feature traps/incompatibilities where you can.

#[cfg(feature = "youtube-dl")]
const YOUTUBE_DL_COMMAND: &str = "youtube-dl";
#[cfg(feature = "youtube-dlc")]
const YOUTUBE_DL_COMMAND: &str = "youtube-dlc";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this so that the default is "youtube-dl", and the youtube-dlc feature changes this?

E.g., constant computation allows constructs such as:

const TEST: &str = if cfg!(feature = "") {
    "A"
} else {
    "B"
};

/// Creates a streamed audio source with `youtube-dl` and `ffmpeg`.
#[cfg(any(feature = "youtube-dl", feature = "youtube-dlc"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With one override feature, this check is unnecessary. This also stops Restartable sources from failing to compile.

@@ -102,6 +108,7 @@ pub(crate) async fn _ytdl(uri: &str, pre_args: &[&str]) -> Result<Input> {

/// Creates a streamed audio source from YouTube search results with `youtube-dl`,`ffmpeg`, and `ytsearch`.
/// Takes the first video listed from the YouTube search.
#[cfg(any(feature = "youtube-dl", feature = "youtube-dlc"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the previous instance,

@FelixMcFelix
Copy link
Member

Lgtm. Thanks!

@FelixMcFelix FelixMcFelix merged commit 6702520 into serenity-rs:current Nov 13, 2020
@FelixMcFelix FelixMcFelix mentioned this pull request Jan 8, 2021
GnomedDev pushed a commit to GnomedDev/songbird that referenced this pull request May 26, 2022
Update to next + fix queue + fix clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants