Playlist fixes, add YoutubeDl::get_stream function (#279)
* Fix(ytdl): Return all results when querying a URL * Publicly export `songbird::input::metadata::ytdl::Output` Closes: https://github.com/serenity-rs/songbird/issues/277 * Make `YoutubeDl::query` public * Abstract getting streams from YoutubeDl into functions `get_stream` and `get_streams` * fmt, remove get_streams * Fix doc comment * fixup doc comments, export `metadata::ytdl::Output` as `YoutubeDlOutput` * fmt * export metadata * fixup! fixup doc comments, export `metadata::ytdl::Output` as `YoutubeDlOutput`
This commit is contained in:
@@ -1,28 +1,49 @@
|
||||
//! `YoutubeDl` track metadata.
|
||||
|
||||
use super::AuxMetadata;
|
||||
use crate::constants::SAMPLE_RATE_RAW;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, time::Duration};
|
||||
|
||||
/// Information returned by yt-dlp about a URL.
|
||||
///
|
||||
/// Returned by [`crate::input::YoutubeDl::query`].
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct Output {
|
||||
/// The main artist.
|
||||
pub artist: Option<String>,
|
||||
/// The album name.
|
||||
pub album: Option<String>,
|
||||
/// The channel name.
|
||||
pub channel: Option<String>,
|
||||
/// The duration of the stream in seconds.
|
||||
pub duration: Option<f64>,
|
||||
/// The size of the stream.
|
||||
pub filesize: Option<u64>,
|
||||
/// Required HTTP headers to fetch the track stream.
|
||||
pub http_headers: Option<HashMap<String, String>>,
|
||||
/// Release date of this track.
|
||||
pub release_date: Option<String>,
|
||||
/// The thumbnail URL for this track.
|
||||
pub thumbnail: Option<String>,
|
||||
/// The title of this track.
|
||||
pub title: Option<String>,
|
||||
/// The track name.
|
||||
pub track: Option<String>,
|
||||
/// The date this track was uploaded on.
|
||||
pub upload_date: Option<String>,
|
||||
/// The name of the uploader.
|
||||
pub uploader: Option<String>,
|
||||
/// The stream URL.
|
||||
pub url: String,
|
||||
/// The URL of the public-facing webpage for this track.
|
||||
pub webpage_url: Option<String>,
|
||||
/// The stream protocol.
|
||||
pub protocol: Option<String>,
|
||||
}
|
||||
|
||||
impl Output {
|
||||
/// Requests auxiliary metadata which can be accessed without parsing the file.
|
||||
pub fn as_aux_metadata(&self) -> AuxMetadata {
|
||||
let album = self.album.clone();
|
||||
let track = self.track.clone();
|
||||
|
||||
Reference in New Issue
Block a user