Added youtube url link extraction
This commit is contained in:
parent
e1bf4c3ea4
commit
8fea066b81
@ -92,8 +92,26 @@ fn render_media_list(props: &MediaListProps) -> Html {
|
||||
None => {}
|
||||
};
|
||||
let mut media = (*media_handle).clone();
|
||||
media.media_list.push(Media::Video((*video_str).clone()));
|
||||
media_handle.set(media);
|
||||
let video_string = (*video_str).clone();
|
||||
|
||||
if video_string.contains("v=") {
|
||||
let split = match video_string.split_once("v=") {
|
||||
Some(split) => split,
|
||||
None => return
|
||||
};
|
||||
if split.1.contains('&') {
|
||||
let split_again = match split.1.split_once('&') {
|
||||
Some(split_again) => split_again,
|
||||
None => return
|
||||
};
|
||||
media.media_list.push(Media::Video(format!("https://www.youtube.com/embed/{}", split_again.0,)));
|
||||
media_handle.set(media);
|
||||
} else {
|
||||
media.media_list.push(Media::Video(format!("https://www.youtube.com/embed/{}", split.1.to_string())));
|
||||
media_handle.set(media);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user