[Feature Request] Piped support for YouTube
IngwiePhoenix opened this issue · 2 comments
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
- I have checked the documentation to make sure this feature doesn't already exist
- I have searched for similar feature requests
- I have confirmed that my requests is not on the list of things that will not be added
- I am running the latest version of the bot:
Hi, I'm interested in taking on this issue.
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!