Skip to content

Commit 5b46d3e

Browse files
author
Kevin Souza
committed
temp: filter dash formats
1 parent 1a03dcf commit 5b46d3e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src-tauri/src/youtube/video.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ use sqlx::prelude::FromRow;
1212

1313
use super::main::{RP_CLIENT, USING_BOTGUARD};
1414

15+
const DASH_IDS: [u32; 33] = [
16+
133, 134, 135, 136, 137, 138, 160, 212, 264, 298, 299, 266, 167, 168, 169, 170, 218, 219, 278,
17+
242, 243, 244, 245, 246, 247, 248, 271, 272, 302, 303, 308, 313, 315,
18+
];
19+
1520
#[derive(Serialize, FromRow)]
1621
pub struct FeedPageVideo {
1722
pub id: String,
@@ -240,7 +245,11 @@ fn get_player_formats(
240245
) -> (Vec<Format>, Vec<Format>) {
241246
let video = video_streams
242247
.iter()
243-
.map(|v| {
248+
.filter_map(|v| {
249+
if !DASH_IDS.contains(&v.itag) {
250+
return None;
251+
}
252+
244253
let codec = match v.codec {
245254
VideoCodec::Unknown => "Unknown",
246255
VideoCodec::Mp4v => "mp4v",
@@ -250,13 +259,13 @@ fn get_player_formats(
250259
_ => "Format not supported",
251260
};
252261

253-
Format {
262+
Some(Format {
254263
codec: codec.to_string(),
255264
src: v.url.clone(),
256265
type_: v.mime.split(';').next().unwrap_or("").trim().to_string(),
257266
height: v.height,
258267
width: v.width,
259-
}
268+
})
260269
})
261270
.collect::<Vec<Format>>();
262271

0 commit comments

Comments
 (0)