개요
유튜브 api를 사용하려고 했는데
일일 할당량이 10,000 이고
썸네일은 1번에 50회
검색은 1번에 100회를 소모해서
db에 저장된 링크값으로 api를 쓰기에는 10,000회가 모자를 것같다는 생각에
db에 링크를 저장하고 정규식으로 id값만 추출한 후
프론트단에서 그 id 값을 이용하는 것으로 구현할것이다.
- 동영상주소 : https://www.youtube.com/watch?v=2hTRAVIXjX8
- 썸네일주소 : http://img.youtube.com/vi/2hTRAVIXjX8/2.jpg
- 디폴트썸네일주소 : https://img.youtube.com/vi/2hTRAVIXjX8/mqdefault.jpg
- 저장명: lq~, mq~, hq~ (퀄리티순)- 출처 https://solbel.tistory.com/466
function extractVideoID(url) {
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
if (match && match[7].length == 11) {
return match[7];
} else {
alert("Could not extract video ID.");
}
}