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

[Feature Request] Piped support for YouTube #1492

Open
4 tasks done
IngwiePhoenix opened this issue Mar 2, 2024 · 2 comments
Open
4 tasks done

[Feature Request] Piped support for YouTube #1492

IngwiePhoenix opened this issue Mar 2, 2024 · 2 comments

Comments

@IngwiePhoenix
Copy link

Is your feature request related to a problem? Please describe.

Not that I am aware of.

What is your ideal solution to the problem?

I would like to be able to configure the bot to utilize my Piped instance when playing back Youtube videos.

Piped: https://github.com/TeamPiped/Piped
Their API: https://docs.piped.video/docs/api-documentation/

I host my own instance, it'd be neat to use it - or at least have the links be recognized.

How would this feature be used?

When using !play <url>, the bot checks if the URL matches the configured Piped instance, fetches the apropriate Youtube URL, and continues from there on as normal.

Additional Info

Nothing I can think of, really.

Checklist

@Yohr011
Copy link

Yohr011 commented Apr 2, 2024

Hi, I'm interested in taking on this issue.

@IngwiePhoenix
Copy link
Author

@Yohr011

I can not do Java; but I can give you a few pointers.

// Target the Piped API directly; the frontent is just an SPA.
string pipedInstance = "https://pipedapi.ingwie.me";
string videoId = (new URL("https://www.youtube.com/watch?v=pMyuGyRkEEc")).getQueryParam("v"); // mock

// From the JSON response:
struct PipedAPI_Response {
  StreamInfo[] audioStreams;
  StreamInfo[] videoStreams;
  int duration; // seconds
  string title;
  // All other keys ignored, not needed
};

struct StreamInfo {
  string format; // file format specifier, caps
  string quality; // quality specifier; stringified aka. human-readable
  string url; // Piped Proxy URL that retrives the URL
};

All you need to do now is to fetch(pipedInstance + "/streams/" + videoId) and get .audioStreams (the bot probably doesnt care for videos) and then pick whichever .quality is satisfactory and send .url to the playback handler.

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants